Skip to content
Permalink
Browse files

Fix error in Router::redirect().

Type warnings would be emitted when redirect() was called with a string
target.
  • Loading branch information...
markstory committed Jun 29, 2014
1 parent 982b696 commit 74c7273d95f22c90d62955130569cf246c321ade
Showing with 15 additions and 0 deletions.
  1. +3 −0 src/Routing/Router.php
  2. +12 −0 tests/TestCase/Routing/RouterTest.php
@@ -361,6 +361,9 @@ public static function connect($route, $defaults = [], $options = []) {
*/
public static function redirect($route, $url, $options = []) {
$options['routeClass'] = 'Cake\Routing\Route\RedirectRoute';
if (is_string($url)) {
$url = ['redirect' => $url];
}
return static::connect($route, $url, $options);
}
@@ -2676,6 +2676,18 @@ public function testPatternOnAction() {
$this->assertFalse($result);
}
/**
* Test that redirect() works.
*
* @return void
*/
public function testRedirect() {
Router::redirect('/mobile', '/', ['status' => 301]);
$scope = Router::scope('/');
$route = $scope->routes()[0];
$this->assertInstanceOf('Cake\Routing\Route\RedirectRoute', $route);
}
/**
* Tests resourceMap as getter and setter.
*

0 comments on commit 74c7273

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