2010-03-21 23:32:22 +01:00
|
|
|
<?php
|
|
|
|
|
2016-09-22 16:38:29 +02:00
|
|
|
use SilverStripe\SiteConfig\SiteConfig;
|
|
|
|
|
2013-01-03 14:46:56 +01:00
|
|
|
class SiteConfigSubsitesTest extends BaseSubsiteTest {
|
2010-03-21 23:32:22 +01:00
|
|
|
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
|
|
|
|
|
|
|
function testEachSubsiteHasAUniqueSiteConfig() {
|
|
|
|
$subsite1 = $this->objFromFixture('Subsite', 'domaintest1');
|
|
|
|
$subsite2 = $this->objFromFixture('Subsite', 'domaintest2');
|
|
|
|
|
|
|
|
$this->assertTrue(is_array(singleton('SiteConfigSubsites')->extraStatics()));
|
|
|
|
|
|
|
|
Subsite::changeSubsite(0);
|
|
|
|
$sc = SiteConfig::current_site_config();
|
|
|
|
$sc->Title = 'RootSite';
|
|
|
|
$sc->write();
|
|
|
|
|
|
|
|
Subsite::changeSubsite($subsite1->ID);
|
|
|
|
$sc = SiteConfig::current_site_config();
|
|
|
|
$sc->Title = 'Subsite1';
|
|
|
|
$sc->write();
|
|
|
|
|
|
|
|
Subsite::changeSubsite($subsite2->ID);
|
|
|
|
$sc = SiteConfig::current_site_config();
|
|
|
|
$sc->Title = 'Subsite2';
|
|
|
|
$sc->write();
|
|
|
|
|
|
|
|
Subsite::changeSubsite(0);
|
|
|
|
$this->assertEquals(SiteConfig::current_site_config()->Title, 'RootSite');
|
|
|
|
Subsite::changeSubsite($subsite1->ID);
|
|
|
|
$this->assertEquals(SiteConfig::current_site_config()->Title, 'Subsite1');
|
|
|
|
Subsite::changeSubsite($subsite2->ID);
|
|
|
|
$this->assertEquals(SiteConfig::current_site_config()->Title, 'Subsite2');
|
2013-05-07 05:11:11 +02:00
|
|
|
|
|
|
|
$keys = SiteConfig::current_site_config()->extend('cacheKeyComponent');
|
|
|
|
$this->assertContains('subsite-' . $subsite2->ID, $keys);
|
2010-03-21 23:32:22 +01:00
|
|
|
}
|
2013-05-07 05:11:11 +02:00
|
|
|
|
2010-03-21 23:32:22 +01:00
|
|
|
}
|