MNT Refactor out missing assertArraySubset (#10208)

This commit is contained in:
Steve Boyd 2022-01-20 12:24:25 +13:00 committed by GitHub
parent 511b8a4c71
commit fc707cc10d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()