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