diff options
Diffstat (limited to 'tests/codeigniter/core/Loader_test.php')
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 70 |
1 files changed, 32 insertions, 38 deletions
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9ad3ca6b9..93ca5b223 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -31,15 +31,12 @@ class Loader_test extends CI_TestCase { $this->assertFalse($this->load->is_loaded(ucfirst($lib))); // Test loading as an array. - $this->assertNull($this->load->library(array($lib))); + $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); - // Test no lib given - $this->assertNull($this->load->library()); - // Test a string given to params - $this->assertNull($this->load->library($lib, ' ')); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' ')); // Create library w/o class $lib = 'bad_test_lib'; @@ -50,7 +47,7 @@ class Loader_test extends CI_TestCase { 'RuntimeException', 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); } // -------------------------------------------------------------------- @@ -66,7 +63,7 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create($ext, '<?php class '.$ext.' extends '.$class.' { }', $this->ci_app_root, 'libraries'); // Test loading with extension - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertTrue(class_exists($ext), $ext.' does not exist'); $this->assertAttributeInstanceOf($class, $name, $this->ci_obj); @@ -74,13 +71,13 @@ class Loader_test extends CI_TestCase { // Test reloading with object name $obj = 'exttest'; - $this->assertNull($this->load->library($lib, NULL, $obj)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj)); $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj); $this->assertAttributeInstanceOf($ext, $obj, $this->ci_obj); // Test reloading unset($this->ci_obj->$name); - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertObjectNotHasAttribute($name, $this->ci_obj); // Create baseless library @@ -94,7 +91,7 @@ class Loader_test extends CI_TestCase { 'RuntimeException', 'CI Error: Unable to load the requested class: '.$lib ); - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); } // -------------------------------------------------------------------- @@ -117,7 +114,7 @@ class Loader_test extends CI_TestCase { // Test object name and config $obj = 'testy'; - $this->assertNull($this->load->library($lib, NULL, $obj)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj)); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj); $this->assertEquals($cfg, $this->ci_obj->$obj->config); @@ -136,7 +133,7 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries'); // Load library - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); // Was the model class instantiated. $this->assertTrue(class_exists($class), $class.' does not exist'); @@ -158,20 +155,17 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir); // Test loading as an array. - $this->assertNull($this->load->driver(array($driver))); + $this->assertInstanceOf('CI_Loader', $this->load->driver(array($driver))); $this->assertTrue(class_exists($class), $class.' does not exist'); $this->assertAttributeInstanceOf($class, $driver, $this->ci_obj); // Test loading as a library with a name $obj = 'testdrive'; - $this->assertNull($this->load->library($driver, NULL, $obj)); + $this->assertInstanceOf('CI_Loader', $this->load->library($driver, NULL, $obj)); $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj); - // Test no driver given - $this->assertFalse($this->load->driver()); - // Test a string given to params - $this->assertNull($this->load->driver($driver, ' ')); + $this->assertInstanceOf('CI_Loader', $this->load->driver($driver, ' ')); } // -------------------------------------------------------------------- @@ -186,14 +180,14 @@ class Loader_test extends CI_TestCase { $this->ci_vfs_create($model, $content, $this->ci_app_root, 'models'); // Load model - $this->assertNull($this->load->model($model)); + $this->assertInstanceOf('CI_Loader', $this->load->model($model)); // Was the model class instantiated. $this->assertTrue(class_exists($model)); $this->assertObjectHasAttribute($model, $this->ci_obj); // Test no model given - $this->assertNull($this->load->model('')); + $this->assertInstanceOf('CI_Loader', $this->load->model('')); } // -------------------------------------------------------------------- @@ -212,7 +206,7 @@ class Loader_test extends CI_TestCase { // Load model $name = 'testors'; - $this->assertNull($this->load->model($subdir.'/'.$model, $name)); + $this->assertInstanceOf('CI_Loader', $this->load->model($subdir.'/'.$model, $name)); // Was the model class instantiated? $this->assertTrue(class_exists($model)); @@ -246,8 +240,8 @@ class Loader_test extends CI_TestCase { // public function testDatabase() // { - // $this->assertNull($this->load->database()); - // $this->assertNull($this->load->dbutil()); + // $this->assertInstanceOf('CI_Loader', $this->load->database()); + // $this->assertInstanceOf('CI_Loader', $this->load->dbutil()); // } // -------------------------------------------------------------------- @@ -271,7 +265,7 @@ class Loader_test extends CI_TestCase { $this->ci_instance_var('output', $output); // Test view output - $this->assertNull($this->load->view($view, array($var => $value))); + $this->assertInstanceOf('CI_Loader', $this->load->view($view, array($var => $value))); } // -------------------------------------------------------------------- @@ -317,8 +311,8 @@ class Loader_test extends CI_TestCase { $val1 = 'bar'; $key2 = 'boo'; $val2 = 'hoo'; - $this->assertNull($this->load->vars(array($key1 => $val1))); - $this->assertNull($this->load->vars($key2, $val2)); + $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()); } @@ -330,16 +324,16 @@ class Loader_test extends CI_TestCase { // Create helper in VFS $helper = 'test'; $func = '_my_helper_test_func'; - $content = '<?php function '.$func.'() { return true; } '; + $content = '<?php function '.$func.'() { return TRUE; } '; $this->ci_vfs_create($helper.'_helper', $content, $this->ci_base_root, 'helpers'); // Create helper extension $exfunc = '_my_extension_func'; - $content = '<?php function '.$exfunc.'() { return true; } '; + $content = '<?php function '.$exfunc.'() { return TRUE; } '; $this->ci_vfs_create($this->prefix.$helper.'_helper', $content, $this->ci_app_root, 'helpers'); // Load helper - $this->assertNull($this->load->helper($helper)); + $this->assertInstanceOf('CI_Loader', $this->load->helper($helper)); $this->assertTrue(function_exists($func), $func.' does not exist'); $this->assertTrue(function_exists($exfunc), $exfunc.' does not exist'); @@ -379,12 +373,12 @@ class Loader_test extends CI_TestCase { $helpers[] = $helper; $func = '_my_helper_test_func'.$i; $funcs[] = $func; - $files[$helper.'_helper'] = '<?php function '.$func.'() { return true; } '; + $files[$helper.'_helper'] = '<?php function '.$func.'() { return TRUE; } '; } $this->ci_vfs_create($files, NULL, $this->ci_base_root, 'helpers'); // Load helpers - $this->assertNull($this->load->helpers($helpers)); + $this->assertInstanceOf('CI_Loader', $this->load->helpers($helpers)); // Verify helper existence foreach ($funcs as $func) { @@ -401,7 +395,7 @@ class Loader_test extends CI_TestCase { $lang = $this->getMock('CI_Lang', array('load')); $lang->expects($this->once())->method('load')->with($file); $this->ci_instance_var('lang', $lang); - $this->assertNull($this->load->language($file)); + $this->assertInstanceOf('CI_Loader', $this->load->language($file)); } // -------------------------------------------------------------------- @@ -419,24 +413,24 @@ class Loader_test extends CI_TestCase { // Add path and verify $path = APPPATH.$dir.'/'; - $this->assertNull($this->load->add_package_path($path)); + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); $this->assertContains($path, $this->load->get_package_paths(TRUE)); // Test successful load - $this->assertNull($this->load->library($lib)); + $this->assertInstanceOf('CI_Loader', $this->load->library($lib)); $this->assertTrue(class_exists($class), $class.' does not exist'); // Add another path $path2 = APPPATH.'another/'; - $this->assertNull($this->load->add_package_path($path2)); + $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2)); $this->assertContains($path2, $this->load->get_package_paths(TRUE)); // Remove last path - $this->assertNull($this->load->remove_package_path()); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path()); $this->assertNotContains($path2, $this->load->get_package_paths(TRUE)); // Remove path and verify restored paths - $this->assertNull($this->load->remove_package_path($path)); + $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); // Test failed load without path @@ -463,7 +457,7 @@ class Loader_test extends CI_TestCase { // Create helper in VFS $helper = 'autohelp'; $hlp_func = '_autohelp_test_func'; - $content = '<?php function '.$hlp_func.'() { return true; }'; + $content = '<?php function '.$hlp_func.'() { return TRUE; }'; $this->ci_vfs_create($helper.'_helper', $content, $this->ci_app_root, 'helpers'); // Create library in VFS |