BUG Prevent translatable / subdirs interfering with test state

This commit is contained in:
Damian Mooyman 2016-08-23 12:36:12 +12:00
parent 7c97a8ae74
commit 0e61dfc3f6
3 changed files with 20 additions and 10 deletions

View File

@ -13,9 +13,12 @@ class FileSubsitesTest extends BaseSubsiteTest
'File' => array( 'File' => array(
'SecureFileExtension', 'SecureFileExtension',
'VersionedFileExtension' 'VersionedFileExtension'
) ),
'SiteTree' => array(
'Translatable',
)
); );
public function testTrivialFeatures() public function testTrivialFeatures()
{ {
$this->assertTrue(is_array(singleton('FileSubsites')->extraStatics())); $this->assertTrue(is_array(singleton('FileSubsites')->extraStatics()));
@ -29,35 +32,35 @@ class FileSubsitesTest extends BaseSubsiteTest
Subsite::changeSubsite(1); Subsite::changeSubsite(1);
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1'); $this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
} }
public function testWritingSubsiteID() public function testWritingSubsiteID()
{ {
$this->objFromFixture('Member', 'admin')->logIn(); $this->objFromFixture('Member', 'admin')->logIn();
$subsite = $this->objFromFixture('Subsite', 'domaintest1'); $subsite = $this->objFromFixture('Subsite', 'domaintest1');
FileSubsites::$default_root_folders_global = true; FileSubsites::$default_root_folders_global = true;
Subsite::changeSubsite(0); Subsite::changeSubsite(0);
$file = new File(); $file = new File();
$file->write(); $file->write();
$file->onAfterUpload(); $file->onAfterUpload();
$this->assertEquals((int)$file->SubsiteID, 0); $this->assertEquals((int)$file->SubsiteID, 0);
Subsite::changeSubsite($subsite->ID); Subsite::changeSubsite($subsite->ID);
$this->assertTrue($file->canEdit()); $this->assertTrue($file->canEdit());
$file = new File(); $file = new File();
$file->write(); $file->write();
$this->assertEquals((int)$file->SubsiteID, 0); $this->assertEquals((int)$file->SubsiteID, 0);
$this->assertTrue($file->canEdit()); $this->assertTrue($file->canEdit());
FileSubsites::$default_root_folders_global = false; FileSubsites::$default_root_folders_global = false;
Subsite::changeSubsite($subsite->ID); Subsite::changeSubsite($subsite->ID);
$file = new File(); $file = new File();
$file->write(); $file->write();
$this->assertEquals($file->SubsiteID, $subsite->ID); $this->assertEquals($file->SubsiteID, $subsite->ID);
// Test inheriting from parent folder // Test inheriting from parent folder
$folder = new Folder(); $folder = new Folder();
$folder->write(); $folder->write();

View File

@ -176,6 +176,9 @@ class SiteTreeSubsitesTest extends BaseSubsiteTest
} }
public function testCopyToSubsite() { public function testCopyToSubsite() {
// Remove baseurl if testing in subdir
Config::inst()->update('Director', 'alternate_base_url', '/');
/** @var Subsite $otherSubsite */ /** @var Subsite $otherSubsite */
$otherSubsite = $this->objFromFixture('Subsite', 'subsite1'); $otherSubsite = $this->objFromFixture('Subsite', 'subsite1');
$staffPage = $this->objFromFixture('Page', 'staff'); // nested page $staffPage = $this->objFromFixture('Page', 'staff'); // nested page

View File

@ -7,6 +7,10 @@ class SubsitesVirtualPageTest extends BaseSubsiteTest
'subsites/tests/SubsitesVirtualPageTest.yml', 'subsites/tests/SubsitesVirtualPageTest.yml',
); );
protected $illegalExtensions = array(
'SiteTree' => array('Translatable')
);
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();