2010-03-21 23:32:22 +01:00
|
|
|
<?php
|
|
|
|
|
2013-01-03 14:46:56 +01:00
|
|
|
class FileSubsitesTest extends BaseSubsiteTest {
|
2010-03-21 23:32:22 +01:00
|
|
|
static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
|
|
|
|
|
|
|
function testTrivialFeatures() {
|
|
|
|
$this->assertTrue(is_array(singleton('FileSubsites')->extraStatics()));
|
|
|
|
$file = new File();
|
2010-03-30 22:43:34 +02:00
|
|
|
$file->Name = 'FileTitle';
|
2010-03-21 23:32:22 +01:00
|
|
|
$file->Title = 'FileTitle';
|
|
|
|
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
|
|
|
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
2012-07-11 15:32:10 +02:00
|
|
|
$this->assertEquals('FileTitle', $file->getTreeTitle());
|
2012-03-25 18:35:01 +02:00
|
|
|
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
2010-03-21 23:32:22 +01:00
|
|
|
Subsite::changeSubsite(1);
|
|
|
|
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testWritingSubsiteID() {
|
|
|
|
$this->objFromFixture('Member', 'admin')->logIn();
|
|
|
|
|
|
|
|
$subsite = $this->objFromFixture('Subsite', 'domaintest1');
|
|
|
|
FileSubsites::$default_root_folders_global = true;
|
|
|
|
|
|
|
|
Subsite::changeSubsite(0);
|
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$file->onAfterUpload();
|
|
|
|
$this->assertEquals((int)$file->SubsiteID, 0);
|
|
|
|
|
|
|
|
Subsite::changeSubsite($subsite->ID);
|
|
|
|
$this->assertTrue($file->canEdit());
|
|
|
|
|
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$this->assertEquals((int)$file->SubsiteID, 0);
|
|
|
|
$this->assertTrue($file->canEdit());
|
|
|
|
|
|
|
|
FileSubsites::$default_root_folders_global = false;
|
|
|
|
|
|
|
|
Subsite::changeSubsite($subsite->ID);
|
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$this->assertEquals($file->SubsiteID, $subsite->ID);
|
|
|
|
|
|
|
|
// Test inheriting from parent folder
|
|
|
|
$folder = new Folder();
|
|
|
|
$folder->write();
|
|
|
|
$this->assertEquals($folder->SubsiteID, $subsite->ID);
|
|
|
|
FileSubsites::$default_root_folders_global = true;
|
|
|
|
$file = new File();
|
|
|
|
$file->ParentID = $folder->ID;
|
|
|
|
$file->onAfterUpload();
|
|
|
|
$this->assertEquals($folder->SubsiteID, $file->SubsiteID);
|
|
|
|
}
|
2013-02-04 03:21:08 +01:00
|
|
|
|
|
|
|
function testSubsitesFolderDropdown() {
|
|
|
|
$this->objFromFixture('Member', 'admin')->logIn();
|
|
|
|
|
|
|
|
$file = new Folder();
|
|
|
|
|
|
|
|
$this->assertEquals(array(
|
|
|
|
'Main site',
|
|
|
|
'Template',
|
|
|
|
'Subsite1 Template',
|
|
|
|
'Subsite2 Template',
|
|
|
|
'Test 1',
|
|
|
|
'Test 2',
|
|
|
|
'Test 3'
|
|
|
|
), $file->getCMSFields()->dataFieldByName('SubsiteID')->getSource());
|
|
|
|
}
|
2010-03-21 23:32:22 +01:00
|
|
|
|
|
|
|
}
|