function TermKernelTest::testParentHandlerSettings

Same name in other branches
  1. 10 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 202

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.