function FieldTypePluginManagerTest::testGetGroupedDefinitions
Same name and namespace in other branches
- 10 core/tests/Drupal/Tests/Core/Field/FieldTypePluginManagerTest.php \Drupal\Tests\Core\Field\FieldTypePluginManagerTest::testGetGroupedDefinitions()
Tests get grouped definitions.
File
-
core/
tests/ Drupal/ Tests/ Core/ Field/ FieldTypePluginManagerTest.php, line 84
Class
Namespace
Drupal\Tests\Core\FieldCode
public function testGetGroupedDefinitions() : void {
$this->discovery
->getDefinitions()
->willReturn([
'telephone' => [
'category' => 'general',
'label' => 'Telephone',
'id' => 'telephone',
],
'string' => [
'category' => 'text',
'label' => 'Text (plain)',
'id' => 'string',
],
'integer' => [
'category' => 'number',
'label' => 'Number (integer)',
'id' => 'integer',
],
'float' => [
'id' => 'float',
'label' => 'Number (float)',
'category' => 'number',
],
]);
$this->fieldTypeCategoryManager
->getDefinitions()
->willReturn([
'general' => [
'label' => 'General',
'id' => 'general',
],
'number' => [
'label' => 'Number 🦥',
'id' => 'number',
],
'text' => [
'label' => 'Text 🐈',
'id' => 'text',
],
'empty_group' => [
'label' => 'Empty 🦗',
'id' => 'empty_group',
],
]);
$grouped_definitions = $this->fieldTypeManager
->getGroupedDefinitions();
$this->assertEquals([
'General',
'Number 🦥',
'Text 🐈',
], array_keys($grouped_definitions));
$grouped_definitions = $this->fieldTypeManager
->getGroupedDefinitions(NULL, 'label', 'id');
$this->assertEquals([
'general',
'number',
'text',
], array_keys($grouped_definitions));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.