summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
authorftwbzhao <b.zhao1@gmail.com>2015-04-09 16:32:41 +0200
committerftwbzhao <b.zhao1@gmail.com>2015-04-09 16:32:41 +0200
commitb587698dd45396b91106bd7c894a79747b1fb7a9 (patch)
tree76a1d614976dd0b695e513a40f9235e3b9f7f82c /tests/codeigniter/core
parent9b9a06c9635cd3b4fce0aebe4d2eead4809999a5 (diff)
parentfd363f224d7886eb686434d7a835eaa49183d8e6 (diff)
Merge branch 'develop' of https://github.com/bcit-ci/CodeIgniter into develop
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Lang_test.php26
-rw-r--r--tests/codeigniter/core/Loader_test.php49
2 files changed, 73 insertions, 2 deletions
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
index 929bc2ffd..d2dd7598a 100644
--- a/tests/codeigniter/core/Lang_test.php
+++ b/tests/codeigniter/core/Lang_test.php
@@ -49,6 +49,32 @@ class Lang_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_multiple_file_load()
+ {
+ // Multiple files
+ $this->ci_vfs_clone('system/language/english/profiler_lang.php');
+ $files = array(
+ 0 => 'profiler',
+ 1 => 'nonexistent'
+ );
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Unable to load the requested language file: language/english/nonexistent_lang.php'
+ );
+ $this->lang->load($files, 'english');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_alternative_path_load()
+ {
+ // Alternative Path
+ $this->ci_vfs_clone('system/language/english/profiler_lang.php');
+ $this->assertTrue($this->lang->load('profiler', 'english', FALSE, TRUE, 'vfs://system/'));
+ }
+
+ // --------------------------------------------------------------------
+
/**
* @depends test_load
*/
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 9e2092e05..cfaf6c74b 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);
@@ -35,6 +38,13 @@ class Loader_test extends CI_TestCase {
$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, ' '));
@@ -319,6 +329,24 @@ class Loader_test extends CI_TestCase {
// --------------------------------------------------------------------
+ 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));
+ }
+
+ // --------------------------------------------------------------------
+
public function test_helper()
{
// Create helper in VFS
@@ -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';
@@ -511,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
+}