W3cubDocs

/CakePHP 4.1

Trait ConsoleIntegrationTestTrait

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

Namespace: Cake\TestSuite

Properties summary

  • $_appArgs protected
    array|null

    The customized application constructor arguments.

  • $_appClass protected
    string|null

    The customized application class name.

  • $_err protected
    \Cake\TestSuite\Stub\ConsoleOutput

    Console error output stub

  • $_exitCode protected
    int|null

    Last exit code

  • $_in protected
    \Cake\Console\ConsoleInput

    Console input mock

  • $_out protected
    \Cake\TestSuite\Stub\ConsoleOutput

    Console output stub

  • $_useCommandRunner protected
    bool

    Whether or not to use the CommandRunner

Method Summary

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(int $expected, string $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(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

commandStringToArgs() protected

commandStringToArgs(string $command)

Creates an $argv array from a command string

Parameters

string $command

Command string

Returns

string[]

configApplication() public

configApplication(string $class, ?array $constructorArgs)

Configure the application class to use in console integration tests.

Parameters

string $class

The application class name.

array|null $constructorArgs

The constructor arguments for your application class.

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

Throws

Cake\TestSuite\Stub\MissingConsoleInputException

RuntimeException

makeRunner() protected

makeRunner()

Builds the appropriate command dispatcher

Returns

\Cake\Console\CommandRunner|\Cake\TestSuite\LegacyCommandRunner

useCommandRunner() public

useCommandRunner()

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

Property Detail

$_appArgs protected

The customized application constructor arguments.

Type

array|null

$_appClass protected

The customized application class name.

Type

string|null

$_err protected

Console error output stub

Type

\Cake\TestSuite\Stub\ConsoleOutput

$_exitCode protected

Last exit code

Type

int|null

$_in protected

Console input mock

Type

\Cake\Console\ConsoleInput

$_out protected

Console output stub

Type

\Cake\TestSuite\Stub\ConsoleOutput

$_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/4.1/trait-Cake.TestSuite.ConsoleIntegrationTestTrait.html