Skip to content

Commit

Permalink
Add $this->resetInstance() to set up for model testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Aug 6, 2015
1 parent 7b2ac36 commit ce46307
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions application/tests/_ci_phpunit_test/CIPHPUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class CIPHPUnitTestCase extends PHPUnit_Framework_TestCase
*/
protected $double;

/**
* @var CI_Controller
*/
protected $CI;

/**
* Constructs a test case with the given name.
*
Expand All @@ -47,6 +52,16 @@ public static function setUpBeforeClass()
$_SERVER['argc'] = 1;
}

/**
* Reset CodeIgniter instance and assign new CodeIgniter instance as $this->CI
*/
public function resetInstance()
{
reset_instance();
new CI_Controller();
$this->CI =& get_instance();
}

public function tearDown()
{
if (class_exists('MonkeyPatch', false))
Expand Down

0 comments on commit ce46307

Please sign in to comment.