From 6030719346e9b0eb0e0ea99c679cadeb1fe4afde Mon Sep 17 00:00:00 2001 From: dchill42 Date: Mon, 27 Aug 2012 23:59:31 -0400 Subject: Improved VFS usage in Loader and Config units, added Loader driver test, and moved config load testing to Config unit Signed-off-by: dchill42 --- tests/codeigniter/core/Config_test.php | 52 +++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'tests/codeigniter/core/Config_test.php') diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 30cb90a28..7782a7898 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -90,4 +90,54 @@ class Config_test extends CI_TestCase { $this->assertEquals('http://example.com/system/', $this->config->system_url()); } -} \ No newline at end of file + // -------------------------------------------------------------------- + + public function test_load() + { + // Create VFS tree of application config files + $file1 = 'test.php'; + $file2 = 'secttest'; + $key1 = 'testconfig'; + $val1 = 'my_value'; + $cfg1 = array( + $key1 => $val1 + ); + $cfg2 = array( + 'one' => 'prime', + 'two' => 2, + 'three' => true + ); + $tree = array( + 'application' => array( + 'config' => array( + $file1 => ' 'config->_config_paths = array(vfsStream::url('application').'/'); + + // Test regular load + $this->assertTrue($this->config->load($file1)); + $this->assertEquals($val1, $this->config->item($key1)); + + // Test section load + $this->assertTrue($this->config->load($file2, TRUE)); + $this->assertEquals($cfg2, $this->config->item($file2)); + + // Test graceful fail + $this->assertFalse($this->config->load('not_config_file', FALSE, TRUE)); + + // Test regular fail + $file3 = 'absentia'; + $this->setExpectedException( + 'RuntimeException', + 'CI Error: The configuration file '.$file3.'.php does not exist.' + ); + $this->assertNull($this->config->load($file3)); + } + +} -- cgit v1.2.3-24-g4f1b