function TextItemBaseTest::testCalculateDependencies

Same name in other branches
  1. 11.x core/modules/text/tests/src/Kernel/TextItemBaseTest.php \Drupal\Tests\text\Kernel\TextItemBaseTest::testCalculateDependencies()

@covers ::calculateDependencies

File

core/modules/text/tests/src/Kernel/TextItemBaseTest.php, line 69

Class

TextItemBaseTest
Tests TextItemBase.

Namespace

Drupal\Tests\text\Kernel

Code

public function testCalculateDependencies() : void {
    $format = FilterFormat::create([
        'format' => 'test_format',
        'name' => 'Test format',
    ]);
    $format->save();
    $fieldName = $this->randomMachineName();
    $field_storage = FieldStorageConfig::create([
        'field_name' => $fieldName,
        'entity_type' => 'entity_test',
        'type' => 'text',
    ]);
    $field_storage->save();
    $field = FieldConfig::create([
        'field_name' => $fieldName,
        'entity_type' => 'entity_test',
        'bundle' => 'entity_test',
        'settings' => [
            'allowed_formats' => [
                $format->id(),
            ],
        ],
    ]);
    $field->save();
    $field->calculateDependencies();
    $this->assertEquals([
        'module' => [
            'entity_test',
            'text',
        ],
        'config' => [
            "field.storage.entity_test.{$fieldName}",
            'filter.format.test_format',
        ],
    ], $field->getDependencies());
}

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