Abstract Class yiiunit\apidoc\TestCase
Inheritance | yiiunit\apidoc\TestCase » PHPUnit\Framework\TestCase |
---|---|
Subclasses | yiiunit\apidoc\commands\ApiControllerTest, yiiunit\apidoc\commands\GuideControllerTest |
This is the base class for all yii framework unit tests.
Public Methods
隐藏继承的方法 Hide inherited methods
方法 Method | 简介 Description | 定义在 Defined By |
---|---|---|
assertContainsWithoutIndent() | Asserts that a haystack contains a needle, ignoring indenting symbols. | yiiunit\apidoc\TestCase |
assertEqualsWithoutLE() | Asserting two strings equality ignoring line endings | yiiunit\apidoc\TestCase |
Protected Methods
隐藏继承的方法 Hide inherited methods
方法 Method | 简介 Description | 定义在 Defined By |
---|---|---|
destroyApplication() | Destroys application in Yii::$app by setting it to null. | yiiunit\apidoc\TestCase |
invoke() | Invokes object method, even if it is private or protected. | yiiunit\apidoc\TestCase |
mockApplication() | Populates Yii::$app with a new application The application will be destroyed on tearDown() automatically. | yiiunit\apidoc\TestCase |
removeRuntimeDirectory() | Removes tests runtime directory as a cleanup. | yiiunit\apidoc\TestCase |
runControllerAction() | Emulates running of the console controller action. | yiiunit\apidoc\TestCase |
tearDown() | Clean up after test. | yiiunit\apidoc\TestCase |
方法详情 Method Details
Asserts that a haystack contains a needle, ignoring indenting symbols.
public void assertContainsWithoutIndent ( $needle, $haystack, $message = '' ) | ||
$needle | mixed | |
$haystack | mixed | |
$message | string |
Asserting two strings equality ignoring line endings
public void assertEqualsWithoutLE ( $expected, $actual ) | ||
$expected | string | |
$actual | string |
Destroys application in Yii::$app by setting it to null.
protected void destroyApplication ( ) |
Invokes object method, even if it is private or protected.
protected mixed invoke ( $object, $method, array $args = [] ) | ||
$object | object | Object. |
$method | string | Method name. |
$args | array | Method arguments |
return | mixed | Method result |
---|
Populates Yii::$app with a new application The application will be destroyed on tearDown() automatically.
protected void mockApplication ( $config = [], $appClass = '\yii\console\Application' ) | ||
$config | array | The application configuration, if needed |
$appClass | string | Name of the application class to create |
Removes tests runtime directory as a cleanup.
protected void removeRuntimeDirectory ( ) |
Emulates running of the console controller action.
protected string runControllerAction ( $controller, $actionId, array $args = [] ) | ||
$controller | yii\console\Controller|yiiunit\apidoc\support\controllers\StdOutBufferControllerTrait | Controller instance. |
$actionId | string | Id of action to be run. |
$args | array | Action arguments. |
return | string | Command output. |
---|---|---|
throws | Throwable | on failure. |
Clean up after test.
By default the application created with mockApplication() will be destroyed.
protected void tearDown ( ) |