mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
TEST Empty absolute urls - tests for #3323
This commit is contained in:
parent
37f88c8e1a
commit
04e5c11ed9
@ -96,6 +96,9 @@ class DirectorTest extends SapphireTest {
|
|||||||
$rootURL = Director::protocolAndHost();
|
$rootURL = Director::protocolAndHost();
|
||||||
$_SERVER['REQUEST_URI'] = "$rootURL/mysite/sub-page/";
|
$_SERVER['REQUEST_URI'] = "$rootURL/mysite/sub-page/";
|
||||||
Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
|
Config::inst()->update('Director', 'alternate_base_url', '/mysite/');
|
||||||
|
|
||||||
|
//test empty URL
|
||||||
|
$this->assertEquals($rootURL, Director::absoluteURL(''));
|
||||||
|
|
||||||
// Test already absolute url
|
// Test already absolute url
|
||||||
$this->assertEquals($rootURL, Director::absoluteURL($rootURL));
|
$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/');
|
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::baseURL());
|
||||||
$this->assertEquals('http://www.example.org/', Director::absoluteBaseURL());
|
$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'));
|
$this->assertEquals('http://www.example.org/subfolder/test', Director::absoluteURL('subfolder/test'));
|
||||||
|
|
||||||
// Setting it to false restores functionality
|
// Setting it to false restores functionality
|
||||||
|
@ -161,6 +161,12 @@ class HTTPTest extends SapphireTest {
|
|||||||
public function testAbsoluteURLsAttributes() {
|
public function testAbsoluteURLsAttributes() {
|
||||||
$this->withBaseURL('http://www.silverstripe.org/', function($test){
|
$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
|
// links
|
||||||
$test->assertEquals(
|
$test->assertEquals(
|
||||||
'<a href=\'http://www.silverstripe.org/blog/\'>SS Blog</a>',
|
'<a href=\'http://www.silverstripe.org/blog/\'>SS Blog</a>',
|
||||||
|
Loading…
Reference in New Issue
Block a user