Browse Source

Merge pull request #8542 from cakephp/router-deprecations

RFC - Deprecate duplicate methods in Router
José Lorenzo Rodríguez 10 years ago
parent
commit
69061571aa
2 changed files with 8 additions and 3 deletions
  1. 3 0
      src/Routing/Router.php
  2. 5 3
      tests/TestCase/Routing/Filter/RoutingFilterTest.php

+ 3 - 0
src/Routing/Router.php

@@ -219,6 +219,7 @@ class Router
      *   shifted into the passed arguments. As well as supplying patterns for routing parameters.
      * @return void
      * @see \Cake\Routing\RouteBuilder::redirect()
+     * @deprecated 3.3.0 Use Router::scope() and RouteBuilder::redirect() instead.
      */
     public static function redirect($route, $url, $options = [])
     {
@@ -279,6 +280,7 @@ class Router
      * @param string|array $controller A controller name or array of controller names (i.e. "Posts" or "ListItems")
      * @param array $options Options to use when generating REST routes
      * @see \Cake\Routing\RouteBuilder::resources()
+     * @deprecated 3.3.0 Use Router::scope() and RouteBuilder::resources() instead.
      * @return void
      */
     public static function mapResources($controller, $options = [])
@@ -798,6 +800,7 @@ class Router
      * @param \Cake\Network\Request $request The request object to modify.
      * @param array $options The array of options.
      * @return \Cake\Network\Request The modified request
+     * @deprecated 3.3.0 Named parameter backwards compatibility will be removed in 4.0.
      */
     public static function parseNamedParams(Request $request, array $options = [])
     {

+ 5 - 3
tests/TestCase/Routing/Filter/RoutingFilterTest.php

@@ -77,8 +77,10 @@ class RoutingFilterTest extends TestCase
      */
     public function testBeforeDispatchRedirectRoute()
     {
-        Router::redirect('/home', ['controller' => 'articles']);
-        Router::connect('/:controller/:action/*');
+        Router::scope('/', function ($routes) {
+            $routes->redirect('/home', ['controller' => 'articles']);
+            $routes->connect('/:controller/:action/*');
+        });
         $filter = new RoutingFilter();
 
         $request = new Request("/home");
@@ -86,7 +88,7 @@ class RoutingFilterTest extends TestCase
         $event = new Event(__CLASS__, $this, compact('request', 'response'));
         $response = $filter->beforeDispatch($event);
         $this->assertInstanceOf('Cake\Network\Response', $response);
-        $this->assertSame('http://localhost/articles/index', $response->header()['Location']);
+        $this->assertSame('http://localhost/articles', $response->header()['Location']);
         $this->assertSame(301, $response->statusCode());
     }