2010-03-21 23:32:22 +01:00
|
|
|
<?php
|
|
|
|
|
2017-04-23 22:23:34 +02:00
|
|
|
namespace SilverStripe\Subsites\Tests;
|
|
|
|
|
2016-09-22 16:38:29 +02:00
|
|
|
use SilverStripe\SiteConfig\SiteConfig;
|
2017-05-24 15:25:34 +02:00
|
|
|
use SilverStripe\Subsites\Extensions\SiteConfigSubsites;
|
2017-05-24 15:26:28 +02:00
|
|
|
use SilverStripe\Subsites\Model\Subsite;
|
|
|
|
|
|
|
|
class SiteConfigSubsitesTest extends BaseSubsiteTest
|
|
|
|
{
|
2017-05-30 15:14:28 +02:00
|
|
|
public static $fixture_file = 'subsites/tests/php/SubsiteTest.yml';
|
2017-05-24 15:26:28 +02:00
|
|
|
|
2017-04-23 22:23:34 +02:00
|
|
|
public function testEachSubsiteHasAUniqueSiteConfig()
|
2017-05-24 15:26:28 +02:00
|
|
|
{
|
|
|
|
$subsite1 = $this->objFromFixture(Subsite::class, 'domaintest1');
|
|
|
|
$subsite2 = $this->objFromFixture(Subsite::class, 'domaintest2');
|
|
|
|
|
2017-05-29 13:42:42 +02:00
|
|
|
$this->assertTrue(is_array(singleton(SiteConfigSubsites::class)->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);
|
2017-05-30 17:58:31 +02:00
|
|
|
$this->assertEquals('RootSite', SiteConfig::current_site_config()->Title);
|
2017-05-29 13:42:42 +02:00
|
|
|
Subsite::changeSubsite($subsite1->ID);
|
2017-05-30 17:58:31 +02:00
|
|
|
$this->assertEquals('Subsite1', SiteConfig::current_site_config()->Title);
|
2017-05-29 13:42:42 +02:00
|
|
|
Subsite::changeSubsite($subsite2->ID);
|
2017-05-30 17:58:31 +02:00
|
|
|
$this->assertEquals('Subsite2', SiteConfig::current_site_config()->Title);
|
2016-09-22 16:38:29 +02:00
|
|
|
|
2017-05-24 15:26:28 +02:00
|
|
|
$keys = SiteConfig::current_site_config()->extend('cacheKeyComponent');
|
|
|
|
$this->assertContains('subsite-' . $subsite2->ID, $keys);
|
|
|
|
}
|
2010-03-21 23:32:22 +01:00
|
|
|
}
|