silverstripe-subsites/tests/php/BaseSubsiteTest.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2016-09-22 16:38:29 +02:00
namespace SilverStripe\Subsites\Tests;
use SilverStripe\Core\Config\Config;
2016-09-22 16:38:29 +02:00
use SilverStripe\Dev\SapphireTest;
2017-05-24 15:25:34 +02:00
use SilverStripe\Subsites\Model\Subsite;
use SilverStripe\Subsites\State\SubsiteState;
2017-05-24 15:25:34 +02:00
2017-05-24 15:26:28 +02:00
class BaseSubsiteTest extends SapphireTest
{
protected function setUp()
2017-05-24 15:26:28 +02:00
{
parent::setUp();
SubsiteState::singleton()->setUseSessions(true);
Config::modify()->set(Subsite::class, 'write_hostmap', false);
2017-06-01 15:57:53 +02:00
Subsite::$force_subsite = null;
}
2017-05-24 15:26:28 +02:00
2017-06-01 15:10:07 +02:00
/**
* Avoid subsites filtering on fixture fetching.
* @param string $className
* @param string $identifier
2017-06-01 15:10:07 +02:00
* @return \SilverStripe\ORM\DataObject
*/
protected function objFromFixture($className, $identifier)
2017-06-01 15:57:53 +02:00
{
Subsite::disable_subsite_filter(true);
$obj = parent::objFromFixture($className, $identifier);
2017-06-01 15:57:53 +02:00
Subsite::disable_subsite_filter(false);
2017-05-24 15:26:28 +02:00
return $obj;
}
2017-06-01 15:57:53 +02:00
/**
* Tests the initial state of disable_subsite_filter
*/
public function testDisableSubsiteFilter()
{
$this->assertFalse(Subsite::$disable_subsite_filter);
}
}