From 8889db7e1b1768ecfb76e9e73598541042a9edc1 Mon Sep 17 00:00:00 2001 From: dchill42 Date: Mon, 22 Oct 2012 23:16:26 -0400 Subject: Replaced evals with getMock usage in Loader tests Signed-off-by: dchill42 --- tests/codeigniter/core/Loader_test.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index a8a2de78f..f7c338a20 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -264,15 +264,12 @@ class Loader_test extends CI_TestCase { $this->assertEquals($content.$value, $out); // Mock output class - $class = 'Mock_Load_Output'; - $prop = 'output'; - eval('class '.$class.' { public function append_output($out) { $this->'.$prop.' = $out; } }'); - $this->ci_instance_var('output', new $class()); + $output = $this->getMock('CI_Output', array('append_output')); + $output->expects($this->once())->method('append_output')->with($content.$value); + $this->ci_instance_var('output', $output); // Test view output - $this->load->view($view, array($var => $value)); - $this->assertObjectHasAttribute($prop, $this->ci_obj->output); - $this->assertEquals($content.$value, $this->ci_obj->output->$prop); + $this->assertNull($this->load->view($view, array($var => $value))); } // -------------------------------------------------------------------- @@ -397,17 +394,12 @@ class Loader_test extends CI_TestCase { public function test_language() { - // Create mock Lang class with load stub - $class = 'Mock_Load_Lang'; - $prop = '_file'; - eval('class '.$class.' { public function load($file, $lang) { $this->'.$prop.' = $file; } }'); - $this->ci_instance_var('lang', new $class()); - - // Does the right file get loaded? + // Mock lang class and test load call $file = 'test'; + $lang = $this->getMock('CI_Lang', array('load')); + $lang->expects($this->once())->method('load')->with($file); + $this->ci_instance_var('lang', $lang); $this->assertNull($this->load->language($file)); - $this->assertObjectHasAttribute($prop, $this->ci_obj->lang); - $this->assertEquals($file, $this->ci_obj->lang->$prop); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b