2014-09-07 07:09:28 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
/**
|
|
|
|
* @package docsviewer
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2014-09-07 07:09:28 +02:00
|
|
|
class DocumentationViewerVersionWarningTest extends SapphireTest {
|
|
|
|
|
|
|
|
protected $autoFollowRedirection = false;
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
private $manifest;
|
2014-09-07 07:09:28 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
Config::nest();
|
|
|
|
|
|
|
|
// explicitly use dev/docs. Custom paths should be tested separately
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationViewer', 'link_base', 'dev/docs'
|
|
|
|
);
|
|
|
|
|
|
|
|
// disable automatic module registration so modules don't interfere.
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'automatic_registration', false
|
|
|
|
);
|
|
|
|
|
|
|
|
Config::inst()->remove('DocumentationManifest', 'register_entities');
|
|
|
|
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'register_entities', array(
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Version' => '2.3'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-v2.4/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Version' => '2.4',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Stable' => true
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-v3.0/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Version' => '3.0'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->manifest = new DocumentationManifest(true);
|
2014-09-07 07:09:28 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2014-09-07 07:09:28 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::unnest();
|
2014-09-07 07:09:28 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testVersionWarning() {
|
|
|
|
$v = new DocumentationViewer();
|
|
|
|
|
|
|
|
// the current version is set to 2.4, no notice should be shown on that page
|
2014-09-15 11:47:45 +02:00
|
|
|
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/'), DataModel::inst());
|
2014-09-07 07:09:28 +02:00
|
|
|
$this->assertFalse($v->VersionWarning());
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2014-09-07 07:09:28 +02:00
|
|
|
|
|
|
|
// 2.3 is an older release, hitting that should return us an outdated flag
|
2014-09-15 11:47:45 +02:00
|
|
|
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/2.3/'), DataModel::inst());
|
2014-09-07 07:09:28 +02:00
|
|
|
$warn = $v->VersionWarning();
|
|
|
|
|
|
|
|
$this->assertTrue($warn->OutdatedRelease);
|
|
|
|
$this->assertNull($warn->FutureRelease);
|
|
|
|
|
|
|
|
// 3.0 is a future release
|
2014-09-15 11:47:45 +02:00
|
|
|
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/3.0/'), DataModel::inst());
|
2014-09-07 07:09:28 +02:00
|
|
|
$warn = $v->VersionWarning();
|
|
|
|
|
|
|
|
$this->assertNull($warn->OutdatedRelease);
|
|
|
|
$this->assertTrue($warn->FutureRelease);
|
|
|
|
}
|
|
|
|
}
|