Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 17, 2023
2 parents b7cb0cc + 2fe4f94 commit 7b1500c
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 11 deletions.
2 changes: 1 addition & 1 deletion system/Router/DefinedRouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function collect(): Generator
$handler = $view ? '(View) ' . $view : '(Closure)';
}

$routeName = $this->routeCollection->getRoutesOptions($route)['as'] ?? $route;
$routeName = $this->routeCollection->getRoutesOptions($route, $method)['as'] ?? $route;

yield [
'method' => $method,
Expand Down
41 changes: 41 additions & 0 deletions tests/system/Router/DefinedRouteCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,45 @@ public function testCollect()
];
$this->assertSame($expected, $definedRoutes);
}

/**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/8039
*/
public function testCollectSameFromWithDifferentVerb()
{
$routes = $this->createRouteCollection();
$routes->get('login', 'AuthController::showLogin', ['as' => 'loginShow']);
$routes->post('login', 'AuthController::login', ['as' => 'login']);
$routes->get('logout', 'AuthController::logout', ['as' => 'logout']);

$collector = new DefinedRouteCollector($routes);

$definedRoutes = [];

foreach ($collector->collect() as $route) {
$definedRoutes[] = $route;
}

$expected = [
[
'method' => 'get',
'route' => 'login',
'name' => 'loginShow',
'handler' => '\\App\\Controllers\\AuthController::showLogin',
],
[
'method' => 'get',
'route' => 'logout',
'name' => 'logout',
'handler' => '\\App\\Controllers\\AuthController::logout',
],
[
'method' => 'post',
'route' => 'login',
'name' => 'login',
'handler' => '\\App\\Controllers\\AuthController::login',
],
];
$this->assertSame($expected, $definedRoutes);
}
}
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.4.2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Bugs Fixed
production mode or to display backtrace in json when an exception occurred.
- **Forge:** Fixed a bug where adding a Primary Key to an existing table was
ignored if there were no other Keys added too.
- **Routing:** Fixed a bug that ``spark routes`` may show incorrect route names.

See the repo's
`CHANGELOG.md <https://github.com/codeigniter4/CodeIgniter4/blob/develop/CHANGELOG.md>`_
Expand Down
2 changes: 1 addition & 1 deletion user_guide_src/source/installation/upgrade_file_upload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Upgrade Working with Uploaded Files

Documentations
==============
- `Output Class Documentation CodeIgniter 3.X <http://codeigniter.com/userguide3/libraries/file_uploading.html>`_
- `File Uploading Class Documentation CodeIgniter 3.X <http://codeigniter.com/userguide3/libraries/file_uploading.html>`_
- :doc:`Working with Uploaded Files Documentation CodeIgniter 4.X </libraries/uploaded_files>`

What has been changed
Expand Down
15 changes: 10 additions & 5 deletions user_guide_src/source/libraries/curlrequest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ cookie
======

This specifies the filename that CURL should use to read cookie values from, and
to save cookie values to. This is done using the CURL_COOKIEJAR and CURL_COOKIEFILE options.
to save cookie values to. This is done using the ``CURL_COOKIEJAR`` and ``CURL_COOKIEFILE`` options.
An example:

.. literalinclude:: curlrequest/021.php
Expand All @@ -223,8 +223,10 @@ debug
=====

When ``debug`` is passed and set to ``true``, this will enable additional debugging to echo to STDERR during the
script execution. This is done by passing CURLOPT_VERBOSE and echoing the output. So, when you're running a built-in
server via ``spark serve`` you will see the output in the console. Otherwise, the output will be written to
script execution.

This is done by passing ``CURLOPT_VERBOSE`` and echoing the output. So, when you're running a built-in
server via ``spark serve``, you will see the output in the console. Otherwise, the output will be written to
the server's error log.

.. literalinclude:: curlrequest/034.php
Expand Down Expand Up @@ -270,8 +272,11 @@ further headers arrays or calls to ``setHeader()``.
http_errors
===========

By default, CURLRequest will fail if the HTTP code returned is greater than or equal to 400. You can set
``http_errors`` to ``false`` to return the content instead:
By default, CURLRequest will throw ``HTTPException`` if the HTTP code returned is
greater than or equal to 400.

If you want to see the response body, you can set ``http_errors`` to ``false`` to
return the content instead:

.. literalinclude:: curlrequest/026.php

Expand Down
9 changes: 5 additions & 4 deletions user_guide_src/source/libraries/curlrequest/026.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

$client->request('GET', '/status/500');
// Will fail verbosely
// If the response code is 500, an HTTPException is thrown,
// and a detailed error report is displayed if in development mode.

$res = $client->request('GET', '/status/500', ['http_errors' => false]);
echo $res->getStatusCode();
// 500
$response = $client->request('GET', '/status/500', ['http_errors' => false]);
echo $response->getStatusCode(); // 500
echo $response->getBody(); // You can see the response body.
4 changes: 4 additions & 0 deletions user_guide_src/source/testing/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ Removes all mocked classes from the Services class, bringing it back to its orig

You can also use the ``$this->resetServices()`` method that ``CIUnitTestCase`` provides.

.. note:: This method resets the all states of Services, and the ``RouteCollection``
will have no routes. If you want to use your routes to be loaded, you need to
call the ``loadRoutes()`` method like ``Services::routes()->loadRoutes()``.

Services::resetSingle(string $name)
-----------------------------------

Expand Down

0 comments on commit 7b1500c

Please sign in to comment.