function TermKernelTest::testParentHandlerSettings

Same name in other branches
  1. 11.x core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php \Drupal\Tests\taxonomy\Kernel\TermKernelTest::testParentHandlerSettings()

The "parent" field must restrict references to the same vocabulary.

File

core/modules/taxonomy/tests/src/Kernel/TermKernelTest.php, line 230

Class

TermKernelTest
Kernel tests for taxonomy term functions.

Namespace

Drupal\Tests\taxonomy\Kernel

Code

public function testParentHandlerSettings() : void {
    $vocabulary = $this->createVocabulary();
    $vocabulary_fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('taxonomy_term', $vocabulary->id());
    $parent_target_bundles = $vocabulary_fields['parent']->getSetting('handler_settings')['target_bundles'];
    $this->assertSame([
        $vocabulary->id() => $vocabulary->id(),
    ], $parent_target_bundles);
}

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