function FieldTypeCategoryDiscoveryTest::testFieldTypeCategories

Same name in other branches
  1. 10 core/modules/field/tests/src/Kernel/FieldTypeCategoryDiscoveryTest.php \Drupal\Tests\field\Kernel\FieldTypeCategoryDiscoveryTest::testFieldTypeCategories()

Tests custom field type categories created by modules.

File

core/modules/field/tests/src/Kernel/FieldTypeCategoryDiscoveryTest.php, line 26

Class

FieldTypeCategoryDiscoveryTest
Tests discovery of field type categories provided by modules.

Namespace

Drupal\Tests\field\Kernel

Code

public function testFieldTypeCategories() : void {
    $category = \Drupal::service('plugin.manager.field.field_type_category')->createInstance('test_category');
    $expected = [
        'Test category',
        'This is a test field type category.',
        -10,
        [
            'field_plugins_test/test_library',
        ],
    ];
    $this->assertSame($expected, [
        (string) $category->getLabel(),
        (string) $category->getDescription(),
        $category->getWeight(),
        $category->getLibraries(),
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.