silverstripe-docsviewer/tests/DocumentationPermalinksTest.php
2016-12-02 15:31:18 +13:00

51 lines
1.3 KiB
PHP
Executable File

<?php
/**
* @package docsviewer
* @subpackage tests
*/
class DocumentationPermalinksTest extends FunctionalTest
{
public function testSavingAndAccessingMapping()
{
// basic test
DocumentationPermalinks::add(
array(
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
)
);
$this->assertEquals(
'en/framework/subfolder/foo',
DocumentationPermalinks::map('foo')
);
$this->assertEquals(
'en/cms/bar',
DocumentationPermalinks::map('bar')
);
}
/**
* Tests to make sure short codes get translated to full paths.
*/
public function testRedirectingMapping()
{
DocumentationPermalinks::add(
array(
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
)
);
$this->autoFollowRedirection = false;
$v = new DocumentationViewer();
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'), DataModel::inst());
$this->assertEquals('301', $response->getStatusCode());
$this->assertContains('en/framework/subfolder/foo', $response->getHeader('Location'));
}
}