Permalink
Browse files

New test for old URL redirection

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65782 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent f11d7cc commit 8da5af457ef13e2e438fe2f36adbc5b3b71b376a @sminnee sminnee committed Nov 13, 2008
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/control/ModelAsControllerTest.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @package sapphire
+ * @subpackage tests
+ */
+class ModelAsControllerTest extends SapphireTest {
+
+ public function testFindOldPage() {
+ $page = new Page();
+ $page->Title = 'Test Page';
+ $page->URLSegment = 'test-page';
+ $page->write();
+ $page->publish('Stage', 'Live');
+
+ $page->URLSegment = 'test';
+ $page->write();
+ $page->publish('Stage', 'Live');
+
+ $router = new ModelAsController();
+ $request = new HTTPRequest(
+ 'GET', 'test-page/action/id/otherid'
+ );
+ $request->match('$URLSegment/$Action/$ID/$OtherID');
+ $response = $router->handleRequest($request);
+
+ $this->assertEquals (
+ $response->getHeader('Location'),
+ Controller::join_links(Director::baseURL() . 'test/action/id/otherid')
+ );
+ }
+
+}

0 comments on commit 8da5af4

Please sign in to comment.