You are here

public function TermParentCollectorTest::testParentWasAdded in Dependency Calculation 8

@covers ::onCalculateDependencies

Throws

\Exception

File

tests/src/Kernel/EventSubscriber/DependencyCollector/TermParentCollectorTest.php, line 69

Class

TermParentCollectorTest
Class TermParentCollectorTest.

Namespace

Drupal\Tests\depcalc\Kernel\EventSubscriber\DependencyCollector

Code

public function testParentWasAdded() {
  $parent = Term::create([
    'vid' => 'tags',
    'status' => 1,
    'name' => 'Term parent',
  ]);
  $parent
    ->save();
  $child = Term::create([
    'vid' => 'tags',
    'status' => 1,
    'name' => 'Term child',
  ]);
  $child->parent->entity = $parent;
  $child
    ->save();
  $event = $this
    ->dispatchCalculateDependencies($child, []);
  $dependencies = $event
    ->getDependencies();
  $this
    ->assertArrayHasKey($parent
    ->uuid(), $dependencies, 'Taxonomy term should have parent as a dependency');
}