TEST Empty absolute urls - tests for #3323

This commit is contained in:
Daniel Hensby 2014-07-30 23:22:37 +01:00
parent 37f88c8e1a
commit 04e5c11ed9
2 changed files with 10 additions and 0 deletions

View File

@ -96,6 +96,9 @@ class DirectorTest extends SapphireTest {
$rootURL = Director::protocolAndHost();
$_SERVER['REQUEST_URI'] = "$rootURL/mysite/sub-page/";
Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
//test empty URL
$this->assertEquals($rootURL, Director::absoluteURL(''));
// Test already absolute url
$this->assertEquals($rootURL, Director::absoluteURL($rootURL));
@ -137,6 +140,7 @@ class DirectorTest extends SapphireTest {
Config::inst()->update('Director', 'alternate_base_url', 'http://www.example.org/');
$this->assertEquals('http://www.example.org/', Director::baseURL());
$this->assertEquals('http://www.example.org/', Director::absoluteBaseURL());
$this->assertEquals('http://www.example.org/', Director::absoluteURL(''));
$this->assertEquals('http://www.example.org/subfolder/test', Director::absoluteURL('subfolder/test'));
// Setting it to false restores functionality

View File

@ -161,6 +161,12 @@ class HTTPTest extends SapphireTest {
public function testAbsoluteURLsAttributes() {
$this->withBaseURL('http://www.silverstripe.org/', function($test){
//empty links
$test->assertEquals(
'<a href="http://www.silverstripe.org/">test</a>',
HTTP::absoluteURLs('<a href="">test</a>')
);
// links
$test->assertEquals(
'<a href=\'http://www.silverstripe.org/blog/\'>SS Blog</a>',