Skip to content
Open
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
30 changes: 2 additions & 28 deletions system/Test/FeatureTestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,7 @@ protected function withRoutes(?array $routes = null)
$collection->resetRoutes();

foreach ($routes as $route) {
if ($route[0] === strtolower($route[0])) {
@trigger_error(
'Passing lowercase HTTP method "' . $route[0] . '" is deprecated.'
. ' Use uppercase HTTP method like "' . strtoupper($route[0]) . '".',
E_USER_DEPRECATED,
);
}

/**
* @TODO For backward compatibility. Remove strtolower() in the future.
* @deprecated 4.5.0
*/
$method = strtolower($route[0]);
$method = strtolower($route[0]); // convert to method of RouteCollection

if (isset($route[3])) {
$collection->{$method}($route[1], $route[2], $route[3]);
Expand Down Expand Up @@ -173,26 +161,12 @@ public function skipEvents()
* Calls a single URI, executes it, and returns a TestResponse
* instance that can be used to run many assertions against.
*
* @param string $method HTTP verb
* @param uppercase-string $method HTTP verb
*
* @return TestResponse
*/
public function call(string $method, string $path, ?array $params = null)
{
if ($method === strtolower($method)) {
@trigger_error(
'Passing lowercase HTTP method "' . $method . '" is deprecated.'
. ' Use uppercase HTTP method like "' . strtoupper($method) . '".',
E_USER_DEPRECATED,
);
}

/**
* @deprecated 4.5.0
* @TODO remove this in the future.
*/
$method = strtoupper($method);

// Simulate having a blank session
$_SESSION = [];
service('superglobals')->setServer('REQUEST_METHOD', $method);
Expand Down
3 changes: 3 additions & 0 deletions user_guide_src/source/changelogs/v4.8.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Behavior Changes
- **Commands:** The ``filter:check`` command now requires the HTTP method argument to be uppercase (e.g., ``spark filter:check GET /`` instead of ``spark filter:check get /``).
- **Filters:** HTTP method matching for method-based filters is now case-sensitive. The keys in ``Config\Filters::$methods`` must exactly match the request method
(e.g., ``GET``, ``POST``). Lowercase method names (e.g., ``post``) will no longer match.
- **Testing:** Tests using the ``FeatureTestTrait`` must now use uppercase HTTP method names when performing a request when using the ``call()`` method directly
(e.g., ``$this->call('GET', '/path')`` instead of ``$this->call('get', '/path')``). Additionally, setting method-based routes using ``withRoutes()`` must
also use uppercase method names (e.g., ``$this->withRoutes([['GET', 'home', 'Home::index']])``).

Interface Changes
=================
Expand Down
4 changes: 2 additions & 2 deletions user_guide_src/source/testing/feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Requesting a Page
Essentially, feature tests simply allows you to call an endpoint on your application and get the results back.
To do this, you use the ``call()`` method.

1. The first parameter is the HTTP method to use (most frequently either ``GET`` or ``POST``).
1. The first parameter is the uppercase HTTP method to use (most frequently either ``GET`` or ``POST``).
2. The second parameter is the URI path on your site to test.
3. The third parameter ``$params`` accepts an array that is used to populate the
superglobal variables for the HTTP verb you are using. So, a method of **GET**
Expand Down Expand Up @@ -60,7 +60,7 @@ override any existing routes in the system:
.. literalinclude:: feature/004.php
:lines: 2-

Each of the "routes" is a 3 element array containing the HTTP verb (or "add" for all),
Each of the "routes" is a 3 element array containing the uppercase HTTP verb (or "add" for all),
the URI to match, and the routing destination.

.. _feature-setting-session-values:
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/testing/feature/002.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$result = $this->call('GET', '/');

// Submit a form
$result = $this->call('post', 'contact', [
$result = $this->call('POST', 'contact', [
'name' => 'Fred Flintstone',
'email' => 'flintyfred@example.com',
]);
Loading