From 69c97a71476e4eaa6c629022fcd4ec7f36d4ec0d Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Wed, 20 Apr 2011 21:44:54 -0400 Subject: Adding early bootstrap ideas for core test suite --- tests/codeigniter/core/Config_test.php | 107 ++++++++++++++++++++++++ tests/codeigniter/core/Lang_test.php | 31 +++++++ tests/codeigniter/core/Loader_test.php | 144 +++++++++++++++++++++++++++++++++ 3 files changed, 282 insertions(+) create mode 100644 tests/codeigniter/core/Config_test.php create mode 100644 tests/codeigniter/core/Lang_test.php create mode 100644 tests/codeigniter/core/Loader_test.php (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php new file mode 100644 index 000000000..628fc630b --- /dev/null +++ b/tests/codeigniter/core/Config_test.php @@ -0,0 +1,107 @@ +ci_core_class('cfg'); + + $stub = $this->getMock($cls, NULL, array(), '', FALSE); + + //I would prefer this, but it currently + // does not work as when you try to pass + // null to setMethods it fails on an internal + // function call that expects an array =( + /* + $stub = $this->getMockBuilder($cls) + ->disableOriginalConstructor() + ->setMethods(null) + ->getMock(); + */ + + + // set predictable config values + $stub->config = array( + 'index_page' => 'index.php', + 'base_url' => 'http://example.com/', + 'subclass_prefix' => 'MY_' + ); + + $this->config = $stub; + } + + // -------------------------------------------------------------------- + + public function testItem() + { + $this->assertEquals('http://example.com/', $this->config->item('base_url')); + + // Bad Config value + $this->assertFalse($this->config->item('no_good_item')); + + // Index + $this->assertFalse($this->config->item('no_good_item', 'bad_index')); + $this->assertFalse($this->config->item('no_good_item', 'default')); + } + + // -------------------------------------------------------------------- + + public function testSetItem() + { + $this->assertFalse($this->config->item('not_yet_set')); + + $this->config->set_item('not_yet_set', 'is set'); + + $this->assertEquals('is set', $this->config->item('not_yet_set')); + } + + // -------------------------------------------------------------------- + + public function testSlashItem() + { + // Bad Config value + $this->assertFalse($this->config->slash_item('no_good_item')); + + $this->assertEquals('http://example.com/', $this->config->slash_item('base_url')); + + $this->assertEquals('MY_/', $this->config->slash_item('subclass_prefix')); + } + + // -------------------------------------------------------------------- + + public function testSiteUrl() + { + $this->assertEquals('http://example.com/index.php', $this->config->site_url()); + + $base_url = $this->config->item('base_url'); + + $this->config->set_item('base_url', ''); + + $q_string = $this->config->item('enable_query_strings'); + + $this->config->set_item('enable_query_strings', FALSE); + + $this->assertEquals('/index.php/test', $this->config->site_url('test')); + $this->assertEquals('/index.php/test/1', $this->config->site_url(array('test', '1'))); + + $this->config->set_item('enable_query_strings', TRUE); + + $this->assertEquals('/index.php?test', $this->config->site_url('test')); + $this->assertEquals('/index.php?0=test&1=1', $this->config->site_url(array('test', '1'))); + + $this->config->set_item('base_url', $base_url); + + $this->assertEquals('http://example.com/index.php?test', $this->config->site_url('test')); + + // back to home base + $this->config->set_item('enable_query_strings', $q_string); + } + + // -------------------------------------------------------------------- + + public function testSystemUrl() + { + $this->assertEquals('http://example.com/system/', $this->config->system_url()); + } + +} \ No newline at end of file diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php new file mode 100644 index 000000000..82e279a52 --- /dev/null +++ b/tests/codeigniter/core/Lang_test.php @@ -0,0 +1,31 @@ +ci_core_class('lang'); + $this->lang = new $cls; + } + + // -------------------------------------------------------------------- + + public function testLoad() + { + // get_config needs work + $this->markTestIncomplete('get_config needs work'); + //$this->assertTrue($this->lang->load('profiler')); + } + + // -------------------------------------------------------------------- + + public function testLine() + { + $this->markTestIncomplete('get_config needs work'); + + $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string')); + } + +} \ No newline at end of file diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php new file mode 100644 index 000000000..fd9c63216 --- /dev/null +++ b/tests/codeigniter/core/Loader_test.php @@ -0,0 +1,144 @@ +ci_core_class('load'); + $this->_loader = new $cls; + + // mock up a ci instance + $this->ci_obj = new StdClass; + + // Fix get_instance() + CodeIgniterTestCase::$test_instance =& $this; + $this->ci_instance($this->ci_obj); + } + + // -------------------------------------------------------------------- + + public function testLibrary() + { + // Mock up a config object until we + // figure out how to test the library configs + $config = $this->getMock('CI_Config', NULL, array(), '', FALSE); + $config->expects($this->any()) + ->method('load') + ->will($this->returnValue(TRUE)); + + // Add the mock to our stdClass + $this->ci_set_instance_var('config', $config); + + // Test loading as an array. + $this->assertEquals(NULL, $this->_loader->library(array('table'))); + $this->assertTrue(class_exists('CI_Table'), 'Table class exists'); + $this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj); + + // Test no lib given + $this->assertEquals(FALSE, $this->_loader->library()); + + // Test a string given to params + $this->assertEquals(NULL, $this->_loader->library('table', ' ')); + } + + // -------------------------------------------------------------------- + + public function testModels() + { + // Test loading as an array. + $this->assertEquals(NULL, $this->_loader->model(array('foobar'))); + + // Test no model given + $this->assertEquals(FALSE, $this->_loader->model('')); + + // Test a string given to params + $this->assertEquals(NULL, $this->_loader->model('foobar', ' ')); + } + + // -------------------------------------------------------------------- + + public function testDatabase() + { + $this->assertEquals(NULL, $this->_loader->database()); + $this->assertEquals(NULL, $this->_loader->dbutil()); + } + + // -------------------------------------------------------------------- + + public function testView() + { + // I'm not entirely sure this is the proper way to handle this. + // So, let's revist it, m'kay? + try + { + $this->_loader->view('foo'); + } + catch (Exception $expected) + { + return; + } + } + + // -------------------------------------------------------------------- + + public function testFile() + { + // I'm not entirely sure this is the proper way to handle this. + // So, let's revist it, m'kay? + try + { + $this->_loader->file('foo'); + } + catch (Exception $expected) + { + return; + } + } + + // -------------------------------------------------------------------- + + public function testVars() + { + $vars = array( + 'foo' => 'bar' + ); + + $this->assertEquals(NULL, $this->_loader->vars($vars)); + $this->assertEquals(NULL, $this->_loader->vars('foo', 'bar')); + } + + // -------------------------------------------------------------------- + + public function testHelper() + { + $this->assertEquals(NULL, $this->_loader->helper('array')); + $this->assertEquals(NULL, $this->_loader->helper('bad')); + } + + // -------------------------------------------------------------------- + + public function testHelpers() + { + $this->assertEquals(NULL, $this->_loader->helpers(array('file', 'array', 'string'))); + } + + // -------------------------------------------------------------------- + + // public function testLanguage() + // { + // $this->assertEquals(NULL, $this->_loader->language('test')); + // } + + // -------------------------------------------------------------------- + + public function testLoadConfig() + { + $this->assertEquals(NULL, $this->_loader->config('config', FALSE, TRUE)); + } + + + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 10ba64f9b76a25a77182d72a0a09413ccba12770 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Thu, 21 Apr 2011 01:00:27 -0400 Subject: Renamed the main test class, fixing test cases. --- tests/codeigniter/core/Config_test.php | 26 ++++++-------------------- tests/codeigniter/core/Lang_test.php | 2 +- tests/codeigniter/core/Loader_test.php | 5 ++--- 3 files changed, 9 insertions(+), 24 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 628fc630b..b04dd67fa 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -1,33 +1,19 @@ ci_core_class('cfg'); - - $stub = $this->getMock($cls, NULL, array(), '', FALSE); - - //I would prefer this, but it currently - // does not work as when you try to pass - // null to setMethods it fails on an internal - // function call that expects an array =( - /* - $stub = $this->getMockBuilder($cls) - ->disableOriginalConstructor() - ->setMethods(null) - ->getMock(); - */ - - + // set predictable config values - $stub->config = array( + $this->ci_set_config(array( 'index_page' => 'index.php', 'base_url' => 'http://example.com/', 'subclass_prefix' => 'MY_' - ); - - $this->config = $stub; + )); + + $this->config = new $cls; } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index 82e279a52..f65b335b0 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -1,6 +1,6 @@ ci_obj = new StdClass; // Fix get_instance() - CodeIgniterTestCase::$test_instance =& $this; $this->ci_instance($this->ci_obj); } @@ -30,7 +29,7 @@ class Loader_test extends CodeIgniterTestCase { ->will($this->returnValue(TRUE)); // Add the mock to our stdClass - $this->ci_set_instance_var('config', $config); + $this->ci_instance_var('config', $config); // Test loading as an array. $this->assertEquals(NULL, $this->_loader->library(array('table'))); -- cgit v1.2.3-24-g4f1b From 8da69039f6d855eb4f88de73702155e6899d2d23 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 11:28:27 -0500 Subject: Working on tests in the loader. Have generic model mocking working with vfsStream. --- tests/codeigniter/core/Loader_test.php | 134 ++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 44 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index c7085c439..2aa1b8cb9 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -1,5 +1,38 @@ models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot()); + $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot()); + $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot()); + $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot()); + + $this->_ci_ob_level = ob_get_level(); + $this->_ci_library_paths = array(vfsStream::url('application').'/', BASEPATH); + $this->_ci_helper_paths = array(vfsStream::url('application').'/', BASEPATH); + $this->_ci_model_paths = array(vfsStream::url('application').'/'); + $this->_ci_view_paths = array(vfsStream::url('application').'/views/' => TRUE); + } +} + + class Loader_test extends CI_TestCase { private $ci_obj; @@ -7,8 +40,7 @@ class Loader_test extends CI_TestCase { public function setUp() { // Instantiate a new loader - $cls = $this->ci_core_class('load'); - $this->_loader = new $cls; + $this->load = new Extended_Loader(); // mock up a ci instance $this->ci_obj = new StdClass; @@ -32,53 +64,67 @@ class Loader_test extends CI_TestCase { $this->ci_instance_var('config', $config); // Test loading as an array. - $this->assertEquals(NULL, $this->_loader->library(array('table'))); + $this->assertEquals(NULL, $this->load->library(array('table'))); $this->assertTrue(class_exists('CI_Table'), 'Table class exists'); $this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj); // Test no lib given - $this->assertEquals(FALSE, $this->_loader->library()); + $this->assertEquals(FALSE, $this->load->library()); // Test a string given to params - $this->assertEquals(NULL, $this->_loader->library('table', ' ')); + $this->assertEquals(NULL, $this->load->library('table', ' ')); } // -------------------------------------------------------------------- + public function testNonExistentModel() + { + $this->setExpectedException( + 'Exception', + 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_mode.php' + ); + + $this->load->model('ci_test_nonexistent_mode.php'); + } + + // -------------------------------------------------------------------- + public function testModels() { - // Test loading as an array. - $this->assertEquals(NULL, $this->_loader->model(array('foobar'))); + $this->ci_set_core_class('model', 'CI_Model'); + + $content = 'withContent($content) + ->at($this->load->models_dir); + + $this->assertNull($this->load->model('unit_test_model')); // Test no model given - $this->assertEquals(FALSE, $this->_loader->model('')); + $this->assertEquals(FALSE, $this->load->model('')); // Test a string given to params - $this->assertEquals(NULL, $this->_loader->model('foobar', ' ')); + // $this->assertEquals(NULL, $this->load->model('foobar', ' ')); } // -------------------------------------------------------------------- - public function testDatabase() - { - $this->assertEquals(NULL, $this->_loader->database()); - $this->assertEquals(NULL, $this->_loader->dbutil()); - } + // public function testDatabase() + // { + // $this->assertEquals(NULL, $this->load->database()); + // $this->assertEquals(NULL, $this->load->dbutil()); + // } // -------------------------------------------------------------------- - public function testView() + public function testNonExistentView() { - // I'm not entirely sure this is the proper way to handle this. - // So, let's revist it, m'kay? - try - { - $this->_loader->view('foo'); - } - catch (Exception $expected) - { - return; - } + $this->setExpectedException( + 'Exception', + 'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php' + ); + + $this->load->view('ci_test_nonexistent_view', array('foo' => 'bar')); } // -------------------------------------------------------------------- @@ -86,10 +132,9 @@ class Loader_test extends CI_TestCase { public function testFile() { // I'm not entirely sure this is the proper way to handle this. - // So, let's revist it, m'kay? try { - $this->_loader->file('foo'); + $this->load->file('foo'); } catch (Exception $expected) { @@ -105,39 +150,40 @@ class Loader_test extends CI_TestCase { 'foo' => 'bar' ); - $this->assertEquals(NULL, $this->_loader->vars($vars)); - $this->assertEquals(NULL, $this->_loader->vars('foo', 'bar')); + $this->assertEquals(NULL, $this->load->vars($vars)); + $this->assertEquals(NULL, $this->load->vars('foo', 'bar')); } // -------------------------------------------------------------------- - public function testHelper() - { - $this->assertEquals(NULL, $this->_loader->helper('array')); - $this->assertEquals(NULL, $this->_loader->helper('bad')); - } + // public function testHelper() + // { + // $this->assertEquals(NULL, $this->load->helper('array')); + // $this->assertEquals(NULL, $this->load->helper('bad')); + // } // -------------------------------------------------------------------- public function testHelpers() { - $this->assertEquals(NULL, $this->_loader->helpers(array('file', 'array', 'string'))); + $this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string'))); } // -------------------------------------------------------------------- // public function testLanguage() // { - // $this->assertEquals(NULL, $this->_loader->language('test')); + // $this->assertEquals(NULL, $this->load->language('test')); // } // -------------------------------------------------------------------- - public function testLoadConfig() - { - $this->assertEquals(NULL, $this->_loader->config('config', FALSE, TRUE)); - } - - - -} \ No newline at end of file + // public function testLoadConfig() + // { + // $this->assertEquals(NULL, $this->load->config('config', FALSE, TRUE)); + // } +} + + + + -- cgit v1.2.3-24-g4f1b From 98357c5865dbec43bcb79fb114469d40cf2f5367 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 11:30:23 -0500 Subject: Swap from assertEquals(FALSE, x) to just assertFalse(). Silly Greg. --- tests/codeigniter/core/Loader_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 2aa1b8cb9..83ee68777 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -101,7 +101,7 @@ class Loader_test extends CI_TestCase { $this->assertNull($this->load->model('unit_test_model')); // Test no model given - $this->assertEquals(FALSE, $this->load->model('')); + $this->assertFalse($this->load->model('')); // Test a string given to params // $this->assertEquals(NULL, $this->load->model('foobar', ' ')); -- cgit v1.2.3-24-g4f1b From deab6ad864f05367e2c122906f63d24286b731d1 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 11:44:11 -0500 Subject: Buttoning up model loader tests. --- tests/codeigniter/core/Loader_test.php | 39 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 83ee68777..d84928eca 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -64,7 +64,7 @@ class Loader_test extends CI_TestCase { $this->ci_instance_var('config', $config); // Test loading as an array. - $this->assertEquals(NULL, $this->load->library(array('table'))); + $this->assertNull($this->load->library(array('table'))); $this->assertTrue(class_exists('CI_Table'), 'Table class exists'); $this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj); @@ -100,11 +100,11 @@ class Loader_test extends CI_TestCase { $this->assertNull($this->load->model('unit_test_model')); - // Test no model given - $this->assertFalse($this->load->model('')); + // Was the model class instantiated. + $this->assertTrue(class_exists('Unit_test_model')); - // Test a string given to params - // $this->assertEquals(NULL, $this->load->model('foobar', ' ')); + // Test no model given + $this->assertNull($this->load->model('')); } // -------------------------------------------------------------------- @@ -132,14 +132,8 @@ class Loader_test extends CI_TestCase { public function testFile() { // I'm not entirely sure this is the proper way to handle this. - try - { - $this->load->file('foo'); - } - catch (Exception $expected) - { - return; - } + // $this->load->file('foo'); + } // -------------------------------------------------------------------- @@ -156,15 +150,22 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - // public function testHelper() - // { - // $this->assertEquals(NULL, $this->load->helper('array')); - // $this->assertEquals(NULL, $this->load->helper('bad')); - // } + public function testHelper() + { + $this->assertEquals(NULL, $this->load->helper('array')); + + $this->setExpectedException( + 'Exception', + 'CI Error: Unable to load the requested file: helpers/bad_helper.php' + ); + + + $this->load->helper('bad'); + } // -------------------------------------------------------------------- - public function testHelpers() + public function testLoadingMultipleHelpers() { $this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string'))); } -- cgit v1.2.3-24-g4f1b From 321768d902f68a929a55ef9480c22cb54d40bd34 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 12:09:33 -0500 Subject: Testing view loading. --- tests/codeigniter/core/Loader_test.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index d84928eca..782751cd7 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -117,6 +117,23 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + public function testLoadView() + { + $this->ci_set_core_class('output', 'CI_Output'); + + $content = 'This is my test page. '; + $view = vfsStream::newFile('unit_test_view.php')->withContent($content) + ->at($this->load->views_dir); + + // Use the optional return parameter in this test, so the view is not + // run through the output class. + $this->assertEquals('This is my test page. World!', + $this->load->view('unit_test_view', array('hello' => "World!"), TRUE)); + + } + + // -------------------------------------------------------------------- + public function testNonExistentView() { $this->setExpectedException( -- cgit v1.2.3-24-g4f1b From 6858fb92133afa127eff6f11dd29abf554e1b2d1 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 12:27:23 -0500 Subject: Adding mock testing of libraries in the application directory --- tests/codeigniter/core/Loader_test.php | 58 +++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 12 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 782751cd7..1e32c7e0a 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -53,15 +53,7 @@ class Loader_test extends CI_TestCase { public function testLibrary() { - // Mock up a config object until we - // figure out how to test the library configs - $config = $this->getMock('CI_Config', NULL, array(), '', FALSE); - $config->expects($this->any()) - ->method('load') - ->will($this->returnValue(TRUE)); - - // Add the mock to our stdClass - $this->ci_instance_var('config', $config); + $this->_setup_config_mock(); // Test loading as an array. $this->assertNull($this->load->library(array('table'))); @@ -73,22 +65,58 @@ class Loader_test extends CI_TestCase { // Test a string given to params $this->assertEquals(NULL, $this->load->library('table', ' ')); - } + } + + // -------------------------------------------------------------------- + + public function testLoadLibraryInApplicationDir() + { + $this->_setup_config_mock(); + + $content = 'withContent($content) + ->at($this->load->libs_dir); + + $this->assertNull($this->load->library('super_test_library')); + + // Was the model class instantiated. + $this->assertTrue(class_exists('Super_test_library')); + } // -------------------------------------------------------------------- + private function _setup_config_mock() + { + // Mock up a config object until we + // figure out how to test the library configs + $config = $this->getMock('CI_Config', NULL, array(), '', FALSE); + $config->expects($this->any()) + ->method('load') + ->will($this->returnValue(TRUE)); + + // Add the mock to our stdClass + $this->ci_instance_var('config', $config); + } + + // -------------------------------------------------------------------- + + public function testNonExistentModel() { $this->setExpectedException( 'Exception', - 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_mode.php' + 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php' ); - $this->load->model('ci_test_nonexistent_mode.php'); + $this->load->model('ci_test_nonexistent_model.php'); } // -------------------------------------------------------------------- + /** + * @coverts CI_Loader::model + */ public function testModels() { $this->ci_set_core_class('model', 'CI_Model'); @@ -117,6 +145,9 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + /** + * @coverts CI_Loader::view + */ public function testLoadView() { $this->ci_set_core_class('output', 'CI_Output'); @@ -134,6 +165,9 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + /** + * @coverts CI_Loader::view + */ public function testNonExistentView() { $this->setExpectedException( -- cgit v1.2.3-24-g4f1b From 4d2bb09cbb4fc66dc4881c2ffdeee7dbaf0a3a3b Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 12:33:12 -0500 Subject: config CI_Loader tests. --- tests/codeigniter/core/Loader_test.php | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 1e32c7e0a..55ab9a4e5 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -195,8 +195,8 @@ class Loader_test extends CI_TestCase { 'foo' => 'bar' ); - $this->assertEquals(NULL, $this->load->vars($vars)); - $this->assertEquals(NULL, $this->load->vars('foo', 'bar')); + $this->assertNull($this->load->vars($vars)); + $this->assertNull($this->load->vars('foo', 'bar')); } // -------------------------------------------------------------------- @@ -230,12 +230,30 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - // public function testLoadConfig() - // { - // $this->assertEquals(NULL, $this->load->config('config', FALSE, TRUE)); - // } -} - - + public function testLoadConfig() + { + $this->_setup_config_mock(); + + $this->assertNull($this->load->config('config', FALSE)); + } + + // -------------------------------------------------------------------- + public function testLoadBadConfig() + { + $this->_setup_config_mock(); + + $this->setExpectedException( + 'Exception', + 'CI Error: The configuration file foobar.php does not exist.' + ); + + $this->load->config('foobar', FALSE); + } + // -------------------------------------------------------------------- + + + + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 56106630e172203858d58325dea5d2e81b226f87 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Thu, 21 Apr 2011 13:10:19 -0500 Subject: load->file() tests. --- tests/codeigniter/core/Loader_test.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 55ab9a4e5..49679e241 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -101,7 +101,6 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testNonExistentModel() { $this->setExpectedException( @@ -182,8 +181,22 @@ class Loader_test extends CI_TestCase { public function testFile() { - // I'm not entirely sure this is the proper way to handle this. - // $this->load->file('foo'); + $content = 'Here is a test file, which we will load now.'; + $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content) + ->at($this->load->views_dir); + + // Just like load->view(), take the output class out of the mix here. + $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php', + TRUE); + + $this->assertEquals($content, $load); + + $this->setExpectedException( + 'Exception', + 'CI Error: Unable to load the requested file: ci_test_file_not_exists' + ); + + $this->load->file('ci_test_file_not_exists', TRUE); } @@ -210,7 +223,6 @@ class Loader_test extends CI_TestCase { 'CI Error: Unable to load the requested file: helpers/bad_helper.php' ); - $this->load->helper('bad'); } -- cgit v1.2.3-24-g4f1b From 68286a4dcc1ed4d904ad992173c1b3621bf6fced Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Thu, 21 Apr 2011 22:00:33 -0400 Subject: Reworked unit tests to match rest of framework and added a few more. --- tests/codeigniter/core/Common_test.php | 16 ++++++++++++++++ tests/codeigniter/core/Config_test.php | 12 ++++++------ tests/codeigniter/core/Lang_test.php | 6 +++--- tests/codeigniter/core/Loader_test.php | 28 ++++++++++++++-------------- 4 files changed, 39 insertions(+), 23 deletions(-) create mode 100644 tests/codeigniter/core/Common_test.php (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php new file mode 100644 index 000000000..cec12982d --- /dev/null +++ b/tests/codeigniter/core/Common_test.php @@ -0,0 +1,16 @@ +assertEquals(TRUE, is_php('1.2.0')); + $this->assertEquals(FALSE, is_php('9999.9.9')); + } + +} \ No newline at end of file diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index b04dd67fa..b6c57da70 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -2,7 +2,7 @@ class Config_test extends CI_TestCase { - public function setUp() + public function set_up() { $cls =& $this->ci_core_class('cfg'); @@ -18,7 +18,7 @@ class Config_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testItem() + public function test_item() { $this->assertEquals('http://example.com/', $this->config->item('base_url')); @@ -32,7 +32,7 @@ class Config_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testSetItem() + public function test_set_item() { $this->assertFalse($this->config->item('not_yet_set')); @@ -43,7 +43,7 @@ class Config_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testSlashItem() + public function test_slash_item() { // Bad Config value $this->assertFalse($this->config->slash_item('no_good_item')); @@ -55,7 +55,7 @@ class Config_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testSiteUrl() + public function test_site_url() { $this->assertEquals('http://example.com/index.php', $this->config->site_url()); @@ -85,7 +85,7 @@ class Config_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testSystemUrl() + public function test_system_url() { $this->assertEquals('http://example.com/system/', $this->config->system_url()); } diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index f65b335b0..dcc3d0879 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -4,7 +4,7 @@ class Lang_test extends CI_TestCase { protected $lang; - public function setUp() + public function set_up() { $cls = $this->ci_core_class('lang'); $this->lang = new $cls; @@ -12,7 +12,7 @@ class Lang_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLoad() + public function test_load() { // get_config needs work $this->markTestIncomplete('get_config needs work'); @@ -21,7 +21,7 @@ class Lang_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLine() + public function test_line() { $this->markTestIncomplete('get_config needs work'); diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 49679e241..9ba870b7d 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -37,7 +37,7 @@ class Loader_test extends CI_TestCase { private $ci_obj; - public function setUp() + public function set_up() { // Instantiate a new loader $this->load = new Extended_Loader(); @@ -51,7 +51,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLibrary() + public function test_library() { $this->_setup_config_mock(); @@ -69,7 +69,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLoadLibraryInApplicationDir() + public function test_load_library_in_application_dir() { $this->_setup_config_mock(); @@ -101,7 +101,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testNonExistentModel() + public function test_non_existent_model() { $this->setExpectedException( 'Exception', @@ -116,7 +116,7 @@ class Loader_test extends CI_TestCase { /** * @coverts CI_Loader::model */ - public function testModels() + public function test_models() { $this->ci_set_core_class('model', 'CI_Model'); @@ -147,7 +147,7 @@ class Loader_test extends CI_TestCase { /** * @coverts CI_Loader::view */ - public function testLoadView() + public function test_load_view() { $this->ci_set_core_class('output', 'CI_Output'); @@ -158,7 +158,7 @@ class Loader_test extends CI_TestCase { // Use the optional return parameter in this test, so the view is not // run through the output class. $this->assertEquals('This is my test page. World!', - $this->load->view('unit_test_view', array('hello' => "World!"), TRUE)); + $this->load->view('unit_test_view', array('hello' => "World!"), TRUE)); } @@ -167,7 +167,7 @@ class Loader_test extends CI_TestCase { /** * @coverts CI_Loader::view */ - public function testNonExistentView() + public function test_non_existent_view() { $this->setExpectedException( 'Exception', @@ -179,7 +179,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testFile() + public function test_file() { $content = 'Here is a test file, which we will load now.'; $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content) @@ -202,7 +202,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testVars() + public function test_vars() { $vars = array( 'foo' => 'bar' @@ -214,7 +214,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testHelper() + public function test_helper() { $this->assertEquals(NULL, $this->load->helper('array')); @@ -228,7 +228,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLoadingMultipleHelpers() + public function test_loading_multiple_helpers() { $this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string'))); } @@ -242,7 +242,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLoadConfig() + public function test_load_config() { $this->_setup_config_mock(); @@ -251,7 +251,7 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- - public function testLoadBadConfig() + public function test_load_bad_config() { $this->_setup_config_mock(); -- cgit v1.2.3-24-g4f1b From 2e00c2490fb544596fba06483ad1c1d626c1fd4f Mon Sep 17 00:00:00 2001 From: Stephen Date: Sun, 28 Aug 2011 10:25:40 +0200 Subject: Added tests for CI_URI class. Made modifications to core class which helped with isolation for testing. --- tests/codeigniter/core/URI_test.php | 344 ++++++++++++++++++++++++++++++++++++ 1 file changed, 344 insertions(+) create mode 100644 tests/codeigniter/core/URI_test.php (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php new file mode 100644 index 000000000..87d921b11 --- /dev/null +++ b/tests/codeigniter/core/URI_test.php @@ -0,0 +1,344 @@ +ci_core_class('cfg'); + + // set predictable config values + $test->ci_set_config(array( + 'index_page' => 'index.php', + 'base_url' => 'http://example.com/', + 'subclass_prefix' => 'MY_' + )); + + $this->config = new $cls; + + } + + protected function _is_cli_request() + { + return FALSE; + } +} + +class URI_test extends CI_TestCase { + + public function set_up() + { + $this->uri = new URI_extended(); + } + + // -------------------------------------------------------------------- + + public function test_set_uri_string() + { + // Slashes get killed + $this->uri->_set_uri_string('/'); + + $a = ''; + $b =& $this->uri->uri_string; + + $this->assertEquals($a, $b); + + $this->uri->_set_uri_string('nice/uri'); + + $a = 'nice/uri'; + + $this->assertEquals($a, $b); + } + + // -------------------------------------------------------------------- + + public function test_fetch_uri_string() + { + define('SELF', 'index.php'); + + // uri_protocol: AUTO + $this->uri->config->set_item('uri_protocol', 'AUTO'); + + // Test a variety of request uris + $requests = array( + '/index.php/controller/method' => 'controller/method', + '/index.php?/controller/method' => 'controller/method', + '/index.php?/controller/method/?var=foo' => 'controller/method' + ); + + foreach($requests as $request => $expected) + { + $_SERVER['SCRIPT_NAME'] = '/index.php'; + $_SERVER['REQUEST_URI'] = $request; + + $this->uri->_fetch_uri_string(); + $this->assertEquals($expected, $this->uri->uri_string ); + } + + // Test a subfolder + $_SERVER['SCRIPT_NAME'] = '/subfolder/index.php'; + $_SERVER['REQUEST_URI'] = '/subfolder/index.php/controller/method'; + + $this->uri->_fetch_uri_string(); + + $a = 'controller/method'; + $b = $this->uri->uri_string; + + $this->assertEquals($a, $b); + + // death to request uri + unset($_SERVER['REQUEST_URI']); + + // life to path info + $_SERVER['PATH_INFO'] = '/controller/method/'; + + $this->uri->_fetch_uri_string(); + + $a = '/controller/method/'; + $b =& $this->uri->uri_string; + + $this->assertEquals($a, $b); + + // death to path info + // At this point your server must be seriously drunk + unset($_SERVER['PATH_INFO']); + + $_SERVER['QUERY_STRING'] = '/controller/method/'; + + $this->uri->_fetch_uri_string(); + + $a = '/controller/method/'; + $b = $this->uri->uri_string; + + $this->assertEquals($a, $b); + + // At this point your server is a labotomy victim + + unset($_SERVER['QUERY_STRING']); + + $_GET['/controller/method/'] = ''; + + $this->uri->_fetch_uri_string(); + $this->assertEquals($a, $b); + + // Test coverage implies that these will work + // uri_protocol: REQUEST_URI + // uri_protocol: CLI + + } + + // -------------------------------------------------------------------- + + public function test_explode_segments() + { + // Lets test the function's ability to clean up this mess + $uris = array( + 'test/uri' => array('test', 'uri'), + '/test2/uri2' => array('test2', 'uri2'), + '//test3/test3///' => array('test3', 'test3') + ); + + foreach($uris as $uri => $a) + { + $this->uri->segments = array(); + $this->uri->uri_string = $uri; + $this->uri->_explode_segments(); + + $b = $this->uri->segments; + + $this->assertEquals($a, $b); + } + + } + + // -------------------------------------------------------------------- + + public function test_filter_uri() + { + $this->uri->config->set_item('enable_query_strings', FALSE); + $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-'); + + $str_in = 'abc01239~%.:_-'; + $str = $this->uri->_filter_uri($str_in); + + $this->assertEquals($str, $str_in); + } + + // -------------------------------------------------------------------- + + public function test_filter_uri_escaping() + { + // ensure escaping even if dodgey characters are permitted + + $this->uri->config->set_item('enable_query_strings', FALSE); + $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-()$'); + + $str = $this->uri->_filter_uri('$destroy_app(foo)'); + + $this->assertEquals($str, '$destroy_app(foo)'); + } + + // -------------------------------------------------------------------- + + public function test_filter_uri_throws_error() + { + $this->setExpectedException('Exception'); + + $this->uri->config->set_item('enable_query_strings', FALSE); + $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-'); + $this->uri->_filter_uri('$this()'); + } + + // -------------------------------------------------------------------- + + public function test_remove_url_suffix() + { + $this->uri->config->set_item('url_suffix', '.html'); + + $this->uri->uri_string = 'controller/method/index.html'; + $this->uri->_remove_url_suffix(); + + $this->assertEquals($this->uri->uri_string, 'controller/method/index'); + + $this->uri->uri_string = 'controller/method/index.htmlify.html'; + $this->uri->_remove_url_suffix(); + + $this->assertEquals($this->uri->uri_string, 'controller/method/index.htmlify'); + } + + // -------------------------------------------------------------------- + + public function test_segment() + { + $this->uri->segments = array(1 => 'controller'); + $this->assertEquals($this->uri->segment(1), 'controller'); + $this->assertEquals($this->uri->segment(2, 'default'), 'default'); + } + + // -------------------------------------------------------------------- + + public function test_rsegment() + { + $this->uri->rsegments = array(1 => 'method'); + $this->assertEquals($this->uri->rsegment(1), 'method'); + $this->assertEquals($this->uri->rsegment(2, 'default'), 'default'); + } + + // -------------------------------------------------------------------- + + public function test_uri_to_assoc() + { + $this->uri->segments = array('a', '1', 'b', '2', 'c', '3'); + + $a = array('a' => '1', 'b' => '2', 'c' => '3'); + $b = $this->uri->uri_to_assoc(1); + $this->assertEquals($a, $b); + + $a = array('b' => '2', 'c' => '3'); + $b = $this->uri->uri_to_assoc(3); + $this->assertEquals($a, $b); + + + $this->uri->keyval = array(); // reset cache + + $this->uri->segments = array('a', '1', 'b', '2', 'c'); + + $a = array('a' => '1', 'b' => '2', 'c' => FALSE); + $b = $this->uri->uri_to_assoc(1); + $this->assertEquals($a, $b); + + $this->uri->keyval = array(); // reset cache + + $this->uri->segments = array('a', '1'); + + // test default + $a = array('a' => '1', 'b' => FALSE); + $b = $this->uri->uri_to_assoc(1, array('a', 'b')); + $this->assertEquals($a, $b); + } + + // -------------------------------------------------------------------- + + public function test_ruri_to_assoc() + { + $this->uri->rsegments = array('x', '1', 'y', '2', 'z', '3'); + + $a = array('x' => '1', 'y' => '2', 'z' => '3'); + $b = $this->uri->ruri_to_assoc(1); + $this->assertEquals($a, $b); + + $a = array('y' => '2', 'z' => '3'); + $b = $this->uri->ruri_to_assoc(3); + $this->assertEquals($a, $b); + + + $this->uri->keyval = array(); // reset cache + + $this->uri->rsegments = array('x', '1', 'y', '2', 'z'); + + $a = array('x' => '1', 'y' => '2', 'z' => FALSE); + $b = $this->uri->ruri_to_assoc(1); + $this->assertEquals($a, $b); + + $this->uri->keyval = array(); // reset cache + + $this->uri->rsegments = array('x', '1'); + + // test default + $a = array('x' => '1', 'y' => FALSE); + $b = $this->uri->ruri_to_assoc(1, array('x', 'y')); + $this->assertEquals($a, $b); + + } + + // -------------------------------------------------------------------- + + public function test_assoc_to_uri() + { + $this->uri->config->set_item('uri_string_slashes', 'none'); + + $arr = array('a' => 1, 'b' => 2); + $a = 'a/1/b/2'; + $b = $this->uri->assoc_to_uri($arr); + $this->assertEquals($a, $b); + } + + // -------------------------------------------------------------------- + + public function test_slash_segment() + { + $this->uri->segments[1] = 'segment'; + $this->uri->rsegments[1] = 'segment'; + + $a = '/segment/'; + $b = $this->uri->slash_segment(1, 'both'); + $this->assertEquals($a, $b); + $b = $this->uri->slash_rsegment(1, 'both'); + $this->assertEquals($a, $b); + + $a = '/segment'; + $b = $this->uri->slash_segment(1, 'leading'); + $this->assertEquals($a, $b); + $b = $this->uri->slash_rsegment(1, 'leading'); + $this->assertEquals($a, $b); + + $a = 'segment/'; + $b = $this->uri->slash_segment(1, 'trailing'); + $this->assertEquals($a, $b); + $b = $this->uri->slash_rsegment(1, 'trailing'); + $this->assertEquals($a, $b); + } + + +} +// END URI_test Class + +/* End of file URI_test.php */ +/* Location: ./tests/core/URI_test.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cf1926acb352f1d80cab7c1bc7e1ec5457a2b43d Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Mon, 29 Aug 2011 00:00:51 -0400 Subject: Removed beginning slash in expected for site_url. --- tests/codeigniter/core/Config_test.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index b6c57da70..30f0cc61d 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -67,13 +67,13 @@ class Config_test extends CI_TestCase { $this->config->set_item('enable_query_strings', FALSE); - $this->assertEquals('/index.php/test', $this->config->site_url('test')); - $this->assertEquals('/index.php/test/1', $this->config->site_url(array('test', '1'))); + $this->assertEquals('index.php/test', $this->config->site_url('test')); + $this->assertEquals('index.php/test/1', $this->config->site_url(array('test', '1'))); $this->config->set_item('enable_query_strings', TRUE); - $this->assertEquals('/index.php?test', $this->config->site_url('test')); - $this->assertEquals('/index.php?0=test&1=1', $this->config->site_url(array('test', '1'))); + $this->assertEquals('index.php?test', $this->config->site_url('test')); + $this->assertEquals('index.php?0=test&1=1', $this->config->site_url(array('test', '1'))); $this->config->set_item('base_url', $base_url); -- cgit v1.2.3-24-g4f1b From 7729faa553c0ec93a13533003a53dc66078467a8 Mon Sep 17 00:00:00 2001 From: Hamza Bhatti Date: Sat, 10 Mar 2012 13:07:05 +0400 Subject: Fix test errors in Loader_test.php and URI_test.php Change exceptions from Exception to RuntimeException since PHPUnit 3.6 doesn't like you to expect generic exceptions. The error it gives is: InvalidArgumentException: You must not expect the generic exception class travis-ci.org/#!/tiyowan/CodeIgniter/builds/832518 This issue addressed by using exceptions that are more specific. --- tests/codeigniter/core/Loader_test.php | 12 ++++++------ tests/codeigniter/core/URI_test.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 9ba870b7d..b86fd3477 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -104,7 +104,7 @@ class Loader_test extends CI_TestCase { public function test_non_existent_model() { $this->setExpectedException( - 'Exception', + 'RuntimeException', 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php' ); @@ -170,7 +170,7 @@ class Loader_test extends CI_TestCase { public function test_non_existent_view() { $this->setExpectedException( - 'Exception', + 'RuntimeException', 'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php' ); @@ -192,7 +192,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals($content, $load); $this->setExpectedException( - 'Exception', + 'RuntimeException', 'CI Error: Unable to load the requested file: ci_test_file_not_exists' ); @@ -219,7 +219,7 @@ class Loader_test extends CI_TestCase { $this->assertEquals(NULL, $this->load->helper('array')); $this->setExpectedException( - 'Exception', + 'RuntimeException', 'CI Error: Unable to load the requested file: helpers/bad_helper.php' ); @@ -256,7 +256,7 @@ class Loader_test extends CI_TestCase { $this->_setup_config_mock(); $this->setExpectedException( - 'Exception', + 'RuntimeException', 'CI Error: The configuration file foobar.php does not exist.' ); @@ -268,4 +268,4 @@ class Loader_test extends CI_TestCase { -} \ No newline at end of file +} diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index 87d921b11..40252aa14 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -189,7 +189,7 @@ class URI_test extends CI_TestCase { public function test_filter_uri_throws_error() { - $this->setExpectedException('Exception'); + $this->setExpectedException('RuntimeException'); $this->uri->config->set_item('enable_query_strings', FALSE); $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-'); @@ -341,4 +341,4 @@ class URI_test extends CI_TestCase { // END URI_test Class /* End of file URI_test.php */ -/* Location: ./tests/core/URI_test.php */ \ No newline at end of file +/* Location: ./tests/core/URI_test.php */ -- cgit v1.2.3-24-g4f1b From 8749bc7e836c196dfef37d3b7b5a67736a15092c Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 11 Mar 2012 05:43:45 +0700 Subject: Fix incomplete and skipped test --- tests/codeigniter/core/Lang_test.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/codeigniter/core') diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index dcc3d0879..a414f0ace 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -6,6 +6,9 @@ class Lang_test extends CI_TestCase { public function set_up() { + $loader_cls = $this->ci_core_class('load'); + $this->ci_instance_var('load', new $loader_cls); + $cls = $this->ci_core_class('lang'); $this->lang = new $cls; } @@ -14,17 +17,14 @@ class Lang_test extends CI_TestCase { public function test_load() { - // get_config needs work - $this->markTestIncomplete('get_config needs work'); - //$this->assertTrue($this->lang->load('profiler')); + $this->assertTrue($this->lang->load('profiler', 'english')); } // -------------------------------------------------------------------- public function test_line() { - $this->markTestIncomplete('get_config needs work'); - + $this->assertTrue($this->lang->load('profiler', 'english')); $this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string')); } -- cgit v1.2.3-24-g4f1b