public function PatternDefinitionTest::testFields in UI Patterns 8
Test field singleton.
@dataProvider definitionGettersProvider
File
- tests/
src/ Unit/ Definition/ PatternDefinitionTest.php, line 31
Class
- PatternDefinitionTest
- @coversDefaultClass \Drupal\ui_patterns\Definition\PatternDefinition
Namespace
Drupal\Tests\ui_patterns\Unit\DefinitionCode
public function testFields() {
$fields = [
'name' => [
'name' => 'name',
'label' => 'Label',
],
];
$pattern_definition = new PatternDefinition();
$pattern_definition
->setFields($fields);
$this
->assertEquals([
$fields['name']['label'],
$fields['name']['name'],
NULL,
NULL,
NULL,
], [
$pattern_definition
->getField('name')
->getLabel(),
$pattern_definition
->getField('name')
->getName(),
$pattern_definition
->getField('name')
->getType(),
$pattern_definition
->getField('name')
->getDescription(),
$pattern_definition
->getField('name')
->getPreview(),
]);
$pattern_definition
->getField('name')
->setType('type');
$pattern_definition
->getField('name')
->setPreview('preview');
$pattern_definition
->getField('name')
->setDescription('description');
$this
->assertEquals([
'type',
'description',
'preview',
], [
$pattern_definition
->getField('name')
->getType(),
$pattern_definition
->getField('name')
->getDescription(),
$pattern_definition
->getField('name')
->getPreview(),
]);
}