A test case class intended to make integration tests of cake console commands easier.
array|null
The customized application constructor arguments.
string|null
The customized application class name.
\Cake\TestSuite\Stub\ConsoleOutput
Console error output stub
int|null
Last exit code
\Cake\Console\ConsoleInput
Console input mock
\Cake\TestSuite\Stub\ConsoleOutput
Console output stub
bool
Whether or not to use the CommandRunner
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
assertErrorContains(string $expected, string $message)
Asserts stderr
contains expected output
string
$expected Expected output
string
$message optional Failure message
assertErrorEmpty(string $message)
Asserts that stderr
is empty
string
$message optional The message to output when the assertion fails.
assertErrorRegExp(string $pattern, string $message)
Asserts stderr
contains expected regexp
string
$pattern Expected pattern
string
$message optional Failure message
assertExitCode(int $expected, string $message)
Asserts shell exited with the expected code
int
$expected Expected exit code
string
$message optional Failure message
assertExitError(mixed $message)
Asserts shell exited with Command::CODE_ERROR
string
$message optional Failure message
assertExitSuccess(mixed $message)
Asserts shell exited with the Command::CODE_SUCCESS
string
$message optional Failure message
assertOutputContains(string $expected, string $message)
Asserts stdout
contains expected output
string
$expected Expected output
string
$message optional Failure message
assertOutputContainsRow(array $row, string $message)
Check that a row of cells exists in the output.
array
$row Row of cells to ensure exist in the output.
string
$message optional Failure message.
assertOutputEmpty(string $message)
Asserts that stdout
is empty
string
$message optional The message to output when the assertion fails.
assertOutputNotContains(string $expected, string $message)
Asserts stdout
does not contain expected output
string
$expected Expected output
string
$message optional Failure message
assertOutputRegExp(string $pattern, string $message)
Asserts stdout
contains expected regexp
string
$pattern Expected pattern
string
$message optional Failure message
cleanupConsoleTrait()
Cleans state to get ready for the next test
commandStringToArgs(string $command)
Creates an $argv array from a command string
string
$command Command string
string[]
configApplication(string $class, ?array $constructorArgs)
Configure the application class to use in console integration tests.
string
$class The application class name.
array|null
$constructorArgs The constructor arguments for your application class.
exec(string $command, array $input)
Runs CLI integration test
string
$command Command to run
array
$input optional Input values to pass to an interactive shell
Cake\TestSuite\Stub\MissingConsoleInputException
RuntimeException
makeRunner()
Builds the appropriate command dispatcher
\Cake\Console\CommandRunner|\Cake\TestSuite\LegacyCommandRunner
useCommandRunner()
Set this test case to use the CommandRunner rather than the legacy ShellDispatcher
The customized application constructor arguments.
array|null
The customized application class name.
string|null
Console error output stub
\Cake\TestSuite\Stub\ConsoleOutput
Last exit code
int|null
Console input mock
\Cake\Console\ConsoleInput
Console output stub
\Cake\TestSuite\Stub\ConsoleOutput
Whether or not to use the CommandRunner
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/4.1/trait-Cake.TestSuite.ConsoleIntegrationTestTrait.html