From 6b7fc8fc1826406d5c6d04afe2c39a36e5522609 Mon Sep 17 00:00:00 2001 From: Christian Mohr Date: Wed, 7 Mar 2018 19:05:20 +0100 Subject: added test for nested view --- tests/codeigniter/core/Loader_test.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index df698f30c..f043d1fcc 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -318,6 +318,15 @@ class Loader_test extends CI_TestCase { $vars = new stdClass(); $vars->$var = $value; $this->assertInstanceOf('CI_Loader', $this->load->view($view, $vars)); + + // Create another view in VFS, nesting the first one without its own $vars + $nesting_view = 'unit_test_nesting_view'; + $nesting_content = 'Here comes a nested view. '; + $this->ci_vfs_create($nesting_view, $nesting_content.'view("'.$view.'");', $this->ci_app_root, 'views'); + + // Test $vars inheritance to nested views + $out = $this->load->view($nesting_view, array("loader" => $this->load, $var => $value), TRUE); + $this->assertEquals($nesting_content.$content.$value, $out); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0e594f14d34e54fa97cb29a0b08eb3efd0e7a939 Mon Sep 17 00:00:00 2001 From: Christian Mohr Date: Wed, 7 Mar 2018 19:11:49 +0100 Subject: added load_view unit test to ensure that a once set and later missing parameter is in fact missing --- tests/codeigniter/core/Loader_test.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests/codeigniter') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index f043d1fcc..40d310274 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -303,12 +303,16 @@ class Loader_test extends CI_TestCase { $var = 'hello'; $value = 'World!'; $content = 'This is my test page. '; - $this->ci_vfs_create($view, $content.'ci_app_root, 'views'); + $this->ci_vfs_create($view, $content.'ci_app_root, 'views'); // Test returning view $out = $this->load->view($view, array($var => $value), TRUE); $this->assertEquals($content.$value, $out); + // Test view with missing parameter in $vars + $out = $this->load->view($view, [], TRUE); + $this->assertEquals($content.'undefined', $out); + // Mock output class $output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock(); $output->expects($this->once())->method('append_output')->with($content.$value); -- cgit v1.2.3-24-g4f1b