From ae092ebf19d8dbf1be1d366f10e63e9d45eb9c56 Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Sat, 14 Apr 2012 18:02:53 +1200 Subject: [PATCH] BUGFIX: ensure E_STRICT compatibility with docsviewer and 3.0 handleRequest(). --- code/controllers/DocumentationViewer.php | 4 ++-- tests/DocumentationPermalinksTest.php | 2 +- tests/DocumentationSearchTest.php | 6 ++--- tests/DocumentationViewerTest.php | 30 ++++++++++++------------ 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index c23953d..fc35fdb 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -127,7 +127,7 @@ class DocumentationViewer extends Controller { * * @return SS_HTTPResponse */ - public function handleRequest(SS_HTTPRequest $request, DataModel $model = null) { + public function handleRequest(SS_HTTPRequest $request, DataModel $model) { // if we submitted a form, let that pass if(!$request->isGET() || isset($_GET['action_results'])) return parent::handleRequest($request); @@ -141,7 +141,7 @@ class DocumentationViewer extends Controller { // if no params passed at all then it's the homepage if(!$firstParam && !$secondParam && !$thirdParam) { - return parent::handleRequest($request); + return parent::handleRequest($request, $model); } if($firstParam) { diff --git a/tests/DocumentationPermalinksTest.php b/tests/DocumentationPermalinksTest.php index 2d7a84c..ec1ac48 100755 --- a/tests/DocumentationPermalinksTest.php +++ b/tests/DocumentationPermalinksTest.php @@ -26,7 +26,7 @@ class DocumentationPermalinksTest extends FunctionalTest { $this->autoFollowRedirection = false; $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'), DataModel::inst()); $this->assertEquals('301', $response->getStatusCode()); $this->assertContains('current/en/sapphire/subfolder/foo', $response->getHeader('Location')); diff --git a/tests/DocumentationSearchTest.php b/tests/DocumentationSearchTest.php index b68c0c4..c11dc35 100755 --- a/tests/DocumentationSearchTest.php +++ b/tests/DocumentationSearchTest.php @@ -30,18 +30,18 @@ class DocumentationSearchTest extends FunctionalTest { function testOpenSearchControllerAccessible() { $c = new DocumentationOpenSearchController(); - $response = $c->handleRequest(new SS_HTTPRequest('GET', '')); + $response = $c->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst()); $this->assertEquals(404, $response->getStatusCode()); // test accessing it when the search isn't active DocumentationSearch::enable(false); - $response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/')); + $response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/'), DataModel::inst()); $this->assertEquals(404, $response->getStatusCode()); // test we get a response to the description. The meta data test will check // that the individual fields are valid but we should check urls are there DocumentationSearch::enable(true); - $response = $c->handleRequest(new SS_HTTPRequest('GET', 'description')); + $response = $c->handleRequest(new SS_HTTPRequest('GET', 'description'), DataModel::inst()); $this->assertEquals(200, $response->getStatusCode()); $desc = new SimpleXMLElement($response->getBody()); diff --git a/tests/DocumentationViewerTest.php b/tests/DocumentationViewerTest.php index 94119f5..035367f 100755 --- a/tests/DocumentationViewerTest.php +++ b/tests/DocumentationViewerTest.php @@ -105,7 +105,7 @@ class DocumentationViewerTest extends FunctionalTest { function testGetModulePagesShort() { $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/'), DataModel::inst()); $pages = $v->getEntityPages(); $arr = $pages->toArray(); @@ -117,7 +117,7 @@ class DocumentationViewerTest extends FunctionalTest { function testGetEntityPages() { $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/subfolder/'), DataModel::inst()); $pages = $v->getEntityPages(); $this->assertEquals( array('sort/', 'subfolder/', 'test.md'), @@ -165,7 +165,7 @@ class DocumentationViewerTest extends FunctionalTest { function testUrlParsing() { // Module index $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/test')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3/test'), DataModel::inst()); $this->assertEquals('2.3', $v->getVersion()); $this->assertEquals('en', $v->getLang()); $this->assertEquals('DocumentationViewerTests', $v->getEntity()->getTitle()); @@ -173,7 +173,7 @@ class DocumentationViewerTest extends FunctionalTest { // Module index without version and language. Should pick up the defaults $v2 = new DocumentationViewer(); - $response = $v2->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/test')); + $response = $v2->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/test'), DataModel::inst()); $this->assertEquals('2.4', $v2->getVersion()); $this->assertEquals('en', $v2->getLang()); @@ -182,7 +182,7 @@ class DocumentationViewerTest extends FunctionalTest { // Overall index $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', '')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst()); $this->assertEquals('', $v->getVersion()); $this->assertEquals('en', $v->getLang()); $this->assertEquals('', $v->module); @@ -192,7 +192,7 @@ class DocumentationViewerTest extends FunctionalTest { function testBreadcrumbs() { // Module index $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'), DataModel::inst()); $crumbs = $v->getBreadcrumbs(); $this->assertEquals(1, $crumbs->Count()); @@ -201,7 +201,7 @@ class DocumentationViewerTest extends FunctionalTest { // Subfolder index $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/'), DataModel::inst()); $crumbs = $v->getBreadcrumbs(); $this->assertEquals(2, $crumbs->Count()); $crumbLinks = $crumbs->column('Link'); @@ -210,7 +210,7 @@ class DocumentationViewerTest extends FunctionalTest { // Subfolder page $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/subpage')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4/subfolder/subpage'), DataModel::inst()); $crumbs = $v->getBreadcrumbs(); $this->assertEquals(3, $crumbs->Count()); $crumbLinks = $crumbs->column('Link'); @@ -221,19 +221,19 @@ class DocumentationViewerTest extends FunctionalTest { function testGetVersion() { $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'), DataModel::inst()); $this->assertEquals('2.4', $v->getVersion()); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/1')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/1'), DataModel::inst()); $this->assertEquals('1', $v->getVersion()); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0'), DataModel::inst()); $this->assertEquals('3.0', $v->getVersion()); } function testGetEntities() { $v = new DocumentationViewer(); - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'), DataModel::inst()); $pages = $v->getEntities(); @@ -251,18 +251,18 @@ class DocumentationViewerTest extends FunctionalTest { $v = new DocumentationViewer(); // the current version is set to 2.4, no notice should be shown on that page - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.4'), DataModel::inst()); $this->assertFalse($v->VersionWarning()); // 2.3 is an older release, hitting that should return us an outdated flag - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/2.3'), DataModel::inst()); $warn = $v->VersionWarning(); $this->assertTrue($warn->OutdatedRelease); $this->assertNull($warn->FutureRelease); // 3.0 is a future release - $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0')); + $response = $v->handleRequest(new SS_HTTPRequest('GET', 'DocumentationViewerTests/en/3.0'), DataModel::inst()); $warn = $v->VersionWarning(); $this->assertNull($warn->OutdatedRelease);