diff options
author | dchill42 <dchill42@gmail.com> | 2012-10-23 05:16:26 +0200 |
---|---|---|
committer | dchill42 <dchill42@gmail.com> | 2012-10-23 05:16:26 +0200 |
commit | 8889db7e1b1768ecfb76e9e73598541042a9edc1 (patch) | |
tree | bf74e17b593db9c242238598e79af979dd9556e5 | |
parent | c2f59ef2d5d3ef28a113a11c24bee25eb03eeb56 (diff) |
Replaced evals with getMock usage in Loader tests
Signed-off-by: dchill42 <dchill42@gmail.com>
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 24 |
1 files changed, 8 insertions, 16 deletions
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); } // -------------------------------------------------------------------- |