Trait ConsoleIntegrationTestTrait
A test case class intended to make integration tests of cake console commands easier.
Properties summary
- $_err protected
\Cake\TestSuite\Stub\ConsoleOutput|\PHPUnit_Framework_MockObject_MockObject|nullConsole error output stub
- $_exitCode protected
int|nullLast exit code
- $_in protected
\Cake\Console\ConsoleInput|\PHPUnit_Framework_MockObject_MockObject|nullConsole input mock
- $_out protected
\Cake\TestSuite\Stub\ConsoleOutput|\PHPUnit_Framework_MockObject_MockObject|nullConsole output stub
- $_useCommandRunner protected
boolWhether or not to use the CommandRunner
Method Summary
- useCommandRunner() public
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
Method Detail
assertErrorContains() public
assertErrorContains(mixed $expected, mixed $message)
Asserts stderr contains expected output
Parameters
-
string$expected Expected output
-
string$message optional Failure message
assertErrorEmpty() public
assertErrorEmpty(mixed $message)
Asserts that stderr is empty
Parameters
-
string$message optional The message to output when the assertion fails.
assertErrorRegExp() public
assertErrorRegExp(mixed $pattern, mixed $message)
Asserts stderr contains expected regexp
Parameters
-
string$pattern Expected pattern
-
string$message optional Failure message
assertExitCode() public
assertExitCode(mixed $expected, mixed $message)
Asserts shell exited with the expected code
Parameters
-
int$expected Expected exit code
-
string$message optional Failure message
assertExitError() public
assertExitError(mixed $message)
Asserts shell exited with Command::CODE_ERROR
Parameters
-
string$message optional Failure message
assertExitSuccess() public
assertExitSuccess(mixed $message)
Asserts shell exited with the Command::CODE_SUCCESS
Parameters
-
string$message optional Failure message
assertOutputContains() public
assertOutputContains(mixed $expected, mixed $message)
Asserts stdout contains expected output
Parameters
-
string$expected Expected output
-
string$message optional Failure message
assertOutputContainsRow() protected
assertOutputContainsRow(array $row, mixed $message)
Check that a row of cells exists in the output.
Parameters
-
array$row Row of cells to ensure exist in the output.
-
string$message optional Failure message.
assertOutputEmpty() public
assertOutputEmpty(mixed $message)
Asserts that stdout is empty
Parameters
-
string$message optional The message to output when the assertion fails.
assertOutputNotContains() public
assertOutputNotContains(mixed $expected, mixed $message)
Asserts stdout does not contain expected output
Parameters
-
string$expected Expected output
-
string$message optional Failure message
assertOutputRegExp() public
assertOutputRegExp(mixed $pattern, mixed $message)
Asserts stdout contains expected regexp
Parameters
-
string$pattern Expected pattern
-
string$message optional Failure message
cleanupConsoleTrait() public
cleanupConsoleTrait()
Cleans state to get ready for the next test
commandStringToArgs() protected
commandStringToArgs(mixed $command)
Creates an $argv array from a command string
Parameters
-
string$command Command string
Returns
arrayexec() public
exec(mixed $command, array $input)
Runs cli integration test
Parameters
-
string$command Command to run
-
array$input optional Input values to pass to an interactive shell
makeRunner() protected
makeRunner()
Builds the appropriate command dispatcher
Returns
\Cake\Console\CommandRunner|\Cake\TestSuite\LegacyCommandRunneruseCommandRunner() public
useCommandRunner()
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
Property Detail
$_err protected
Console error output stub
Type
\Cake\TestSuite\Stub\ConsoleOutput|\PHPUnit_Framework_MockObject_MockObject|null$_exitCode protected
Last exit code
Type
int|null$_in protected
Console input mock
Type
\Cake\Console\ConsoleInput|\PHPUnit_Framework_MockObject_MockObject|null$_out protected
Console output stub
Type
\Cake\TestSuite\Stub\ConsoleOutput|\PHPUnit_Framework_MockObject_MockObject|null$_useCommandRunner protected
Whether or not to use the CommandRunner
Type
bool
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.9/trait-Cake.TestSuite.ConsoleIntegrationTestTrait.html