-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from kenjis/add-unit-test-case-class
Add UnitTestCase class
- Loading branch information
Showing
6 changed files
with
145 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
class UnitTestCase extends CIPHPUnitTestUnitTestCase | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
application/tests/_ci_phpunit_test/CIPHPUnitTestUnitTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Part of ci-phpunit-test | ||
* | ||
* @author Kenji Suzuki <https://github.com/kenjis> | ||
* @license MIT License | ||
* @copyright 2015 Kenji Suzuki | ||
* @link https://github.com/kenjis/ci-phpunit-test | ||
*/ | ||
|
||
class CIPHPUnitTestUnitTestCase extends CIPHPUnitTestCase | ||
{ | ||
/** | ||
* Create a controller instance | ||
* | ||
* @param string $classname | ||
* @return CI_Controller | ||
*/ | ||
public function newController($classname) | ||
{ | ||
reset_instance(); | ||
$controller = new $classname; | ||
$this->CI =& get_instance(); | ||
return $controller; | ||
} | ||
|
||
/** | ||
* Create a model instance | ||
* | ||
* @param string $classname | ||
* @return CI_Model | ||
*/ | ||
public function newModel($classname) | ||
{ | ||
$this->resetInstance(); | ||
$this->CI->load->model($classname); | ||
|
||
// Is the model in a sub-folder? | ||
if (($last_slash = strrpos($classname, '/')) !== FALSE) | ||
{ | ||
$classname = substr($classname, ++$last_slash); | ||
} | ||
|
||
return $this->CI->$classname; | ||
} | ||
|
||
/** | ||
* Create a library instance | ||
* | ||
* @param string $classname | ||
* @param array $args | ||
* @return object | ||
*/ | ||
public function newLibrary($classname, $args = null) | ||
{ | ||
$this->resetInstance(); | ||
$this->CI->load->library($classname, $args); | ||
|
||
// Is the library in a sub-folder? | ||
if (($last_slash = strrpos($classname, '/')) !== FALSE) | ||
{ | ||
$classname = substr($classname, ++$last_slash); | ||
} | ||
$classname = strtolower($classname); | ||
|
||
return $this->CI->$classname; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters