From c1a8dc5c089a29999a004a767d9b7babf9361610 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 26 Jun 2017 21:32:49 -0400 Subject: [PATCH 1/4] Document changes in cakephp/cakephp#10777 --- en/appendices/3-5-migration-guide.rst | 2 ++ en/development/testing.rst | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/en/appendices/3-5-migration-guide.rst b/en/appendices/3-5-migration-guide.rst index 018466cdd8..fdc7866e48 100644 --- a/en/appendices/3-5-migration-guide.rst +++ b/en/appendices/3-5-migration-guide.rst @@ -211,6 +211,8 @@ TestSuite * ``IntegrationTestCase::head()`` was added. * ``IntegrationTestCase::options()`` was added. +* ``IntegrationTestCase::disableErrorHandlerMiddleware()`` was added to make + debugging errors easier in integration tests. Validation ---------- diff --git a/en/development/testing.rst b/en/development/testing.rst index 717a4261e5..7bbedd0019 100644 --- a/en/development/testing.rst +++ b/en/development/testing.rst @@ -914,12 +914,17 @@ methods to send a request: * ``put()`` Sends a PUT request. * ``delete()`` Sends a DELETE request. * ``patch()`` Sends a PATCH request. +* ``options()`` Sends an OPTIONS request. +* ``head()`` Sends an OPTIONS request. All of the methods except ``get()`` and ``delete()`` accept a second parameter that allows you to send a request body. After dispatching a request you can use the various assertions provided by ``IntegrationTestCase`` or PHPUnit to ensure your request had the correct side-effects. +.. versionadded:: 3.5.0 + ``options()`` and ``head()`` were added in 3.5.0. + Setting up the Request ---------------------- @@ -1169,6 +1174,26 @@ and make sure our web service is returning the proper response:: We use the ``JSON_PRETTY_PRINT`` option as CakePHP's built in JsonView will use that option when ``debug`` is enabled. +Disabling Error Handling Middleware in Tests +-------------------------------------------- + +When debugging tests that are failing because your application is encountering +errors it can be helpful to temporarily disable the error handling middleware to +allow the underlying error to bubble up. You can use +``disableErrorHandlerMiddleware()`` to do this:: + + public function testGetMissing() + { + $this->disableErrorHandlerMiddleware(); + $this->get('/markers/not-there'); + $this->assertResponseCode(404); + } + +In the above example, the test would fail and the underlying exception message +and stack trace would be displayed instead of the rendered error page being +checked. + +.. versionadded:: 3.5.0 Assertion methods ----------------- From 4a724211c5c0aee087bd25b3d143f7576b0d9397 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 26 Jun 2017 21:35:50 -0400 Subject: [PATCH 2/4] Start documenting changes in console libs. --- en/appendices/3-5-migration-guide.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/en/appendices/3-5-migration-guide.rst b/en/appendices/3-5-migration-guide.rst index fdc7866e48..1375194ef9 100644 --- a/en/appendices/3-5-migration-guide.rst +++ b/en/appendices/3-5-migration-guide.rst @@ -24,6 +24,8 @@ features will continue to function until 4.0.0 after which they will be removed. :ref:`csrf-middleware` instead. * ``Cake\Datasource\TableSchemaInterface`` is deprecated. Use ``Cake\Database\TableSchemaAwareInterface`` instead. +* ``Cake\Console\ShellDispatcher`` is deprecated. Applications should update to + use ``Cake\Console\CommandRunner`` instead. Deprecated Combined Get/Set Methods ----------------------------------- @@ -146,6 +148,10 @@ Console * ``Cake\Console\ConsoleOptionParser::setHelpAlias()`` was added. This method allows you to set the command name used when generating help output. Defaults to ``cake``. +* ``Cake\Console\CommandRunnner`` was added replacing + ``Cake\Console\ShellDispatcher``. +* ``Cake\Console\CommandCollection`` was added to provide an interface for + applications to define the command line tools they offer. Datasource ---------- From 2afd5f4d4ab320b0a1b4630c2fe18a3f3eaba235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 27 Jun 2017 12:53:57 +0200 Subject: [PATCH 3/4] It sends a HEAD request, not a OPTIONS one --- en/development/testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/development/testing.rst b/en/development/testing.rst index 7bbedd0019..03eb53a74c 100644 --- a/en/development/testing.rst +++ b/en/development/testing.rst @@ -915,7 +915,7 @@ methods to send a request: * ``delete()`` Sends a DELETE request. * ``patch()`` Sends a PATCH request. * ``options()`` Sends an OPTIONS request. -* ``head()`` Sends an OPTIONS request. +* ``head()`` Sends an HEAD request. All of the methods except ``get()`` and ``delete()`` accept a second parameter that allows you to send a request body. After dispatching a request you can use From c9c2861d5f17fd44ade0766dcbba960fbbeec2d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=BCrth?= Date: Tue, 27 Jun 2017 12:55:03 +0200 Subject: [PATCH 4/4] Grammar Moar :coffee: ! --- en/development/testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/en/development/testing.rst b/en/development/testing.rst index 03eb53a74c..e0b0d8b318 100644 --- a/en/development/testing.rst +++ b/en/development/testing.rst @@ -915,7 +915,7 @@ methods to send a request: * ``delete()`` Sends a DELETE request. * ``patch()`` Sends a PATCH request. * ``options()`` Sends an OPTIONS request. -* ``head()`` Sends an HEAD request. +* ``head()`` Sends a HEAD request. All of the methods except ``get()`` and ``delete()`` accept a second parameter that allows you to send a request body. After dispatching a request you can use