mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MNT Refactor out missing assertArraySubset (#10208)
This commit is contained in:
parent
511b8a4c71
commit
fc707cc10d
@ -183,70 +183,42 @@ class DropdownFieldTest extends SapphireTest
|
|||||||
|
|
||||||
// Check state for default value
|
// Check state for default value
|
||||||
$schemaStateDefaults = $field->getSchemaStateDefaults();
|
$schemaStateDefaults = $field->getSchemaStateDefaults();
|
||||||
$this->assertArraySubset(
|
$this->assertSame($fieldId, $schemaStateDefaults['id']);
|
||||||
[
|
$this->assertSame($fieldName, $schemaStateDefaults['name']);
|
||||||
'id' => $fieldId,
|
$this->assertSame('first', $schemaStateDefaults['value']);
|
||||||
'name' => $fieldName,
|
|
||||||
'value' => 'first'
|
|
||||||
],
|
|
||||||
$schemaStateDefaults,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check data for empty defaults
|
// Check data for empty defaults
|
||||||
$schemaDataDefaults = $field->getSchemaDataDefaults();
|
$schemaDataDefaults = $field->getSchemaDataDefaults();
|
||||||
$this->assertArraySubset(
|
$this->assertSame($fieldId, $schemaDataDefaults['id']);
|
||||||
[
|
$this->assertSame($fieldName, $schemaDataDefaults['name']);
|
||||||
'id' => $fieldId,
|
$this->assertSame('text', $schemaDataDefaults['type']);
|
||||||
'name' => $fieldName,
|
$this->assertSame('SingleSelect', $schemaDataDefaults['schemaType']);
|
||||||
'type' => 'text',
|
$this->assertSame(sprintf('%s_Holder', $fieldId), $schemaDataDefaults['holderId']);
|
||||||
'schemaType' => 'SingleSelect',
|
$this->assertSame('Test Field', $schemaDataDefaults['title']);
|
||||||
'holderId' => sprintf('%s_Holder', $fieldId),
|
$this->assertSame('dropdown', $schemaDataDefaults['extraClass']);
|
||||||
'title' => 'Test Field',
|
$this->assertSame(null, $schemaDataDefaults['data']['emptyString']);
|
||||||
'extraClass' => 'dropdown',
|
$this->assertSame(false, $schemaDataDefaults['data']['hasEmptyDefault']);
|
||||||
'data' => [
|
|
||||||
'emptyString' => null,
|
|
||||||
'hasEmptyDefault' => false
|
|
||||||
]
|
|
||||||
],
|
|
||||||
$schemaDataDefaults,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Set an empty string of field
|
// Set an empty string of field
|
||||||
$field->setEmptyString('(Any)');
|
$field->setEmptyString('(Any)');
|
||||||
|
|
||||||
// Check state for default value
|
// Check state for default value
|
||||||
$schemaStateDefaults = $field->getSchemaStateDefaults();
|
$schemaStateDefaults = $field->getSchemaStateDefaults();
|
||||||
$this->assertArraySubset(
|
$this->assertSame($fieldId, $schemaStateDefaults['id']);
|
||||||
[
|
$this->assertSame($fieldName, $schemaStateDefaults['name']);
|
||||||
'id' => $fieldId,
|
$this->assertSame('', $schemaStateDefaults['value']);
|
||||||
'name' => $fieldName,
|
|
||||||
'value' => ''
|
|
||||||
],
|
|
||||||
$schemaStateDefaults,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
// Check data for empty defaults
|
// Check data for empty defaults
|
||||||
$schemaDataDefaults = $field->getSchemaDataDefaults();
|
$schemaDataDefaults = $field->getSchemaDataDefaults();
|
||||||
$this->assertArraySubset(
|
$this->assertSame($fieldId, $schemaDataDefaults['id']);
|
||||||
[
|
$this->assertSame($fieldName, $schemaDataDefaults['name']);
|
||||||
'id' => $fieldId,
|
$this->assertSame('text', $schemaDataDefaults['type']);
|
||||||
'name' => $fieldName,
|
$this->assertSame('SingleSelect', $schemaDataDefaults['schemaType']);
|
||||||
'type' => 'text',
|
$this->assertSame(sprintf('%s_Holder', $fieldId), $schemaDataDefaults['holderId']);
|
||||||
'schemaType' => 'SingleSelect',
|
$this->assertSame('Test Field', $schemaDataDefaults['title']);
|
||||||
'holderId' => sprintf('%s_Holder', $fieldId),
|
$this->assertSame('dropdown', $schemaDataDefaults['extraClass']);
|
||||||
'title' => 'Test Field',
|
$this->assertSame('(Any)', $schemaDataDefaults['data']['emptyString']);
|
||||||
'extraClass' => 'dropdown',
|
$this->assertSame(true, $schemaDataDefaults['data']['hasEmptyDefault']);
|
||||||
'data' => [
|
|
||||||
'emptyString' => '(Any)',
|
|
||||||
'hasEmptyDefault' => true
|
|
||||||
]
|
|
||||||
],
|
|
||||||
$schemaDataDefaults,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testZeroArraySourceNotOverwrittenByEmptyString()
|
public function testZeroArraySourceNotOverwrittenByEmptyString()
|
||||||
|
Loading…
Reference in New Issue
Block a user