You are here

public function ReferenceMigratorTest::migratesNodes in Term reference change 8

Tests term references in nodes are migrated.

@test

File

tests/src/Kernel/ReferenceMigratorTest.php, line 86

Class

ReferenceMigratorTest
Tests that references are migrated.

Namespace

Drupal\Tests\term_reference_change\Kernel

Code

public function migratesNodes() {
  $sourceTerm = $this
    ->createTerm($this->vocabulary);
  $targetTerm = $this
    ->createTerm($this->vocabulary);
  $node = $this
    ->createNode([
    'field_terms' => [
      'target_id' => $sourceTerm
        ->id(),
    ],
  ]);
  $sut = new ReferenceMigrator(\Drupal::service('term_reference_change.reference_finder'));
  $sut
    ->migrateReference($sourceTerm, $targetTerm);
  $this
    ->assertNodeReferencesTermOnce($node, $targetTerm);
}