function MigrateNodeCompleteTest::assertRevision

Same name in this branch
  1. 8.9.x core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeCompleteTest::assertRevision()
Same name in other branches
  1. 9 core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeCompleteTest::assertRevision()
  2. 9 core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeCompleteTest::assertRevision()
  3. 10 core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeCompleteTest::assertRevision()
  4. 10 core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeCompleteTest::assertRevision()
  5. 11.x core/modules/node/tests/src/Kernel/Migrate/d6/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeCompleteTest::assertRevision()
  6. 11.x core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeCompleteTest::assertRevision()

Asserts various aspects of a node revision.

Parameters

array $revision: An array of revision data matching a node_field_revision table row.

array $data: An array of revision data.

1 call to MigrateNodeCompleteTest::assertRevision()
MigrateNodeCompleteTest::testNodeCompleteMigration in core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php
Tests the complete node migration.

File

core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php, line 166

Class

MigrateNodeCompleteTest
Test class for a complete node migration for Drupal 7.

Namespace

Drupal\Tests\node\Kernel\Migrate\d7

Code

protected function assertRevision(array $revision, array $data) {
    
    /* @var  \Drupal\node\NodeInterface $actual */
    $actual = $this->nodeStorage
        ->loadRevision($revision['vid'])
        ->getTranslation($revision['langcode']);
    $this->assertInstanceOf(NodeInterface::class, $actual);
    $this->assertSame($revision['title'], $actual->getTitle(), sprintf("Title '%s' does not match actual '%s' for revision '%d' langcode '%s'", $revision['title'], $actual->getTitle(), $revision['vid'], $revision['langcode']));
    $this->assertSame($revision['revision_translation_affected'], $actual->get('revision_translation_affected')->value, sprintf("revision_translation_affected '%s' does not match actual '%s' for revision '%d' langcode '%s'", $revision['revision_translation_affected'], $actual->get('revision_translation_affected')->value, $revision['vid'], $revision['langcode']));
    $this->assertSame($data['revision_created'], $actual->getRevisionCreationTime(), sprintf("Creation time '%s' does not match actual '%s' for revision '%d' langcode '%s'", $data['revision_created'], $actual->getRevisionCreationTime(), $revision['vid'], $revision['langcode']));
    $this->assertSame($data['log'], $actual->getRevisionLogMessage(), sprintf("Revision log '%s' does not match actual '%s' for revision '%d' langcode '%s'", var_export($data['log'], TRUE), $actual->getRevisionLogMessage(), $revision['vid'], $revision['langcode']));
    if (isset($data['field_text_long_plain'])) {
        $this->assertSame($data['field_text_long_plain'], $actual->field_text_long_plain->value, sprintf("field_text_long_plain value '%s' does not match actual '%s' for revision '%d' langcode '%s'", var_export($data['field_text_long_plain'], TRUE), $actual->field_text_long_plain->value, $revision['vid'], $revision['langcode']));
    }
    if (isset($data['field_tree'])) {
        $this->assertSame($data['field_tree'], $actual->field_tree->value, sprintf("field_tree value '%s' does not match actual '%s' for revision '%d' langcode '%s'", var_export($data['field_tree'], TRUE), $actual->field_tree->value, $revision['vid'], $revision['langcode']));
    }
}

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