Navigation Menu

Skip to content

Commit

Permalink
Add a test for #12295
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jun 28, 2018
1 parent 55ee598 commit acc1133
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/TestCase/Routing/Route/RedirectRouteTest.php
Expand Up @@ -14,6 +14,7 @@
*/
namespace Cake\Test\TestCase\Routing\Route;

use Cake\Http\ServerRequest;
use Cake\Routing\Router;
use Cake\Routing\Route\RedirectRoute;
use Cake\TestSuite\TestCase;
Expand Down Expand Up @@ -145,6 +146,26 @@ public function testParsePersist()
$route->parse('/posts/2');
}

/**
* test redirecting with persist and a base directory
*
* @return void
*/
public function testParsePersistBaseDirectory()
{
$request = new ServerRequest([
'base' => '/basedir',
'url' => '/posts/2'
]);
Router::pushRequest($request);

$this->expectException(\Cake\Routing\Exception\RedirectException::class);
$this->expectExceptionMessage('http://localhost/basedir/posts/view/2');
$this->expectExceptionCode(301);
$route = new RedirectRoute('/posts/*', ['controller' => 'posts', 'action' => 'view'], ['persist' => true]);
$route->parse('/posts/2');
}

/**
* test redirecting with persist and string target URLs
*
Expand Down

0 comments on commit acc1133

Please sign in to comment.