silverstripe-docsviewer/tests/DocumentationViewerVersionWarningTest.php

95 lines
2.8 KiB
PHP
Raw Normal View History

<?php
/**
* @package docsviewer
* @subpackage tests
*/
2015-11-21 07:25:41 +01:00
class DocumentationViewerVersionWarningTest extends SapphireTest
{
protected $autoFollowRedirection = false;
private $manifest;
2015-11-21 07:25:41 +01:00
public function setUp()
{
parent::setUp();
2015-11-21 07:25:41 +01:00
Config::nest();
2017-08-08 05:50:24 +02:00
// explicitly use dev/docs. Custom paths should be tested separately
2015-11-21 07:25:41 +01:00
Config::inst()->update(
2017-08-08 05:50:24 +02:00
'DocumentationViewer',
'link_base',
'dev/docs'
2015-11-21 07:25:41 +01:00
);
2015-11-21 07:25:41 +01:00
// disable automatic module registration so modules don't interfere.
Config::inst()->update(
2017-08-08 05:50:24 +02:00
'DocumentationManifest',
'automatic_registration',
false
2015-11-21 07:25:41 +01:00
);
2015-11-21 07:25:41 +01:00
Config::inst()->remove('DocumentationManifest', 'register_entities');
2015-11-21 07:25:41 +01:00
Config::inst()->update(
2017-08-08 05:50:24 +02:00
'DocumentationManifest',
'register_entities',
array(
2015-11-21 07:25:41 +01:00
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'
)
)
);
2015-11-21 07:25:41 +01:00
$this->manifest = new DocumentationManifest(true);
}
public function tearDown()
{
parent::tearDown();
Config::unnest();
}
2015-11-21 07:25:41 +01:00
public function testVersionWarning()
{
$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', 'en/testdocs/'), DataModel::inst());
2016-12-02 03:31:18 +01:00
// $this->assertFalse($v->VersionWarning());
2015-11-21 07:25:41 +01:00
// 2.3 is an older release, hitting that should return us an outdated flag
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/2.3/'), DataModel::inst());
$warn = $v->VersionWarning();
2016-12-02 03:31:18 +01:00
// $this->assertTrue($warn->OutdatedRelease);
// $this->assertNull($warn->FutureRelease);
2015-11-21 07:25:41 +01:00
// 3.0 is a future release
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'en/testdocs/3.0/'), DataModel::inst());
$warn = $v->VersionWarning();
2016-12-02 03:31:18 +01:00
// $this->assertNull($warn->OutdatedRelease);
// $this->assertTrue($warn->FutureRelease);
2015-11-21 07:25:41 +01:00
}
}