mirror of
https://github.com/codeigniter4/CodeIgniter4.git
synced 2025-02-20 11:44:28 +08:00
Test routes resource with 'websafe' option
This commit is contained in:
parent
4594b8e044
commit
a1d03e04cb
@ -436,7 +436,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
|
||||
/**
|
||||
* Sets the default constraint to be used in the system. Typically
|
||||
* for use with the 'resources' method.
|
||||
* for use with the 'resource' method.
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
@ -722,7 +722,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
* Example:
|
||||
* // Creates route: admin/users
|
||||
* $route->group('admin', function() {
|
||||
* $route->resources('users');
|
||||
* $route->resource('users');
|
||||
* });
|
||||
*
|
||||
* @param string $name The name to group/prefix the routes with.
|
||||
@ -777,7 +777,7 @@ class RouteCollection implements RouteCollectionInterface
|
||||
* 'placeholder' - The regex used by the Router. Defaults to '(:any)'
|
||||
*
|
||||
* Example:
|
||||
* $route->resources('photos');
|
||||
* $route->resource('photos');
|
||||
*
|
||||
* // Generates the following routes:
|
||||
* HTTP Verb | Path | Action | Used for...
|
||||
@ -864,8 +864,8 @@ class RouteCollection implements RouteCollectionInterface
|
||||
if (in_array('update', $methods))
|
||||
{
|
||||
$this->put($name . '/' . $id, $new_name . '::update/$1', $options);
|
||||
}
|
||||
$this->patch($name . '/' . $id, $new_name . '::update/$1', $options);
|
||||
}
|
||||
if (in_array('delete', $methods))
|
||||
{
|
||||
$this->delete($name . '/' . $id, $new_name . '::delete/$1', $options);
|
||||
|
@ -458,6 +458,24 @@ class RouteCollectionTest extends \CIUnitTestCase
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
public function testResourcesWithWebsafe()
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$routes = $this->getCollector();
|
||||
|
||||
$routes->resource('photos', ['websafe' => true]);
|
||||
|
||||
$expected = [
|
||||
'photos' => '\Photos::create',
|
||||
'photos/(.*)' => '\Photos::update/$1',
|
||||
'photos/(.*)/delete' => '\Photos::delete/$1',
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $routes->getRoutes());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------
|
||||
|
||||
public function testMatchSupportsMultipleMethods()
|
||||
{
|
||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||
|
Loading…
x
Reference in New Issue
Block a user