silverstripe-docsviewer/tests/DocumentationPermalinksTest...

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
* @package docsviewer
* @subpackage tests
*/
2015-11-21 07:25:41 +01:00
class DocumentationPermalinksTest extends FunctionalTest
{
public function testSavingAndAccessingMapping()
{
// basic test
2016-12-02 03:31:18 +01:00
DocumentationPermalinks::add(
array(
2015-11-21 07:25:41 +01:00
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
2016-12-02 03:31:18 +01:00
)
);
2015-11-21 07:25:41 +01:00
2016-12-02 03:31:18 +01:00
$this->assertEquals(
'en/framework/subfolder/foo',
2015-11-21 07:25:41 +01:00
DocumentationPermalinks::map('foo')
);
2016-12-02 03:31:18 +01:00
$this->assertEquals(
'en/cms/bar',
2015-11-21 07:25:41 +01:00
DocumentationPermalinks::map('bar')
);
}
/**
* Tests to make sure short codes get translated to full paths.
*/
public function testRedirectingMapping()
{
2016-12-02 03:31:18 +01:00
DocumentationPermalinks::add(
array(
2015-11-21 07:25:41 +01:00
'foo' => 'en/framework/subfolder/foo',
'bar' => 'en/cms/bar'
2016-12-02 03:31:18 +01:00
)
);
2015-11-21 07:25:41 +01:00
$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'));
}
}