Trait ConsoleIntegrationTestTrait

A test case class intended to make integration tests of cake console commands easier.

Direct Users

Properties summary

Method Summary

Method Detail

assertErrorContains()source public

assertErrorContains( string $expected , string $message = '' )

Asserts stderr contains expected output

Parameters

string $expected
Expected output
string $message optional ''
Failure message

assertErrorEmpty()source public

assertErrorEmpty( string $message = '' )

Asserts that stderr is empty

Parameters

string $message optional ''
The message to output when the assertion fails.

assertErrorRegExp()source public

assertErrorRegExp( string $pattern , string $message = '' )

Asserts stderr contains expected regexp

Parameters

string $pattern
Expected pattern
string $message optional ''
Failure message

assertExitCode()source public

assertExitCode( integer $expected , string $message = '' )

Asserts shell exited with the expected code

Parameters

integer $expected
Expected exit code
string $message optional ''
Failure message

assertExitError()source public

assertExitError( string $message = '' )

Asserts shell exited with Command::CODE_ERROR

Parameters

string $message optional ''
Failure message

assertExitSuccess()source public

assertExitSuccess( string $message = '' )

Asserts shell exited with the Command::CODE_SUCCESS

Parameters

string $message optional ''
Failure message

assertOutputContains()source public

assertOutputContains( string $expected , string $message = '' )

Asserts stdout contains expected output

Parameters

string $expected
Expected output
string $message optional ''
Failure message

assertOutputContainsRow()source protected

assertOutputContainsRow( array $row , string $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()source public

assertOutputEmpty( string $message = '' )

Asserts that stdout is empty

Parameters

string $message optional ''
The message to output when the assertion fails.

assertOutputNotContains()source public

assertOutputNotContains( string $expected , string $message = '' )

Asserts stdout does not contain expected output

Parameters

string $expected
Expected output
string $message optional ''
Failure message

assertOutputRegExp()source public

assertOutputRegExp( string $pattern , string $message = '' )

Asserts stdout contains expected regexp

Parameters

string $pattern
Expected pattern
string $message optional ''
Failure message

cleanupConsoleTrait()source public

cleanupConsoleTrait( )

Cleans state to get ready for the next test

After

commandStringToArgs()source protected

commandStringToArgs( string $command )

Creates an $argv array from a command string

Parameters

string $command
Command string

Returns

array

exec()source public

exec( string $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()source protected

makeRunner( )

Builds the appropriate command dispatcher

Returns

Cake\Console\CommandRunner|Cake\TestSuite\LegacyCommandRunner

useCommandRunner()source public

useCommandRunner( )

Set this test case to use the CommandRunner rather than the legacy ShellDispatcher

Properties detail

$_errsource

protected Cake\TestSuite\Stub\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null

Console error output stub

$_exitCodesource

protected integer|null

Last exit code

$_insource

protected Cake\Console\ConsoleInput|PHPUnit_Framework_MockObject_MockObject|null

Console input mock

$_outsource

protected Cake\TestSuite\Stub\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null

Console output stub

$_useCommandRunnersource

protected boolean

Whether or not to use the CommandRunner

false

© 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.8/class-Cake.TestSuite.ConsoleIntegrationTestTrait.html