summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2015-11-09 11:55:07 +0100
committerAndrey Andreev <narf@devilix.net>2015-11-09 11:55:07 +0100
commitf1c531e2b01a0a8c42e27655591c3aac01d9a846 (patch)
tree1b7e4d4ce8ad1371f2b2daa7f41865f32eb9c1e6 /tests/codeigniter/core
parentcd4e547abbe9e5f4d48bd54d7fc136a01033b480 (diff)
parentb880069aa8521291ebedc57d5c229bc6f72e0426 (diff)
Merge pull request #4225 from zhanghongyi/loader-test
Improve Loader test cases for libraries
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Loader_test.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 889ab92e4..db5088d80 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -48,11 +48,9 @@ class Loader_test extends CI_TestCase {
// Test a string given to params
$this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
- // Create library w/o class
- $lib = 'bad_test_lib';
- $this->ci_vfs_create($lib, '', $this->ci_base_root, 'libraries');
+ // test non existent lib
+ $lib = 'non_existent_test_lib';
- // Test non-existent class
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested class: '.ucfirst($lib)
@@ -62,6 +60,19 @@ class Loader_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_bad_library()
+ {
+ $lib = 'bad_test_lib';
+ $this->ci_vfs_create(ucfirst($lib), '', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Non-existent class: '.ucfirst($lib)
+ );
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
+ }
+
+ // --------------------------------------------------------------------
+
public function test_library_extension()
{
// Create library and extension in VFS
@@ -131,6 +142,16 @@ class Loader_test extends CI_TestCase {
// Test is_loaded
$this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
+
+ // Test to load another class with the same object name
+ $lib = 'another_test_lib';
+ $class = ucfirst($lib);
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ "CI Error: Resource '".$obj."' already exists and is not a ".$class." instance."
+ );
+ $this->load->library($lib, NULL, $obj);
}
// --------------------------------------------------------------------