mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
46 lines
1.2 KiB
PHP
Executable File
46 lines
1.2 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'));
|
|
}
|
|
}
|