BUGFIX: ensure E_STRICT compatibility with docsviewer and 3.0 handleRequest().

This commit is contained in:
Will Rossiter 2012-04-14 18:02:53 +12:00
parent dd84574b8d
commit ae092ebf19
4 changed files with 21 additions and 21 deletions

View File

@ -127,7 +127,7 @@ class DocumentationViewer extends Controller {
* *
* @return SS_HTTPResponse * @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 we submitted a form, let that pass
if(!$request->isGET() || isset($_GET['action_results'])) if(!$request->isGET() || isset($_GET['action_results']))
return parent::handleRequest($request); return parent::handleRequest($request);
@ -141,7 +141,7 @@ class DocumentationViewer extends Controller {
// if no params passed at all then it's the homepage // if no params passed at all then it's the homepage
if(!$firstParam && !$secondParam && !$thirdParam) { if(!$firstParam && !$secondParam && !$thirdParam) {
return parent::handleRequest($request); return parent::handleRequest($request, $model);
} }
if($firstParam) { if($firstParam) {

View File

@ -26,7 +26,7 @@ class DocumentationPermalinksTest extends FunctionalTest {
$this->autoFollowRedirection = false; $this->autoFollowRedirection = false;
$v = new DocumentationViewer(); $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->assertEquals('301', $response->getStatusCode());
$this->assertContains('current/en/sapphire/subfolder/foo', $response->getHeader('Location')); $this->assertContains('current/en/sapphire/subfolder/foo', $response->getHeader('Location'));

View File

@ -30,18 +30,18 @@ class DocumentationSearchTest extends FunctionalTest {
function testOpenSearchControllerAccessible() { function testOpenSearchControllerAccessible() {
$c = new DocumentationOpenSearchController(); $c = new DocumentationOpenSearchController();
$response = $c->handleRequest(new SS_HTTPRequest('GET', '')); $response = $c->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
$this->assertEquals(404, $response->getStatusCode()); $this->assertEquals(404, $response->getStatusCode());
// test accessing it when the search isn't active // test accessing it when the search isn't active
DocumentationSearch::enable(false); 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()); $this->assertEquals(404, $response->getStatusCode());
// test we get a response to the description. The meta data test will check // 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 // that the individual fields are valid but we should check urls are there
DocumentationSearch::enable(true); 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()); $this->assertEquals(200, $response->getStatusCode());
$desc = new SimpleXMLElement($response->getBody()); $desc = new SimpleXMLElement($response->getBody());

View File

@ -105,7 +105,7 @@ class DocumentationViewerTest extends FunctionalTest {
function testGetModulePagesShort() { function testGetModulePagesShort() {
$v = new DocumentationViewer(); $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(); $pages = $v->getEntityPages();
$arr = $pages->toArray(); $arr = $pages->toArray();
@ -117,7 +117,7 @@ class DocumentationViewerTest extends FunctionalTest {
function testGetEntityPages() { function testGetEntityPages() {
$v = new DocumentationViewer(); $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(); $pages = $v->getEntityPages();
$this->assertEquals( $this->assertEquals(
array('sort/', 'subfolder/', 'test.md'), array('sort/', 'subfolder/', 'test.md'),
@ -165,7 +165,7 @@ class DocumentationViewerTest extends FunctionalTest {
function testUrlParsing() { function testUrlParsing() {
// Module index // Module index
$v = new DocumentationViewer(); $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('2.3', $v->getVersion());
$this->assertEquals('en', $v->getLang()); $this->assertEquals('en', $v->getLang());
$this->assertEquals('DocumentationViewerTests', $v->getEntity()->getTitle()); $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 // Module index without version and language. Should pick up the defaults
$v2 = new DocumentationViewer(); $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('2.4', $v2->getVersion());
$this->assertEquals('en', $v2->getLang()); $this->assertEquals('en', $v2->getLang());
@ -182,7 +182,7 @@ class DocumentationViewerTest extends FunctionalTest {
// Overall index // Overall index
$v = new DocumentationViewer(); $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('', $v->getVersion());
$this->assertEquals('en', $v->getLang()); $this->assertEquals('en', $v->getLang());
$this->assertEquals('', $v->module); $this->assertEquals('', $v->module);
@ -192,7 +192,7 @@ class DocumentationViewerTest extends FunctionalTest {
function testBreadcrumbs() { function testBreadcrumbs() {
// Module index // Module index
$v = new DocumentationViewer(); $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(); $crumbs = $v->getBreadcrumbs();
$this->assertEquals(1, $crumbs->Count()); $this->assertEquals(1, $crumbs->Count());
@ -201,7 +201,7 @@ class DocumentationViewerTest extends FunctionalTest {
// Subfolder index // Subfolder index
$v = new DocumentationViewer(); $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(); $crumbs = $v->getBreadcrumbs();
$this->assertEquals(2, $crumbs->Count()); $this->assertEquals(2, $crumbs->Count());
$crumbLinks = $crumbs->column('Link'); $crumbLinks = $crumbs->column('Link');
@ -210,7 +210,7 @@ class DocumentationViewerTest extends FunctionalTest {
// Subfolder page // Subfolder page
$v = new DocumentationViewer(); $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(); $crumbs = $v->getBreadcrumbs();
$this->assertEquals(3, $crumbs->Count()); $this->assertEquals(3, $crumbs->Count());
$crumbLinks = $crumbs->column('Link'); $crumbLinks = $crumbs->column('Link');
@ -221,19 +221,19 @@ class DocumentationViewerTest extends FunctionalTest {
function testGetVersion() { function testGetVersion() {
$v = new DocumentationViewer(); $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()); $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()); $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()); $this->assertEquals('3.0', $v->getVersion());
} }
function testGetEntities() { function testGetEntities() {
$v = new DocumentationViewer(); $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(); $pages = $v->getEntities();
@ -251,18 +251,18 @@ class DocumentationViewerTest extends FunctionalTest {
$v = new DocumentationViewer(); $v = new DocumentationViewer();
// the current version is set to 2.4, no notice should be shown on that page // 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()); $this->assertFalse($v->VersionWarning());
// 2.3 is an older release, hitting that should return us an outdated flag // 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(); $warn = $v->VersionWarning();
$this->assertTrue($warn->OutdatedRelease); $this->assertTrue($warn->OutdatedRelease);
$this->assertNull($warn->FutureRelease); $this->assertNull($warn->FutureRelease);
// 3.0 is a future release // 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(); $warn = $v->VersionWarning();
$this->assertNull($warn->OutdatedRelease); $this->assertNull($warn->OutdatedRelease);