From 807ba2dc2be44a560b6c863ffa5131d3ba4510cd Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 30 Oct 2024 00:19:16 -0400 Subject: [PATCH 1/2] Add docs for debugOutput() Refs cakephp/cakephp#17997 --- en/appendices/5-2-migration-guide.rst | 2 ++ en/console-commands/commands.rst | 18 ++++++++++++++---- en/console-commands/schema-cache.rst | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index 69a6d9760b..200527cfe9 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -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 comands. ORM --- diff --git a/en/console-commands/commands.rst b/en/console-commands/commands.rst index 429a048f22..9493a24b5c 100644 --- a/en/console-commands/commands.rst +++ b/en/console-commands/commands.rst @@ -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**:: @@ -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 =================== diff --git a/en/console-commands/schema-cache.rst b/en/console-commands/schema-cache.rst index 90a24b690a..df891ab6a5 100644 --- a/en/console-commands/schema-cache.rst +++ b/en/console-commands/schema-cache.rst @@ -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: From 2383eac794ec8971e567ddc63d2cdf8a461f8d29 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Wed, 30 Oct 2024 09:29:06 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Mark Scherer --- en/appendices/5-2-migration-guide.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/appendices/5-2-migration-guide.rst b/en/appendices/5-2-migration-guide.rst index 200527cfe9..92ce571d86 100644 --- a/en/appendices/5-2-migration-guide.rst +++ b/en/appendices/5-2-migration-guide.rst @@ -23,7 +23,7 @@ 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 comands. + integration tests for console commands. ORM ---