MNT Remove polyfill

This commit is contained in:
Steve Boyd 2021-11-05 12:06:55 +13:00
parent e217a3d9cb
commit e53c18528c
2 changed files with 51 additions and 103 deletions

View File

@ -53,7 +53,6 @@
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9.5", "phpunit/phpunit": "^9.5",
"dms/phpunit-arraysubset-asserts": "^0.3.0",
"silverstripe/versioned": "^1", "silverstripe/versioned": "^1",
"squizlabs/php_codesniffer": "^3.5" "squizlabs/php_codesniffer": "^3.5"
}, },

View File

@ -2,7 +2,6 @@
namespace SilverStripe\Forms\Tests; namespace SilverStripe\Forms\Tests;
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
use SilverStripe\Assets\File; use SilverStripe\Assets\File;
use SilverStripe\Dev\SapphireTest; use SilverStripe\Dev\SapphireTest;
use SilverStripe\Forms\Form; use SilverStripe\Forms\Form;
@ -13,8 +12,6 @@ use SilverStripe\View\SSViewer;
class TreeMultiselectFieldTest extends SapphireTest class TreeMultiselectFieldTest extends SapphireTest
{ {
use ArraySubsetAsserts;
protected static $fixture_file = 'TreeDropdownFieldTest.yml'; protected static $fixture_file = 'TreeDropdownFieldTest.yml';
protected static $extra_dataobjects = [ protected static $extra_dataobjects = [
@ -136,38 +133,24 @@ class TreeMultiselectFieldTest extends SapphireTest
$this->assertEquals($fieldId, sprintf('%s_%s', $this->formId, $this->fieldName)); $this->assertEquals($fieldId, sprintf('%s_%s', $this->formId, $this->fieldName));
$schemaStateDefaults = $field->getSchemaStateDefaults(); $schemaStateDefaults = $field->getSchemaStateDefaults();
$this->assertArraySubset( $this->assertSame($fieldId, $schemaStateDefaults['id']);
[ $this->assertSame($this->fieldName, $schemaStateDefaults['name']);
'id' => $fieldId, $this->assertSame('unchanged', $schemaStateDefaults['value']);
'name' => $this->fieldName,
'value' => 'unchanged'
],
$schemaStateDefaults,
true
);
$schemaDataDefaults = $field->getSchemaDataDefaults(); $schemaDataDefaults = $field->getSchemaDataDefaults();
$this->assertArraySubset( $this->assertSame($fieldId, $schemaDataDefaults['id']);
[ $this->assertSame($this->fieldName, $schemaDataDefaults['name']);
'id' => $fieldId, $this->assertSame('text', $schemaDataDefaults['type']);
'name' => $this->fieldName, $this->assertSame('SingleSelect', $schemaDataDefaults['schemaType']);
'type' => 'text', $this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
'schemaType' => 'SingleSelect', $this->assertSame(sprintf('%s_Holder', $fieldId), $schemaDataDefaults['holderId']);
'component' => 'TreeDropdownField', $this->assertSame('Test tree', $schemaDataDefaults['title']);
'holderId' => sprintf('%s_Holder', $fieldId), $this->assertSame('treemultiselect multiple searchable', $schemaDataDefaults['extraClass']);
'title' => 'Test tree', $this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
'extraClass' => 'treemultiselect multiple searchable', $this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
'data' => [ $this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
'urlTree' => 'field/TestTree/tree', $this->assertSame(false, $schemaDataDefaults['data']['hasEmptyDefault']);
'showSearch' => true, $this->assertSame(true, $schemaDataDefaults['data']['multiple']);
'emptyString' => '(Search or choose File)',
'hasEmptyDefault' => false,
'multiple' => true
]
],
$schemaDataDefaults,
true
);
$items = $field->getItems(); $items = $field->getItems();
$this->assertCount(0, $items, 'there must be no items selected'); $this->assertCount(0, $items, 'there must be no items selected');
@ -188,15 +171,9 @@ class TreeMultiselectFieldTest extends SapphireTest
$field->setValue($this->fieldValue); $field->setValue($this->fieldValue);
$schemaStateDefaults = $field->getSchemaStateDefaults(); $schemaStateDefaults = $field->getSchemaStateDefaults();
$this->assertArraySubset( $this->assertSame($field->ID(), $schemaStateDefaults['id']);
[ $this->assertSame('TestTree', $schemaStateDefaults['name']);
'id' => $field->ID(), $this->assertSame($this->folderIds, $schemaStateDefaults['value']);
'name' => 'TestTree',
'value' => $this->folderIds
],
$schemaStateDefaults,
true
);
$items = $field->getItems(); $items = $field->getItems();
$this->assertCount(2, $items, 'there must be exactly 2 items selected'); $this->assertCount(2, $items, 'there must be exactly 2 items selected');
@ -214,38 +191,24 @@ class TreeMultiselectFieldTest extends SapphireTest
$field = $this->field->performReadonlyTransformation(); $field = $this->field->performReadonlyTransformation();
$schemaStateDefaults = $field->getSchemaStateDefaults(); $schemaStateDefaults = $field->getSchemaStateDefaults();
$this->assertArraySubset( $this->assertSame($field->ID(), $schemaStateDefaults['id']);
[ $this->assertSame('TestTree', $schemaStateDefaults['name']);
'id' => $field->ID(), $this->assertSame('unchanged', $schemaStateDefaults['value']);
'name' => 'TestTree',
'value' => 'unchanged'
],
$schemaStateDefaults,
true
);
$schemaDataDefaults = $field->getSchemaDataDefaults(); $schemaDataDefaults = $field->getSchemaDataDefaults();
$this->assertArraySubset( $this->assertSame($field->ID(), $schemaDataDefaults['id']);
[ $this->assertSame($this->fieldName, $schemaDataDefaults['name']);
'id' => $field->ID(), $this->assertSame('text', $schemaDataDefaults['type']);
'name' => $this->fieldName, $this->assertSame('SingleSelect', $schemaDataDefaults['schemaType']);
'type' => 'text', $this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
'schemaType' => 'SingleSelect', $this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
'component' => 'TreeDropdownField', $this->assertSame('Test tree', $schemaDataDefaults['title']);
'holderId' => sprintf('%s_Holder', $field->ID()), $this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
'title' => 'Test tree', $this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
'extraClass' => 'treemultiselectfield_readonly multiple searchable', $this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
'data' => [ $this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
'urlTree' => 'field/TestTree/tree', $this->assertSame(false, $schemaDataDefaults['data']['hasEmptyDefault']);
'showSearch' => true, $this->assertSame(true, $schemaDataDefaults['data']['multiple']);
'emptyString' => '(Search or choose File)',
'hasEmptyDefault' => false,
'multiple' => true
]
],
$schemaDataDefaults,
true
);
$items = $field->getItems(); $items = $field->getItems();
$this->assertCount(0, $items, 'there must be 0 selected items'); $this->assertCount(0, $items, 'there must be 0 selected items');
@ -264,38 +227,24 @@ class TreeMultiselectFieldTest extends SapphireTest
$field = $field->performReadonlyTransformation(); $field = $field->performReadonlyTransformation();
$schemaStateDefaults = $field->getSchemaStateDefaults(); $schemaStateDefaults = $field->getSchemaStateDefaults();
$this->assertArraySubset( $this->assertSame($field->ID(), $schemaStateDefaults['id']);
[ $this->assertSame('TestTree', $schemaStateDefaults['name']);
'id' => $field->ID(), $this->assertSame($this->folderIds, $schemaStateDefaults['value']);
'name' => 'TestTree',
'value' => $this->folderIds
],
$schemaStateDefaults,
true
);
$schemaDataDefaults = $field->getSchemaDataDefaults(); $schemaDataDefaults = $field->getSchemaDataDefaults();
$this->assertArraySubset( $this->assertSame($field->ID(), $schemaDataDefaults['id']);
[ $this->assertSame($this->fieldName, $schemaDataDefaults['name']);
'id' => $field->ID(), $this->assertSame('text', $schemaDataDefaults['type']);
'name' => $this->fieldName, $this->assertSame('SingleSelect', $schemaDataDefaults['schemaType']);
'type' => 'text', $this->assertSame('TreeDropdownField', $schemaDataDefaults['component']);
'schemaType' => 'SingleSelect', $this->assertSame(sprintf('%s_Holder', $field->ID()), $schemaDataDefaults['holderId']);
'component' => 'TreeDropdownField', $this->assertSame('Test tree', $schemaDataDefaults['title']);
'holderId' => sprintf('%s_Holder', $field->ID()), $this->assertSame('treemultiselectfield_readonly multiple searchable', $schemaDataDefaults['extraClass']);
'title' => 'Test tree', $this->assertSame('field/TestTree/tree', $schemaDataDefaults['data']['urlTree']);
'extraClass' => 'treemultiselectfield_readonly multiple searchable', $this->assertSame(true, $schemaDataDefaults['data']['showSearch']);
'data' => [ $this->assertSame('(Search or choose File)', $schemaDataDefaults['data']['emptyString']);
'urlTree' => 'field/TestTree/tree', $this->assertSame(false, $schemaDataDefaults['data']['hasEmptyDefault']);
'showSearch' => true, $this->assertSame(true, $schemaDataDefaults['data']['multiple']);
'emptyString' => '(Search or choose File)',
'hasEmptyDefault' => false,
'multiple' => true
]
],
$schemaDataDefaults,
true
);
$items = $field->getItems(); $items = $field->getItems();
$this->assertCount(2, $items, 'there must be exactly 2 selected items'); $this->assertCount(2, $items, 'there must be exactly 2 selected items');