Trait ConsoleIntegrationTestTrait
A test case class intended to make integration tests of cake console commands easier.
Direct Users
Properties summary
-
$_err
protectedConsole error output stubCake\TestSuite\Stub\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null
-
$_exitCode
protectedLast exit codeinteger|null
-
$_in
protectedConsole input mockCake\Console\ConsoleInput|PHPUnit_Framework_MockObject_MockObject|null
-
$_out
protectedConsole output stubCake\TestSuite\Stub\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null
-
$_useCommandRunner
protectedWhether or not to use the CommandRunnerboolean
Method Summary
- assertErrorContains() publicAsserts
stderr
contains expected output - assertErrorEmpty() publicAsserts that
stderr
is empty - assertErrorRegExp() publicAsserts
stderr
contains expected regexp - assertExitCode() publicAsserts shell exited with the expected code
- assertOutputContains() publicAsserts
stdout
contains expected output - assertOutputContainsRow() protectedCheck that a row of cells exists in the output.
- assertOutputEmpty() publicAsserts that
stdout
is empty - assertOutputNotContains() publicAsserts
stdout
does not contain expected output - assertOutputRegExp() publicAsserts
stdout
contains expected regexp - cleanupConsoleTrait() publicCleans state to get ready for the next test
- commandStringToArgs() protectedCreates an $argv array from a command string
- exec() publicRuns cli integration test
- makeRunner() protectedBuilds the appropriate command dispatcher
- useCommandRunner() public
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
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
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
arrayexec()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
$_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
© 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.7/class-Cake.TestSuite.ConsoleIntegrationTestTrait.html