2010-03-21 23:32:22 +01:00
|
|
|
<?php
|
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
class FileSubsitesTest extends BaseSubsiteTest
|
|
|
|
{
|
|
|
|
public static $fixture_file = 'subsites/tests/SubsiteTest.yml';
|
2015-11-24 05:15:08 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Disable other file extensions
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $illegalExtensions = array(
|
|
|
|
'File' => array(
|
|
|
|
'SecureFileExtension',
|
|
|
|
'VersionedFileExtension'
|
2016-08-23 02:36:12 +02:00
|
|
|
),
|
|
|
|
'SiteTree' => array(
|
|
|
|
'Translatable',
|
|
|
|
)
|
2015-11-24 05:15:08 +01:00
|
|
|
);
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
public function testTrivialFeatures()
|
|
|
|
{
|
|
|
|
$this->assertTrue(is_array(singleton('FileSubsites')->extraStatics()));
|
|
|
|
$file = new File();
|
|
|
|
$file->Name = 'FileTitle';
|
|
|
|
$file->Title = 'FileTitle';
|
|
|
|
$this->assertEquals(' * FileTitle', $file->alternateTreeTitle());
|
|
|
|
$file->SubsiteID = $this->objFromFixture('Subsite', 'domaintest1')->ID;
|
|
|
|
$this->assertEquals('FileTitle', $file->getTreeTitle());
|
|
|
|
$this->assertTrue(singleton('Folder')->getCMSFields() instanceof FieldList);
|
|
|
|
Subsite::changeSubsite(1);
|
|
|
|
$this->assertEquals($file->cacheKeyComponent(), 'subsite-1');
|
|
|
|
}
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
public function testWritingSubsiteID()
|
|
|
|
{
|
|
|
|
$this->objFromFixture('Member', 'admin')->logIn();
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
$subsite = $this->objFromFixture('Subsite', 'domaintest1');
|
|
|
|
FileSubsites::$default_root_folders_global = true;
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
Subsite::changeSubsite(0);
|
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$file->onAfterUpload();
|
|
|
|
$this->assertEquals((int)$file->SubsiteID, 0);
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
Subsite::changeSubsite($subsite->ID);
|
|
|
|
$this->assertTrue($file->canEdit());
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$this->assertEquals((int)$file->SubsiteID, 0);
|
|
|
|
$this->assertTrue($file->canEdit());
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
FileSubsites::$default_root_folders_global = false;
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
Subsite::changeSubsite($subsite->ID);
|
|
|
|
$file = new File();
|
|
|
|
$file->write();
|
|
|
|
$this->assertEquals($file->SubsiteID, $subsite->ID);
|
2016-08-23 02:36:12 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
// 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
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
public function testSubsitesFolderDropdown()
|
|
|
|
{
|
|
|
|
$this->objFromFixture('Member', 'admin')->logIn();
|
2013-02-04 03:21:08 +01:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
$file = new Folder();
|
2013-02-04 03:21:08 +01:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
$source = array_values($file->getCMSFields()->dataFieldByName('SubsiteID')->getSource());
|
|
|
|
asort($source);
|
2013-05-06 13:07:16 +02:00
|
|
|
|
2015-11-23 04:53:45 +01:00
|
|
|
$this->assertEquals(array(
|
|
|
|
'Main site',
|
|
|
|
'Subsite1 Template',
|
|
|
|
'Subsite2 Template',
|
2015-11-24 05:15:08 +01:00
|
|
|
'Template',
|
2015-11-23 04:53:45 +01:00
|
|
|
'Test 1',
|
|
|
|
'Test 2',
|
2015-11-24 05:15:08 +01:00
|
|
|
'Test 3',
|
|
|
|
'Test Non-SSL',
|
|
|
|
'Test SSL',
|
|
|
|
), array_values($source));
|
2015-11-23 04:53:45 +01:00
|
|
|
}
|
2010-03-21 23:32:22 +01:00
|
|
|
}
|