mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
35 lines
1.0 KiB
PHP
Executable File
35 lines
1.0 KiB
PHP
Executable File
<?php
|
|
|
|
class DocumentationPermalinksTest extends FunctionalTest {
|
|
|
|
function testSavingAndAccessingMapping() {
|
|
// basic test
|
|
DocumentationPermalinks::add(array(
|
|
'foo' => 'current/en/sapphire/subfolder/foo',
|
|
'bar' => 'current/en/cms/bar'
|
|
));
|
|
|
|
$this->assertEquals('current/en/sapphire/subfolder/foo', DocumentationPermalinks::map('foo'));
|
|
$this->assertEquals('current/en/cms/bar', DocumentationPermalinks::map('bar'));
|
|
}
|
|
|
|
/**
|
|
* Tests to make sure short codes get translated to full paths
|
|
*/
|
|
function testRedirectingMapping() {
|
|
// testing the viewer class but clearer here
|
|
DocumentationPermalinks::add(array(
|
|
'foo' => 'current/en/sapphire/subfolder/foo',
|
|
'bar' => 'current/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('current/en/sapphire/subfolder/foo', $response->getHeader('Location'));
|
|
}
|
|
}
|