diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Benchmark_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/core/Config_test.php | 10 | ||||
-rw-r--r-- | tests/codeigniter/core/Input_test.php | 12 | ||||
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 32 | ||||
-rw-r--r-- | tests/codeigniter/core/Security_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/helpers/directory_helper_test.php | 19 | ||||
-rw-r--r-- | tests/mocks/core/common.php | 2 | ||||
-rw-r--r-- | tests/mocks/database/db.php | 2 |
8 files changed, 50 insertions, 31 deletions
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php index a239ba51d..aff736a40 100644 --- a/tests/codeigniter/core/Benchmark_test.php +++ b/tests/codeigniter/core/Benchmark_test.php @@ -30,7 +30,7 @@ class Benchmark_test extends CI_TestCase { sleep(1); $this->benchmark->mark('code_end'); - $this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1)); + $this->assertEquals('1', $this->benchmark->elapsed_time('code_start', 'code_end', 0)); } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index e3be8a3fc..ba9a2c070 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -24,18 +24,18 @@ class Config_test extends CI_TestCase { $this->assertEquals($this->cfg['base_url'], $this->config->item('base_url')); // Bad Config value - $this->assertFalse($this->config->item('no_good_item')); + $this->assertNull($this->config->item('no_good_item')); // Index - $this->assertFalse($this->config->item('no_good_item', 'bad_index')); - $this->assertFalse($this->config->item('no_good_item', 'default')); + $this->assertNull($this->config->item('no_good_item', 'bad_index')); + $this->assertNull($this->config->item('no_good_item', 'default')); } // -------------------------------------------------------------------- public function test_set_item() { - $this->assertFalse($this->config->item('not_yet_set')); + $this->assertNull($this->config->item('not_yet_set')); $this->config->set_item('not_yet_set', 'is set'); $this->assertEquals('is set', $this->config->item('not_yet_set')); @@ -46,7 +46,7 @@ class Config_test extends CI_TestCase { public function test_slash_item() { // Bad Config value - $this->assertFalse($this->config->slash_item('no_good_item')); + $this->assertNull($this->config->slash_item('no_good_item')); $this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url')); $this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix')); diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index 5cf25fefa..0a98e556c 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -82,11 +82,21 @@ class Input_test extends CI_TestCase { // -------------------------------------------------------------------- - public function test_get_post() + public function test_post_get() { $_SERVER['REQUEST_METHOD'] = 'POST'; $_POST['foo'] = 'bar'; + $this->assertEquals('bar', $this->input->post_get('foo')); + } + + // -------------------------------------------------------------------- + + public function test_get_post() + { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $_GET['foo'] = 'bar'; + $this->assertEquals('bar', $this->input->get_post('foo')); } diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index ac2656e75..9ad3ca6b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -28,7 +28,7 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries'); // Test is_loaded fail - $this->assertFalse($this->load->is_loaded($lib)); + $this->assertFalse($this->load->is_loaded(ucfirst($lib))); // Test loading as an array. $this->assertNull($this->load->library(array($lib))); @@ -123,7 +123,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($cfg, $this->ci_obj->$obj->config); // Test is_loaded - $this->assertEquals($obj, $this->load->is_loaded($lib)); + $this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib))); } // -------------------------------------------------------------------- @@ -181,16 +181,16 @@ class Loader_test extends CI_TestCase { $this->ci_set_core_class('model', 'CI_Model'); // Create model in VFS - $model = 'unit_test_model'; - $class = ucfirst($model); - $content = '<?php class '.$class.' extends CI_Model {} '; + $model = 'Unit_test_model'; + $content = '<?php class '.$model.' extends CI_Model {} '; $this->ci_vfs_create($model, $content, $this->ci_app_root, 'models'); // Load model $this->assertNull($this->load->model($model)); // Was the model class instantiated. - $this->assertTrue(class_exists($class)); + $this->assertTrue(class_exists($model)); + $this->assertObjectHasAttribute($model, $this->ci_obj); // Test no model given $this->assertNull($this->load->model('')); @@ -204,11 +204,10 @@ class Loader_test extends CI_TestCase { $this->ci_core_class('model'); // Create modelin VFS - $model = 'test_sub_model'; + $model = 'Test_sub_model'; $base = 'CI_Model'; - $class = ucfirst($model); $subdir = 'cars'; - $this->ci_vfs_create($model, '<?php class '.$class.' extends '.$base.' { }', $this->ci_app_root, + $this->ci_vfs_create($model, '<?php class '.$model.' extends '.$base.' { }', $this->ci_app_root, array('models', $subdir)); // Load model @@ -216,10 +215,10 @@ class Loader_test extends CI_TestCase { $this->assertNull($this->load->model($subdir.'/'.$model, $name)); // Was the model class instantiated? - $this->assertTrue(class_exists($class)); + $this->assertTrue(class_exists($model)); $this->assertObjectHasAttribute($name, $this->ci_obj); $this->assertAttributeInstanceOf($base, $name, $this->ci_obj); - $this->assertAttributeInstanceOf($class, $name, $this->ci_obj); + $this->assertAttributeInstanceOf($model, $name, $this->ci_obj); // Test name conflict $obj = 'conflict'; @@ -237,7 +236,7 @@ class Loader_test extends CI_TestCase { { $this->setExpectedException( 'RuntimeException', - 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php' + 'CI Error: Unable to locate the model you have specified: Ci_test_nonexistent_model.php' ); $this->load->model('ci_test_nonexistent_model.php'); @@ -481,9 +480,8 @@ class Loader_test extends CI_TestCase { // Create model in VFS package path $dir = 'testdir'; $path = APPPATH.$dir.'/'; - $model = 'automod'; - $mod_class = ucfirst($model); - $this->ci_vfs_create($model, '<?php class '.$mod_class.' { }', $this->ci_app_root, array($dir, 'models')); + $model = 'Automod'; + $this->ci_vfs_create($model, '<?php class '.$model.' { }', $this->ci_app_root, array($dir, 'models')); // Create autoloader config $cfg = array( @@ -513,8 +511,8 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($drv_class, $drv, $this->ci_obj); // Verify model - $this->assertTrue(class_exists($mod_class), $mod_class.' does not exist'); - $this->assertAttributeInstanceOf($mod_class, $model, $this->ci_obj); + $this->assertTrue(class_exists($model), $model.' does not exist'); + $this->assertAttributeInstanceOf($model, $model, $this->ci_obj); // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 3f6e3b07a..433ad313f 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -5,7 +5,7 @@ class Security_test extends CI_TestCase { public function set_up() { // Set cookie for security test - $_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE)); + $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE)); // Set config for Security class $this->ci_set_config('csrf_protection', TRUE); diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index 41370e6e7..de72dee78 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -14,6 +14,8 @@ class Directory_helper_test extends CI_TestCase { public function test_directory_map() { + $ds = DIRECTORY_SEPARATOR; + $structure = array( 'libraries' => array( 'benchmark.html' => '', @@ -26,11 +28,18 @@ class Directory_helper_test extends CI_TestCase { vfsStream::create($structure, $this->_test_dir); + // is_dir(), opendir(), etc. seem to fail on Windows + vfsStream when there are trailing backslashes in directory names + if ( ! is_dir(vfsStream::url('testDir').DIRECTORY_SEPARATOR)) + { + $this->markTestSkipped(); + return; + } + // test default recursive behavior $expected = array( - 'libraries/' => array( + 'libraries'.$ds => array( 'benchmark.html', - 'database/' => array('active_record.html', 'binds.html'), + 'database'.$ds => array('active_record.html', 'binds.html'), 'email.html', '0' ) @@ -39,12 +48,12 @@ class Directory_helper_test extends CI_TestCase { $this->assertEquals($expected, directory_map(vfsStream::url('testDir'))); // test detection of hidden files - $expected['libraries/'][] = '.hiddenfile.txt'; + $expected['libraries'.$ds][] = '.hiddenfile.txt'; - $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), FALSE, TRUE)); + $this->assertEquals($expected, directory_map(vfsStream::url('testDir'), 0, TRUE)); // test recursion depth behavior - $this->assertEquals(array('libraries/'), directory_map(vfsStream::url('testDir'), 1)); + $this->assertEquals(array('libraries'.$ds), directory_map(vfsStream::url('testDir'), 1)); } } diff --git a/tests/mocks/core/common.php b/tests/mocks/core/common.php index 0ccfe1ea4..e5dc29c86 100644 --- a/tests/mocks/core/common.php +++ b/tests/mocks/core/common.php @@ -178,7 +178,7 @@ if ( ! function_exists('is_loaded')) if ( ! function_exists('log_message')) { - function log_message($level, $message, $php_error = FALSE) + function log_message($level, $message) { return TRUE; } diff --git a/tests/mocks/database/db.php b/tests/mocks/database/db.php index 7e0030e15..968476dea 100644 --- a/tests/mocks/database/db.php +++ b/tests/mocks/database/db.php @@ -106,6 +106,7 @@ class Mock_Database_DB { $subdriver = self::$subdriver; $case->ci_vfs_create(array( 'DB_driver.php' => '', + 'DB_result.php' => '', 'DB_forge.php' => '', 'DB_query_builder.php' => '' ), '', $case->ci_base_root, 'database'); @@ -113,6 +114,7 @@ class Mock_Database_DB { { $case->ci_vfs_create(array( $driver.'_driver.php' => '', + $driver.'_result.php' => '', $driver.'_forge.php' => '' ), '', $case->ci_base_root, 'database/drivers/'.$driver); } |