2017-06-07 11:57:32 +02:00
|
|
|
<?php
|
|
|
|
|
2017-08-30 01:06:07 +02:00
|
|
|
namespace SilverStripe\Subsites\Tests;
|
2017-06-07 11:57:32 +02:00
|
|
|
|
|
|
|
use Page;
|
|
|
|
use SilverStripe\Dev\FunctionalTest;
|
|
|
|
use SilverStripe\Subsites\Model\Subsite;
|
|
|
|
use SilverStripe\View\SSViewer;
|
|
|
|
|
|
|
|
class SubsiteFunctionalTest extends FunctionalTest
|
|
|
|
{
|
2017-08-29 07:22:32 +02:00
|
|
|
protected static $fixture_file = 'SubsiteTest.yml';
|
2017-06-07 11:57:32 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @todo: remove test from SiteTreeSubsitesTest when this one works. Seems domain lookup is broken atm
|
|
|
|
*/
|
|
|
|
public function testIfSubsiteThemeIsSetToThemeList()
|
|
|
|
{
|
|
|
|
$this->markTestSkipped('doesn\'t work somehow - refactor when domain lookup is working');
|
|
|
|
$defaultThemes = ['default'];
|
|
|
|
SSViewer::set_themes($defaultThemes);
|
|
|
|
|
|
|
|
$subsitePage = $this->objFromFixture(Page::class, 'contact');
|
|
|
|
$this->get($subsitePage->AbsoluteLink());
|
2017-08-30 01:06:07 +02:00
|
|
|
$this->assertEquals($subsitePage->SubsiteID, SubsiteState::singleton()->getSubsiteId(), 'Subsite should be changed');
|
2017-08-29 07:07:24 +02:00
|
|
|
$this->assertEquals(
|
|
|
|
SSViewer::get_themes(),
|
|
|
|
$defaultThemes,
|
|
|
|
'Themes should not be modified when Subsite has no theme defined'
|
|
|
|
);
|
2017-06-07 11:57:32 +02:00
|
|
|
|
|
|
|
$pageWithTheme = $this->objFromFixture(Page::class, 'subsite1_contactus');
|
|
|
|
$this->get($pageWithTheme->AbsoluteLink());
|
|
|
|
$subsiteTheme = $pageWithTheme->Subsite()->Theme;
|
2017-08-30 01:06:07 +02:00
|
|
|
$this->assertEquals($pageWithTheme->SubsiteID, SubsiteState::singleton()->getSubsiteId(), 'Subsite should be changed');
|
2017-08-29 07:07:24 +02:00
|
|
|
$this->assertEquals(
|
|
|
|
SSViewer::get_themes(),
|
|
|
|
array_merge([$subsiteTheme], $defaultThemes),
|
|
|
|
'Themes should be modified when Subsite has theme defined'
|
|
|
|
);
|
2017-06-07 11:57:32 +02:00
|
|
|
}
|
|
|
|
}
|