yiiunit\apidoc\TestCase - Yii2 类参考手册

Abstract Class yiiunit\apidoc\TestCase

Inheritanceyiiunit\apidoc\TestCase » PHPUnit\Framework\TestCase
Subclassesyiiunit\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

assertContainsWithoutIndent() public method

Asserts that a haystack contains a needle, ignoring indenting symbols.

public void assertContainsWithoutIndent ( $needle, $haystack, $message '' )
$needle mixed
$haystack mixed
$message string
assertEqualsWithoutLE() public method

Asserting two strings equality ignoring line endings

public void assertEqualsWithoutLE ( $expected, $actual )
$expected string
$actual string
destroyApplication() protected method

Destroys application in Yii::$app by setting it to null.

protected void destroyApplication ( )
invoke() protected method

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

mockApplication() protected method

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

removeRuntimeDirectory() protected method

Removes tests runtime directory as a cleanup.

protected void removeRuntimeDirectory ( )
runControllerAction() protected method

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.

tearDown() protected method

Clean up after test.

By default the application created with mockApplication() will be destroyed.

protected void tearDown ( )