summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-07 12:36:50 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-07 12:36:50 +0100
commit61a7b8f4b38bbca520c43ac100899449f73bf408 (patch)
tree74643a65efb6978659d6f614f82b8d77a019551b /tests/codeigniter/core
parent1bbc5644b0c306ff72dc1228b169db56902fc031 (diff)
Implement Loader method chaining
Requested in issue #2165 Supersedes PR #2319
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Loader_test.php56
1 files changed, 28 insertions, 28 deletions
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 8fbeaec7b..799bcd967 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -31,12 +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 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';
@@ -47,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));
}
// --------------------------------------------------------------------
@@ -63,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);
@@ -71,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
@@ -91,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));
}
// --------------------------------------------------------------------
@@ -114,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);
@@ -133,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');
@@ -155,17 +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 a string given to params
- $this->assertNull($this->load->driver($driver, ' '));
+ $this->assertInstanceOf('CI_Loader', $this->load->driver($driver, ' '));
}
// --------------------------------------------------------------------
@@ -180,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(''));
}
// --------------------------------------------------------------------
@@ -206,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));
@@ -240,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());
// }
// --------------------------------------------------------------------
@@ -265,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)));
}
// --------------------------------------------------------------------
@@ -311,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());
}
@@ -333,7 +333,7 @@ class Loader_test extends CI_TestCase {
$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');
@@ -378,7 +378,7 @@ class Loader_test extends CI_TestCase {
$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) {
@@ -395,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));
}
// --------------------------------------------------------------------
@@ -413,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