silverstripe-subsites/tests/php/SubsiteFunctionalTest.php

43 lines
1.6 KiB
PHP

<?php
namespace SilverStripe\Subsites\Tests;
use Page;
use SilverStripe\Dev\FunctionalTest;
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\View\SSViewer;
class SubsiteFunctionalTest extends FunctionalTest
{
protected static $fixture_file = 'SubsiteTest.yml';
/**
* @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());
$this->assertEquals($subsitePage->SubsiteID, SubsiteState::singleton()->getSubsiteId(), 'Subsite should be changed');
$this->assertEquals(
SSViewer::get_themes(),
$defaultThemes,
'Themes should not be modified when Subsite has no theme defined'
);
$pageWithTheme = $this->objFromFixture(Page::class, 'subsite1_contactus');
$this->get($pageWithTheme->AbsoluteLink());
$subsiteTheme = $pageWithTheme->Subsite()->Theme;
$this->assertEquals($pageWithTheme->SubsiteID, SubsiteState::singleton()->getSubsiteId(), 'Subsite should be changed');
$this->assertEquals(
SSViewer::get_themes(),
array_merge([$subsiteTheme], $defaultThemes),
'Themes should be modified when Subsite has theme defined'
);
}
}