mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
NEW Add test for FolderFormFactoryExtension with a separate fixture
This commit is contained in:
parent
a0836bed79
commit
4f174ffd6e
34
tests/php/Extensions/FolderFormFactoryExtensionTest.php
Normal file
34
tests/php/Extensions/FolderFormFactoryExtensionTest.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Subsites\Tests\Extensions;
|
||||
|
||||
use SilverStripe\AssetAdmin\Forms\FolderFormFactory;
|
||||
use SilverStripe\Assets\Folder;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormFactory;
|
||||
|
||||
class FolderFormFactoryExtensionTest extends SapphireTest
|
||||
{
|
||||
protected static $fixture_file = 'FolderFormFactoryExtensionTest.yml';
|
||||
|
||||
public function testSubsitesFolderDropdown()
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
11
tests/php/Extensions/FolderFormFactoryExtensionTest.yml
Normal file
11
tests/php/Extensions/FolderFormFactoryExtensionTest.yml
Normal file
@ -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
|
@ -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 @@ class FileSubsitesTest extends BaseSubsiteTest
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user