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/Loader_test.php | 144 +++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 tests/codeigniter/core/Loader_test.php (limited to 'tests/codeigniter/core/Loader_test.php') 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/Loader_test.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tests/codeigniter/core/Loader_test.php') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index fd9c63216..c7085c439 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php') 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/Loader_test.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'tests/codeigniter/core/Loader_test.php') 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 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 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/codeigniter/core/Loader_test.php') 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 +} -- cgit v1.2.3-24-g4f1b