Skip to content
Permalink
Browse files

Fix for #8942 customized redirect route class (#9010)

  • Loading branch information...
burzum authored and markstory committed Jun 21, 2016
1 parent 97e071f commit a0d362f51fdb83a3dd74b4372d2768bae4bf89f1
Showing with 23 additions and 1 deletion.
  1. +1 −1 src/Routing/Router.php
  2. +22 −0 tests/TestCase/Routing/RouterTest.php
@@ -222,7 +222,7 @@ public static function connect($route, $defaults = [], $options = [])
*/
public static function redirect($route, $url, $options = [])
{
$options['routeClass'] = 'Cake\Routing\Route\RedirectRoute';
$options += ['routeClass' => 'Cake\Routing\Route\RedirectRoute'];
if (is_string($url)) {
$url = ['redirect' => $url];
}
@@ -2869,6 +2869,28 @@ public function testRedirect()
$this->assertInstanceOf('Cake\Routing\Route\RedirectRoute', $route);
}
/**
* Test that redirect() works with another route class.
*
* @return void
*/
public function testRedirectWithAnotherRouteClass()
{
$route1 = $this->getMockBuilder('Cake\Routing\Route\RedirectRoute')
->setConstructorArgs(['/mobile\''])
->getMock();
$class = '\\' . get_class($route1);
Router::redirect('/mobile', '/', [
'status' => 301,
'routeClass' => $class
]);
$routes = Router::routes();
$route = $routes[0];
$this->assertInstanceOf($class, $route);
}
/**
* Test that the compatibility method for incoming urls works.
*

0 comments on commit a0d362f

Please sign in to comment.
You can’t perform that action at this time.