Skip to content

Commit

Permalink
Merge pull request #7943 from cakephp/console-debug
Browse files Browse the repository at this point in the history
Add docs for debugOutput()
  • Loading branch information
markstory authored Oct 30, 2024
2 parents c9d2a6e + 2383eac commit a53c785
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions en/appendices/5-2-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Console

- The ``cake counter_cache`` command was added. This command can be used to
regenerate counters for models that use ``CounterCacheBehavior``.
- ``ConsoleIntegrationTestTrait::debugOutput()`` makes it easier to debug
integration tests for console commands.

ORM
---
Expand Down
18 changes: 14 additions & 4 deletions en/console-commands/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ To get started testing your console application, create a test case that uses th
``exec()`` that is used to execute your command. You can pass the same string
you would use in the CLI to this method.

.. note::

For CakePHP 4.4 onwards the ``Cake\Console\TestSuite\ConsoleIntegrationTestTrait`` namespace should be used.

Let's start with a very simple command, located in
**src/Command/UpdateTableCommand.php**::

Expand Down Expand Up @@ -549,6 +545,20 @@ assertion methods that make help assert against console output::
// assert that stderr matches a regular expression
$this->assertErrorRegExp($expected);

Debug Helpers
-------------

You can use ``debugOutput()`` to output the exit code, stdout and stderr of the
last run command::

$this->exec('update_table Users');
$this->assertExitCode(Command::CODE_SUCCESS);
$this->debugOutput();

.. versionadded:: 4.2.0
The ``debugOutput()`` method was added.


Lifecycle Callbacks
===================

Expand Down
2 changes: 1 addition & 1 deletion en/console-commands/schema-cache.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Schema Cache Tool
#################

The SchemaCacheShell provides a simple CLI tool for managing your application's
The SchemaCacheCommand provides a simple CLI tool for managing your application's
metadata caches. In deployment situations it is helpful to rebuild the metadata
cache in-place without clearing the existing cache data. You can do this by
running:
Expand Down

0 comments on commit a53c785

Please sign in to comment.