mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
99c1fe9f93
BUGFIX Limiting RootURLController to just trigger Translatable if no DomainForHomepage value is found BUGFIX Using $locale parameter in Translatable::get_homepage_urlsegment_by_locale() BUGFIX Updated enabling mechanism in Translatable->alternateGetByUrl() MINOR Removed HTTP_HOST setting in TranslatableTest, wasn't necessary API CHANGE Deprecated Translatable::get_homepage_urlsegment_by_language(), use get_homepage_urlsegment_by_locale() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@75328 467b73ca-7a2a-4603-9d3b-597d59a354a9
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage tests
|
|
*/
|
|
class RootURLControllerTest extends SapphireTest {
|
|
static $fixture_file = 'sapphire/tests/control/RootURLControllerTest.yml';
|
|
|
|
function testHomepageForDomain() {
|
|
$originalHost = $_SERVER['HTTP_HOST'];
|
|
|
|
// Tests matching an HTTP_HOST value to URLSegment homepage values
|
|
$tests = array(
|
|
'page.co.nz' => 'page1',
|
|
'www.page.co.nz' => 'page1',
|
|
'help.com' => 'page1',
|
|
'www.help.com' => 'page1',
|
|
'something.com' => 'page1',
|
|
'www.something.com' => 'page1',
|
|
|
|
'other.co.nz' => 'page2',
|
|
'www.other.co.nz' => 'page2',
|
|
'right' => 'page2',
|
|
'www. right' => 'page2',
|
|
|
|
'only.com' => 'page3',
|
|
'www.only.com' => 'page3',
|
|
|
|
'www.somethingelse.com' => 'home',
|
|
'somethingelse.com' => 'home',
|
|
|
|
// Test some potential false matches to page2 and page3
|
|
'alternate.only.com' => 'home',
|
|
'www.alternate.only.com' => 'home',
|
|
'alternate.something.com' => 'home',
|
|
);
|
|
|
|
foreach($tests as $domain => $urlSegment) {
|
|
$_SERVER['HTTP_HOST'] = $domain;
|
|
$this->assertEquals(
|
|
$urlSegment,
|
|
RootURLController::get_homepage_urlsegment(Translatable::default_locale()),
|
|
"Testing $domain matches $urlSegment"
|
|
);
|
|
}
|
|
|
|
$_SERVER['HTTP_HOST'] = $originalHost;
|
|
}
|
|
} |