mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
commit
81d7ef46c5
2 changed files with 45 additions and 0 deletions
|
@ -174,6 +174,20 @@ class Router {
|
|||
return self::$_namedExpressions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resource map getter & setter.
|
||||
*
|
||||
* @param array $resourceMap Resource map
|
||||
* @return mixed
|
||||
* @see Router::$_resourceMap
|
||||
*/
|
||||
public static function resourceMap($resourceMap = null) {
|
||||
if ($resourceMap === null) {
|
||||
return self::$_resourceMap;
|
||||
}
|
||||
self::$_resourceMap = $resourceMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects a new Route in the router.
|
||||
*
|
||||
|
|
|
@ -2454,6 +2454,37 @@ class RouterTest extends CakeTestCase {
|
|||
$this->assertFalse($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests resourceMap as getter and setter.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testResourceMap() {
|
||||
$default = Router::resourceMap();
|
||||
$exepcted = array(
|
||||
array('action' => 'index', 'method' => 'GET', 'id' => false),
|
||||
array('action' => 'view', 'method' => 'GET', 'id' => true),
|
||||
array('action' => 'add', 'method' => 'POST', 'id' => false),
|
||||
array('action' => 'edit', 'method' => 'PUT', 'id' => true),
|
||||
array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
|
||||
array('action' => 'edit', 'method' => 'POST', 'id' => true)
|
||||
);
|
||||
$this->assertEquals($default, $exepcted);
|
||||
|
||||
$custom = array(
|
||||
array('action' => 'index', 'method' => 'GET', 'id' => false),
|
||||
array('action' => 'view', 'method' => 'GET', 'id' => true),
|
||||
array('action' => 'add', 'method' => 'POST', 'id' => false),
|
||||
array('action' => 'edit', 'method' => 'PUT', 'id' => true),
|
||||
array('action' => 'delete', 'method' => 'DELETE', 'id' => true),
|
||||
array('action' => 'update', 'method' => 'POST', 'id' => true)
|
||||
);
|
||||
Router::resourceMap($custom);
|
||||
$this->assertEquals($custom, Router::resourceMap());
|
||||
|
||||
Router::resourceMap($default);
|
||||
}
|
||||
|
||||
/**
|
||||
* test setting redirect routes
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue