diff --git a/tests/php/Extensions/FolderFormFactoryExtensionTest.php b/tests/php/Extensions/FolderFormFactoryExtensionTest.php new file mode 100644 index 00000000..ebb55740 --- /dev/null +++ b/tests/php/Extensions/FolderFormFactoryExtensionTest.php @@ -0,0 +1,34 @@ +logInWithPermission('ADMIN'); + + /** @var Folder $folder */ + $folder = $this->objFromFixture(Folder::class, 'folder_a'); + + /** @var Form $folderForm */ + $folderForm = FolderFormFactory::create()->getForm(null, FormFactory::DEFAULT_NAME, [ + 'Record' => $folder + ]); + + $source = array_values($folderForm->Fields()->fieldByName('SubsiteID')->getSource()); + $result = array_values($source); + + $this->assertContains('Main site', $result); + $this->assertContains('Subsite A', $result); + $this->assertContains('Subsite B', $result); + } +} diff --git a/tests/php/Extensions/FolderFormFactoryExtensionTest.yml b/tests/php/Extensions/FolderFormFactoryExtensionTest.yml new file mode 100644 index 00000000..369c1994 --- /dev/null +++ b/tests/php/Extensions/FolderFormFactoryExtensionTest.yml @@ -0,0 +1,11 @@ +SilverStripe\Subsites\Model\Subsite: + main: + Title: Template + subsite_a: + Title: Subsite A + subsite_b: + Title: Subsite B + +SilverStripe\Assets\Folder: + folder_a: + Title: Folder A diff --git a/tests/php/FileSubsitesTest.php b/tests/php/FileSubsitesTest.php index c59839e5..b3484faf 100644 --- a/tests/php/FileSubsitesTest.php +++ b/tests/php/FileSubsitesTest.php @@ -12,15 +12,6 @@ class FileSubsitesTest extends BaseSubsiteTest { protected static $fixture_file = 'SubsiteTest.yml'; - /** - * Disable other file extensions - * - * @var array - */ - protected static $illegal_extensions = [ - SiteTree::class => ['Translatable'], // @todo implement namespace for Translatable - ]; - public function testTrivialFeatures() { $this->assertTrue(is_array(singleton(FileSubsites::class)->extraStatics())); @@ -73,27 +64,4 @@ public function testWritingSubsiteID() $file->onAfterUpload(); $this->assertEquals($folder->SubsiteID, $file->SubsiteID); } - - public function testSubsitesFolderDropdown() - { - $this->logInAs('admin'); - - $file = new Folder(); - - $source = array_values($file->getCMSFields()->dataFieldByName('SubsiteID')->getSource()); - asort($source); - - $this->assertEquals([ - 'Main site', - 'Subsite1 Template', - 'Subsite2 Template', - 'Template', - 'Test 1', - 'Test 2', - 'Test 3', - 'Test Non-SSL', - 'Test SSL', - 'Test Vagrant VM on port 8080' - ], array_values($source)); - } }