Skip to content
Browse files

Merge pull request #2030 from dchill42/unit_tests

Replaced Mock_Core_Lang with PHPUnit mockups
  • Loading branch information...
2 parents ad5f1d0 + 1713d32 commit ade05b40714070bcda7ab32187068e95b98c8cf8 @narfbg narfbg committed Nov 25, 2012
View
4 tests/codeigniter/helpers/language_helper_test.php
@@ -5,7 +5,9 @@ class Language_helper_test extends CI_TestCase {
public function test_lang()
{
$this->helper('language');
- $this->ci_instance_var('lang', new Mock_Core_Lang());
+ $lang = $this->getMock('CI_Lang', array('line'));
+ $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
+ $this->ci_instance_var('lang', $lang);
$this->assertFalse(lang(1));
$this->assertEquals('<label for="foo"></label>', lang(1, 'foo'));
View
13 tests/codeigniter/libraries/Calendar_test.php
@@ -2,12 +2,12 @@
class Calendar_test extends CI_TestCase {
- function __construct()
+ function set_up()
{
- $obj = new stdClass;
- $obj->calendar = new Mock_Libraries_Calendar();
-
- $this->calendar = $obj->calendar;
+ $lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
+ $this->ci_instance_var('lang', $lang);
+ $this->calendar = new CI_Calendar();
}
function test_initialize()
@@ -20,9 +20,6 @@ function test_initialize()
$this->assertEquals('monday', $this->calendar->start_day);
}
- /**
- * @covers Mock_Libraries_Calendar::parse_template
- */
function test_generate()
{
$no_events = '<table border="0" cellpadding="4" cellspacing="0">
View
3 tests/codeigniter/libraries/Upload_test.php
@@ -7,7 +7,8 @@ function set_up()
$ci = $this->ci_instance();
$ci->upload = new Mock_Libraries_Upload();
$ci->security = new Mock_Core_Security();
- $ci->lang = new Mock_Core_Lang();
+ $ci->lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $ci->lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->upload = $ci->upload;
}
View
15 tests/mocks/core/lang.php
@@ -1,15 +0,0 @@
-<?php
-
-class Mock_Core_Lang extends CI_Lang {
-
- public function line($line = '')
- {
- return FALSE;
- }
-
- public function load($langfile, $idiom = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '')
- {
- return;
- }
-
-}
View
25 tests/mocks/libraries/calendar.php
@@ -1,25 +0,0 @@
-<?php
-
-class Mock_Libraries_Calendar extends CI_Calendar {
-
- public function __construct($config = array())
- {
- $this->CI = new stdClass;
- $this->CI->lang = new Mock_Core_Lang();
-
- if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE))
- {
- $this->CI->lang->load('calendar');
- }
-
- $this->local_time = time();
-
- if (count($config) > 0)
- {
- $this->initialize($config);
- }
-
- log_message('debug', 'Calendar Class Initialized');
- }
-
-}

0 comments on commit ade05b4

Please sign in to comment.
Something went wrong with that request. Please try again.