From 17f799e1017d1688a2890a1ba78e4f53d80af77e Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Thu, 3 May 2012 15:15:40 +0700 Subject: Add user entity into schema skeleton --- tests/mocks/database/schema/skeleton.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/mocks') diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index a3d5bac65..fbd533bfb 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -50,6 +50,24 @@ class Mock_Database_Schema_Skeleton { */ public static function create_tables() { + // User Table + static::$forge->add_field(array( + 'id' => array( + 'type' => 'INTEGER', + 'constraint' => 3, + ), + 'name' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + ), + 'email' => array( + 'type' => 'VARCHAR', + 'constraint' => 100, + ), + )); + static::$forge->add_key('id', TRUE); + static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE)); + // Job Table static::$forge->add_field(array( 'id' => array( @@ -77,6 +95,12 @@ class Mock_Database_Schema_Skeleton { { // Job Data $data = array( + 'user' => array( + array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com'), + array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'), + array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'), + array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'), + ) 'job' => array( array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'), -- cgit v1.2.3-24-g4f1b From d6b41bb2659f959da01aee0ddb38bb4bce6cd4b6 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 4 May 2012 15:05:22 +0700 Subject: JOIN clause API code-coverage --- tests/mocks/database/schema/skeleton.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index fbd533bfb..9ebd6e85f 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -100,7 +100,7 @@ class Mock_Database_Schema_Skeleton { array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'), array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'), array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'), - ) + ), 'job' => array( array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), array('id' => 2, 'name' => 'Politician', 'description' => 'This is not really a job'), -- cgit v1.2.3-24-g4f1b From f7377abee2ef1e165a362edc9a1c650373a002ca Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 4 May 2012 19:42:24 +0700 Subject: Trace error --- tests/mocks/database/ci_test.sqlite | Bin 17408 -> 19456 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index 86d868af2..e4128b23f 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ -- cgit v1.2.3-24-g4f1b From 1afd479059c3d6f7c46aa0c36aa56cfba7f94226 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 4 May 2012 20:34:30 +0700 Subject: HAVING clause API code-coverage --- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes tests/mocks/database/schema/skeleton.php | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index e4128b23f..d48e3317f 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index 9ebd6e85f..671336cc4 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -64,6 +64,10 @@ class Mock_Database_Schema_Skeleton { 'type' => 'VARCHAR', 'constraint' => 100, ), + 'country' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + ), )); static::$forge->add_key('id', TRUE); static::$forge->create_table('user', (strpos(static::$driver, 'pgsql') === FALSE)); @@ -96,10 +100,10 @@ class Mock_Database_Schema_Skeleton { // Job Data $data = array( 'user' => array( - array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com'), - array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com'), - array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com'), - array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com'), + array('id' => 1, 'name' => 'Derek Jones', 'email' => 'derek@world.com', 'country' => 'US'), + array('id' => 2, 'name' => 'Ahmadinejad', 'email' => 'ahmadinejad@world.com', 'country' => 'Iran'), + array('id' => 3, 'name' => 'Richard A Causey', 'email' => 'richard@world.com', 'country' => 'US'), + array('id' => 4, 'name' => 'Chris Martin', 'email' => 'chris@world.com', 'country' => 'UK'), ), 'job' => array( array('id' => 1, 'name' => 'Developer', 'description' => 'Awesome job, but sometimes makes you bored'), -- cgit v1.2.3-24-g4f1b From 8ca31f34c855c783689198f0d352e6efec352b4d Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 4 May 2012 23:57:46 +0700 Subject: PDO SQLite bug fixed, for result_object --- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index d48e3317f..23a3de2a4 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ -- cgit v1.2.3-24-g4f1b From 570e77cd78e0c704b032c3e7702372ca63d5ddaa Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 15 May 2012 18:47:24 +0700 Subject: Benchmark code-coverage --- tests/mocks/core/benchmark.php | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/mocks/core/benchmark.php (limited to 'tests/mocks') diff --git a/tests/mocks/core/benchmark.php b/tests/mocks/core/benchmark.php new file mode 100644 index 000000000..d92be21db --- /dev/null +++ b/tests/mocks/core/benchmark.php @@ -0,0 +1,3 @@ + Date: Tue, 15 May 2012 18:48:45 +0700 Subject: Clean up autoloader annotation --- tests/mocks/autoloader.php | 1 - 1 file changed, 1 deletion(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index f1bdb5d6f..92c9bea59 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -6,7 +6,6 @@ // // Prototype : // -// include_once('Mock_Core_Loader') // Will load ./mocks/core/loader.php // $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php // $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php // and so on... -- cgit v1.2.3-24-g4f1b From 8af88f3f729b7bcfd2a106f858b5445deafe5ed0 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 15 May 2012 21:52:53 +0700 Subject: Security Code coverage --- tests/mocks/core/security.php | 27 +++++++++++++++++++++++++++ tests/mocks/libraries/table.php | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tests/mocks/core/security.php (limited to 'tests/mocks') diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php new file mode 100644 index 000000000..de8e44710 --- /dev/null +++ b/tests/mocks/core/security.php @@ -0,0 +1,27 @@ +{'_'.$property}) ? $this->{'_'.$property} : NULL; + } + + // Overide inaccesible protected method + public function __call($method, $params) + { + if (is_callable(array($this, '_'.$method))) + { + return call_user_func_array(array($this, '_'.$method), $params); + } + + throw new BadMethodCallException('Method '.$method.' was not found'); + } + +} \ No newline at end of file diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php index 1a6ff8d35..97fbb30bd 100644 --- a/tests/mocks/libraries/table.php +++ b/tests/mocks/libraries/table.php @@ -2,7 +2,7 @@ class Mock_Libraries_Table extends CI_Table { - // Overide inaccesible private or protected method + // Overide inaccesible protected method public function __call($method, $params) { if (is_callable(array($this, '_'.$method))) -- cgit v1.2.3-24-g4f1b From d40a545e9e7e4dc222d58fe46fe23f3691f043ee Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 15 May 2012 22:00:14 +0700 Subject: Comment block for explanation --- tests/mocks/core/security.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/mocks') diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php index de8e44710..c5269fbc5 100644 --- a/tests/mocks/core/security.php +++ b/tests/mocks/core/security.php @@ -4,6 +4,9 @@ class Mock_Core_Security extends CI_Security { public function csrf_set_cookie() { + // We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE, + // we superseded set_cookie with directly set the cookie variable, + // @see : ./Bootstrap.php, line 16 return $this; } -- cgit v1.2.3-24-g4f1b From 7756af5df0a53930019e9fd7b828504f0c2c5427 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 15 May 2012 23:57:05 +0700 Subject: Input class code-coverage --- tests/mocks/core/input.php | 31 +++++++++++++++++++++++++++++++ tests/mocks/core/security.php | 2 +- tests/mocks/core/utf8.php | 27 +++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/mocks/core/input.php create mode 100644 tests/mocks/core/utf8.php (limited to 'tests/mocks') diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php new file mode 100644 index 000000000..8a337d2ef --- /dev/null +++ b/tests/mocks/core/input.php @@ -0,0 +1,31 @@ +_allow_get_array = (config_item('allow_get_array') === TRUE); + $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); + $this->_enable_csrf = (config_item('csrf_protection') === TRUE); + + // Assign Security and Utf8 classes + $this->security = $security; + $this->uni = $utf8; + + // Sanitize global arrays + $this->_sanitize_globals(); + } + + public function fetch_from_array($array, $index = '', $xss_clean = FALSE) + { + return parent::_fetch_from_array($array, $index, $xss_clean); + } + +} \ No newline at end of file diff --git a/tests/mocks/core/security.php b/tests/mocks/core/security.php index c5269fbc5..d7ea0e6bd 100644 --- a/tests/mocks/core/security.php +++ b/tests/mocks/core/security.php @@ -6,7 +6,7 @@ class Mock_Core_Security extends CI_Security { { // We cannot set cookie in CLI mode, so for csrf test, who rely on $_COOKIE, // we superseded set_cookie with directly set the cookie variable, - // @see : ./Bootstrap.php, line 16 + // @see : ./tests/codeigniter/core/Security_test.php, line 8 return $this; } diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php new file mode 100644 index 000000000..b77d717e7 --- /dev/null +++ b/tests/mocks/core/utf8.php @@ -0,0 +1,27 @@ + Date: Fri, 25 May 2012 04:03:56 +0700 Subject: Escape like tests, #136 verification --- tests/mocks/database/schema/skeleton.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests/mocks') diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index 671336cc4..05499f82f 100644 --- a/tests/mocks/database/schema/skeleton.php +++ b/tests/mocks/database/schema/skeleton.php @@ -88,6 +88,23 @@ class Mock_Database_Schema_Skeleton { )); static::$forge->add_key('id', TRUE); static::$forge->create_table('job', (strpos(static::$driver, 'pgsql') === FALSE)); + + // Misc Table + static::$forge->add_field(array( + 'id' => array( + 'type' => 'INTEGER', + 'constraint' => 3, + ), + 'key' => array( + 'type' => 'VARCHAR', + 'constraint' => 40, + ), + 'value' => array( + 'type' => 'TEXT', + ), + )); + static::$forge->add_key('id', TRUE); + static::$forge->create_table('misc', (strpos(static::$driver, 'pgsql') === FALSE)); } /** @@ -111,6 +128,10 @@ class Mock_Database_Schema_Skeleton { array('id' => 3, 'name' => 'Accountant', 'description' => 'Boring job, but you will get free snack at lunch'), array('id' => 4, 'name' => 'Musician', 'description' => 'Only Coldplay can actually called Musician'), ), + 'misc' => array( + array('id' => 1, 'key' => '\\xxxfoo456', 'value' => 'Entry with \\xxx'), + array('id' => 2, 'key' => '\\%foo456', 'value' => 'Entry with \\%'), + ), ); foreach ($data as $table => $dummy_data) -- cgit v1.2.3-24-g4f1b From 98dcac7ea5f82cc1d5cecedd030c5f242f1dc652 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Fri, 25 May 2012 05:07:51 +0700 Subject: Alter the escape like test, since it use raw SQL via query(), the sql statement would need to add ESCAPE clause for database(s) other than mysql --- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index 23a3de2a4..44dcef9ec 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ -- cgit v1.2.3-24-g4f1b From 6c7526c95b3fbd502dc8105a67fd38da793caa4e Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 27 May 2012 13:51:27 +0700 Subject: Continuation for Security and Table code-coverage, add coverage report to travis --- tests/mocks/autoloader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 92c9bea59..441c88944 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -22,7 +22,7 @@ function autoload($class) ); $ci_libraries = array( - 'Calendar', 'Cart', 'Driver', + 'Calendar', 'Cart', 'Driver_Library', 'Email', 'Encrypt', 'Form_validation', 'Ftp', 'Image_lib', 'Javascript', 'Log', 'Migration', 'Pagination', @@ -50,7 +50,7 @@ function autoload($class) elseif (in_array($subclass, $ci_libraries)) { $dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR; - $class = $subclass; + $class = ($subclass == 'Driver_Library') ? 'Driver' : $subclass; } elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3) { -- cgit v1.2.3-24-g4f1b From b2e10b7de0d8979ce19fed5859e696904e2923dd Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 27 May 2012 15:31:53 +0700 Subject: Adding more flexibilities to mock-common --- tests/mocks/core/common.php | 167 +++++++++++++++++++++++++++----------------- 1 file changed, 103 insertions(+), 64 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index fc94d7fff..e74576626 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -2,53 +2,65 @@ // Set up the global CI functions in their most minimal core representation -function &get_instance() +if ( ! function_exists('get_instance')) { - $test = CI_TestCase::instance(); - $instance = $test->ci_instance(); - return $instance; + function &get_instance() + { + $test = CI_TestCase::instance(); + $instance = $test->ci_instance(); + return $instance; + } } // -------------------------------------------------------------------- -function &get_config() { - $test = CI_TestCase::instance(); - $config = $test->ci_get_config(); - - return $config; +if ( ! function_exists('get_config')) +{ + function &get_config() { + $test = CI_TestCase::instance(); + $config = $test->ci_get_config(); + + return $config; + } } -function config_item($item) +if ( ! function_exists('config_item')) { - $config =& get_config(); - - if ( ! isset($config[$item])) + function config_item($item) { - return FALSE; + $config =& get_config(); + + if ( ! isset($config[$item])) + { + return FALSE; + } + + return $config[$item]; } - - return $config[$item]; } // -------------------------------------------------------------------- -function load_class($class, $directory = 'libraries', $prefix = 'CI_') +if ( ! function_exists('load_class')) { - if ($directory != 'core' OR $prefix != 'CI_') - { - throw new Exception('Not Implemented: Non-core load_class()'); - } - - $test = CI_TestCase::instance(); - - $obj =& $test->ci_core_class($class); - - if (is_string($obj)) + function load_class($class, $directory = 'libraries', $prefix = 'CI_') { - throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.''); + if ($directory != 'core' OR $prefix != 'CI_') + { + throw new Exception('Not Implemented: Non-core load_class()'); + } + + $test = CI_TestCase::instance(); + + $obj =& $test->ci_core_class($class); + + if (is_string($obj)) + { + throw new Exception('Bad Isolation: Use ci_set_core_class to set '.$class.''); + } + + return $obj; } - - return $obj; } // This is sort of meh. Should probably be mocked up with @@ -57,76 +69,103 @@ function load_class($class, $directory = 'libraries', $prefix = 'CI_') // bootstrap testsuite. // -------------------------------------------------------------------- -function remove_invisible_characters($str, $url_encoded = TRUE) +if ( ! function_exists('remove_invisible_characters')) { - $non_displayables = array(); - - // every control character except newline (dec 10) - // carriage return (dec 13), and horizontal tab (dec 09) - - if ($url_encoded) + function remove_invisible_characters($str, $url_encoded = TRUE) { - $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 - $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 - } - - $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 + $non_displayables = array(); + + // every control character except newline (dec 10) + // carriage return (dec 13), and horizontal tab (dec 09) + + if ($url_encoded) + { + $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15 + $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31 + } + + $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127 - do - { - $str = preg_replace($non_displayables, '', $str, -1, $count); - } - while ($count); + do + { + $str = preg_replace($non_displayables, '', $str, -1, $count); + } + while ($count); - return $str; + return $str; + } } // Clean up error messages // -------------------------------------------------------------------- -function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') +if ( ! function_exists('show_error')) { - throw new RuntimeException('CI Error: '.$message); + function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') + { + throw new RuntimeException('CI Error: '.$message); + } } -function show_404($page = '', $log_error = TRUE) +if ( ! function_exists('show_404')) { - throw new RuntimeException('CI Error: 404'); + function show_404($page = '', $log_error = TRUE) + { + throw new RuntimeException('CI Error: 404'); + } } -function _exception_handler($severity, $message, $filepath, $line) +if ( ! function_exists('_exception_handler')) { - throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); + function _exception_handler($severity, $message, $filepath, $line) + { + throw new RuntimeException('CI Exception: '.$message.' | '.$filepath.' | '.$line); + } } // We assume a few things about our environment ... // -------------------------------------------------------------------- -function is_php($version = '5.0.0') +if ( ! function_exists('is_php')) { - return ! (version_compare(PHP_VERSION, $version) < 0); + function is_php($version = '5.0.0') + { + return ! (version_compare(PHP_VERSION, $version) < 0); + } } -function is_really_writable($file) +if ( ! function_exists('is_really_writable')) { - return is_writable($file); + function is_really_writable($file) + { + return is_writable($file); + } } -function is_loaded() +if ( ! function_exists('is_loaded')) { - throw new Exception('Bad Isolation: mock up environment'); + function is_loaded() + { + throw new Exception('Bad Isolation: mock up environment'); + } } -function log_message($level = 'error', $message, $php_error = FALSE) +if ( ! function_exists('log_message')) { - return TRUE; + function log_message($level = 'error', $message, $php_error = FALSE) + { + return TRUE; + } } -function set_status_header($code = 200, $text = '') +if ( ! function_exists('set_status_header')) { - return TRUE; + function set_status_header($code = 200, $text = '') + { + return TRUE; + } } // EOF \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d6d1150959c95e43d310d0bc45f8bd674ff6460c Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:12:55 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /tests --- tests/mocks/autoloader.php | 6 +++--- tests/mocks/core/common.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 441c88944..ff2196d4e 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -50,9 +50,9 @@ function autoload($class) elseif (in_array($subclass, $ci_libraries)) { $dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR; - $class = ($subclass == 'Driver_Library') ? 'Driver' : $subclass; + $class = ($subclass === 'Driver_Library') ? 'Driver' : $subclass; } - elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3) + elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) === 3) { $driver_path = BASEPATH.'database'.DIRECTORY_SEPARATOR.'drivers'.DIRECTORY_SEPARATOR; $dir = $driver_path.$m[1].DIRECTORY_SEPARATOR; @@ -77,7 +77,7 @@ function autoload($class) // If the autoload call came from `class_exists` or `file_exists`, // we skipped and return FALSE - if ($trace[2]['function'] == 'class_exists' OR $trace[2]['function'] == 'file_exists') + if ($trace[2]['function'] === 'class_exists' OR $trace[2]['function'] === 'file_exists') { return FALSE; } diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index e74576626..e1c493aa0 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -45,7 +45,7 @@ if ( ! function_exists('load_class')) { function load_class($class, $directory = 'libraries', $prefix = 'CI_') { - if ($directory != 'core' OR $prefix != 'CI_') + if ($directory !== 'core' OR $prefix !== 'CI_') { throw new Exception('Not Implemented: Non-core load_class()'); } -- cgit v1.2.3-24-g4f1b From 9d533aef135dff9dd3465f993283d6e49a9983a5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 15:56:56 +0300 Subject: Fix an SQLite3 pconnect() bug + other minor changes --- tests/mocks/database/drivers/sqlite.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mocks') diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php index 76a182cbf..15cefbf53 100644 --- a/tests/mocks/database/drivers/sqlite.php +++ b/tests/mocks/database/drivers/sqlite.php @@ -1,7 +1,7 @@ Date: Mon, 4 Jun 2012 16:39:19 +0300 Subject: Alter SQLite3's version() method and clear some spaces --- tests/mocks/autoloader.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/mocks') diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index ff2196d4e..90aabcbe6 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -7,9 +7,9 @@ // Prototype : // // $mock_table = new Mock_Libraries_Table(); // Will load ./mocks/libraries/table.php -// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php +// $mock_database_driver = new Mock_Database_Driver(); // Will load ./mocks/database/driver.php // and so on... -function autoload($class) +function autoload($class) { $dir = realpath(dirname(__FILE__)).DIRECTORY_SEPARATOR; @@ -75,13 +75,13 @@ function autoload($class) { $trace = debug_backtrace(); - // If the autoload call came from `class_exists` or `file_exists`, + // If the autoload call came from `class_exists` or `file_exists`, // we skipped and return FALSE if ($trace[2]['function'] === 'class_exists' OR $trace[2]['function'] === 'file_exists') { return FALSE; } - + throw new InvalidArgumentException("Unable to load $class."); } -- cgit v1.2.3-24-g4f1b