2010-10-22 03:07:49 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
/**
|
|
|
|
* @package docsviewer
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2010-10-22 03:07:49 +02:00
|
|
|
class DocumentationPermalinksTest extends FunctionalTest {
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function testSavingAndAccessingMapping() {
|
2010-10-22 03:07:49 +02:00
|
|
|
// basic test
|
|
|
|
DocumentationPermalinks::add(array(
|
2014-09-15 11:47:45 +02:00
|
|
|
'foo' => 'en/framework/subfolder/foo',
|
|
|
|
'bar' => 'en/cms/bar'
|
2010-10-22 03:07:49 +02:00
|
|
|
));
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals('en/framework/subfolder/foo',
|
|
|
|
DocumentationPermalinks::map('foo')
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals('en/cms/bar',
|
|
|
|
DocumentationPermalinks::map('bar')
|
|
|
|
);
|
2010-10-22 03:07:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-09-15 11:47:45 +02:00
|
|
|
* Tests to make sure short codes get translated to full paths.
|
|
|
|
*
|
2010-10-22 03:07:49 +02:00
|
|
|
*/
|
2014-09-15 11:47:45 +02:00
|
|
|
public function testRedirectingMapping() {
|
2010-10-22 03:07:49 +02:00
|
|
|
DocumentationPermalinks::add(array(
|
2014-09-15 11:47:45 +02:00
|
|
|
'foo' => 'en/framework/subfolder/foo',
|
|
|
|
'bar' => 'en/cms/bar'
|
2010-10-22 03:07:49 +02:00
|
|
|
));
|
|
|
|
|
|
|
|
$this->autoFollowRedirection = false;
|
|
|
|
|
|
|
|
$v = new DocumentationViewer();
|
2012-04-14 08:02:53 +02:00
|
|
|
$response = $v->handleRequest(new SS_HTTPRequest('GET', 'foo'), DataModel::inst());
|
2010-10-22 03:07:49 +02:00
|
|
|
|
|
|
|
$this->assertEquals('301', $response->getStatusCode());
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertContains('en/framework/subfolder/foo', $response->getHeader('Location'));
|
2010-10-22 03:07:49 +02:00
|
|
|
}
|
|
|
|
}
|