From 7df6771e33c43b86a9e0bb8beb9d55aafec3b978 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Sun, 29 Mar 2015 16:27:06 -0400 Subject: Improved unit test code coverage. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'tests/codeigniter/core/Loader_test.php') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9e2092e05..64632c056 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -22,6 +22,9 @@ class Loader_test extends CI_TestCase { public function test_library() { + // Test getting CI_Loader object + $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -34,6 +37,13 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); + + // Create library in VFS + $lib = Array('unit_test_lib'=>'unit_test_lib'); + + // Test loading as an array (int). + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); + $this->assertTrue(class_exists($class), $class.' does not exist'); // Test a string given to params $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' ')); @@ -316,6 +326,24 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } + + // -------------------------------------------------------------------- + + public function test_clear_vars() + { + $key1 = 'foo'; + $val1 = 'bar'; + $key2 = 'boo'; + $val2 = 'hoo'; + $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1))); + $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); + $this->assertEquals($val1, $this->load->get_var($key1)); + $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); + + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); + $this->assertEquals('', $this->load->get_var($key1)); + $this->assertEquals('', $this->load->get_var($key2)); + } // -------------------------------------------------------------------- @@ -443,6 +471,24 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_remove_package_path() + { + $dir = 'third-party'; + $path = APPPATH.$dir.'/'; + $path2 = APPPATH.'another/'; + $paths = $this->load->get_package_paths(TRUE); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); + $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); + + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); + $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); + } + + // -------------------------------------------------------------------- + public function test_load_config() { $cfg = 'someconfig'; -- cgit v1.2.3-24-g4f1b From aa11370ba3d326eef259fedd5a67481b3aa95df6 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 10:05:47 -0400 Subject: added spaces Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core/Loader_test.php') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 64632c056..6028521d1 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib'=>'unit_test_lib'); + $lib = Array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From 90e07bdaa034d98e23378c51105a8aea85878d07 Mon Sep 17 00:00:00 2001 From: Heesung Ahn Date: Mon, 30 Mar 2015 12:10:00 -0400 Subject: changed to lowercase array. Signed-off-by:Heesung Ahn --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core/Loader_test.php') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 6028521d1..5e64b62b9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -39,7 +39,7 @@ class Loader_test extends CI_TestCase { $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); // Create library in VFS - $lib = Array('unit_test_lib' => 'unit_test_lib'); + $lib = array('unit_test_lib' => 'unit_test_lib'); // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); -- cgit v1.2.3-24-g4f1b From 928134324d75ed4a876237ec00d4374b2213586a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 30 Mar 2015 19:27:06 +0300 Subject: [ci skip] Whitespace cleanup following PRs #3713 #3714 --- tests/codeigniter/core/Loader_test.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'tests/codeigniter/core/Loader_test.php') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 5e64b62b9..cfaf6c74b 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -24,7 +24,7 @@ class Loader_test extends CI_TestCase { { // Test getting CI_Loader object $this->assertInstanceOf('CI_Loader', $this->load->library(NULL)); - + // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); @@ -37,10 +37,10 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj); - + // Create library in VFS $lib = array('unit_test_lib' => 'unit_test_lib'); - + // Test loading as an array (int). $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertTrue(class_exists($class), $class.' does not exist'); @@ -326,7 +326,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); } - + // -------------------------------------------------------------------- public function test_clear_vars() @@ -339,7 +339,7 @@ class Loader_test extends CI_TestCase { $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2)); $this->assertEquals($val1, $this->load->get_var($key1)); $this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars()); - + $this->assertInstanceOf('CI_Loader', $this->load->clear_vars()); $this->assertEquals('', $this->load->get_var($key1)); $this->assertEquals('', $this->load->get_var($key2)); @@ -477,18 +477,18 @@ class Loader_test extends CI_TestCase { $path = APPPATH.$dir.'/'; $path2 = APPPATH.'another/'; $paths = $this->load->get_package_paths(TRUE); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); - + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); } // -------------------------------------------------------------------- - + public function test_load_config() { $cfg = 'someconfig'; @@ -557,5 +557,4 @@ class Loader_test extends CI_TestCase { // Verify config calls $this->assertEquals($cfg['config'], $this->ci_obj->config->loaded); } - -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b