Trait ConsoleIntegrationTestTrait
A test case class intended to make integration tests of cake console commands easier.
Direct Users
Properties summary
-
$_err
protectedCake\TestSuite\Stub\ConsoleOutput
|PHPUnit_Framework_MockObject_MockObject|nullConsole error output stub -
$_exitCode
protectedinteger|null
Last exit code -
$_in
protectedCake\Console\ConsoleInput
|PHPUnit_Framework_MockObject_MockObject|nullConsole input mock -
$_out
protectedCake\TestSuite\Stub\ConsoleOutput
|PHPUnit_Framework_MockObject_MockObject|nullConsole output stub -
$_useCommandRunner
protectedboolean
Whether or not to use the CommandRunner
Method Summary
-
assertErrorContains() public
Assertsstderr
contains expected output -
assertErrorEmpty() public
Asserts thatstderr
is empty -
assertErrorRegExp() public
Assertsstderr
contains expected regexp -
assertExitCode() public
Asserts shell exited with the expected code -
assertOutputContains() public
Assertsstdout
contains expected output -
assertOutputContainsRow() protected
Check that a row of cells exists in the output. -
assertOutputEmpty() public
Asserts thatstdout
is empty -
assertOutputNotContains() public
Assertsstdout
does not contain expected output -
assertOutputRegExp() public
Assertsstdout
contains expected regexp -
cleanupConsoleTrait() public
Cleans state to get ready for the next test -
commandStringToArgs() protected
Creates an $argv array from a command string -
exec() public
Runs cli integration test -
makeRunner() protected
Builds the appropriate command dispatcher -
useCommandRunner() public
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
Method Detail
assertErrorContains() public ¶
assertErrorContains( string $expected , string $message '' )
Asserts stderr
contains expected output
Parameters
- string $expected
- Expected output
- string $message optional ''
- Failure message
assertErrorEmpty() public ¶
assertErrorEmpty( string $message '' )
Asserts that stderr
is empty
Parameters
- string $message optional ''
- The message to output when the assertion fails.
assertErrorRegExp() public ¶
assertErrorRegExp( string $pattern , string $message '' )
Asserts stderr
contains expected regexp
Parameters
- string $pattern
- Expected pattern
- string $message optional ''
- Failure message
assertExitCode() public ¶
assertExitCode( integer $expected , string $message '' )
Asserts shell exited with the expected code
Parameters
- integer $expected
- Expected exit code
- string $message optional ''
- Failure message
assertOutputContains() public ¶
assertOutputContains( string $expected , string $message '' )
Asserts stdout
contains expected output
Parameters
- string $expected
- Expected output
- string $message optional ''
- Failure message
assertOutputContainsRow() 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() public ¶
assertOutputEmpty( string $message '' )
Asserts that stdout
is empty
Parameters
- string $message optional ''
- The message to output when the assertion fails.
assertOutputNotContains() public ¶
assertOutputNotContains( string $expected , string $message '' )
Asserts stdout
does not contain expected output
Parameters
- string $expected
- Expected output
- string $message optional ''
- Failure message
assertOutputRegExp() public ¶
assertOutputRegExp( string $pattern , string $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
After
commandStringToArgs() protected ¶
commandStringToArgs( string $command )
Creates an $argv array from a command string
Parameters
- string $command
- Command string
Returns
exec() 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
useCommandRunner() public ¶
useCommandRunner( )
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
Properties detail
$_err ¶
Cake\TestSuite\Stub\ConsoleOutput
|PHPUnit_Framework_MockObject_MockObject|null
Console error output stub
$_in ¶
Cake\Console\ConsoleInput
|PHPUnit_Framework_MockObject_MockObject|null
Console input mock
$_out ¶
Cake\TestSuite\Stub\ConsoleOutput
|PHPUnit_Framework_MockObject_MockObject|null
Console output stub