From 4f174ffd6e0a2e4a705090f47df90801363ea91b Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Thu, 18 Jan 2018 16:22:35 +1300 Subject: [PATCH] NEW Add test for FolderFormFactoryExtension with a separate fixture --- .../FolderFormFactoryExtensionTest.php | 34 +++++++++++++++++++ .../FolderFormFactoryExtensionTest.yml | 11 ++++++ tests/php/FileSubsitesTest.php | 32 ----------------- 3 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 tests/php/Extensions/FolderFormFactoryExtensionTest.php create mode 100644 tests/php/Extensions/FolderFormFactoryExtensionTest.yml 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)); - } }