Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions en/appendices/3-5-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------------------------------
Expand Down Expand Up @@ -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
----------
Expand Down Expand Up @@ -211,6 +217,8 @@ TestSuite

* ``IntegrationTestCase::head()`` was added.
* ``IntegrationTestCase::options()`` was added.
* ``IntegrationTestCase::disableErrorHandlerMiddleware()`` was added to make
debugging errors easier in integration tests.

Validation
----------
Expand Down
25 changes: 25 additions & 0 deletions en/development/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 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
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
----------------------

Expand Down Expand Up @@ -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
-----------------
Expand Down