function EntityRevisionTest::testGetEntityUpdateRevision

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php \Drupal\Tests\migrate\Unit\destination\EntityRevisionTest::testGetEntityUpdateRevision()
  2. 8.9.x core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php \Drupal\Tests\migrate\Unit\destination\EntityRevisionTest::testGetEntityUpdateRevision()
  3. 10 core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php \Drupal\Tests\migrate\Unit\destination\EntityRevisionTest::testGetEntityUpdateRevision()

Tests that revision updates update.

@covers ::getEntity

File

core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php, line 100

Class

EntityRevisionTest
Tests entity revision destination.

Namespace

Drupal\Tests\migrate\Unit\destination

Code

public function testGetEntityUpdateRevision() : void {
    $destination = $this->getEntityRevisionDestination([]);
    $entity = $this->prophesize(RevisionableInterface::class);
    // Assert we load the correct revision.
    $this->storage
        ->loadRevision(2)
        ->shouldBeCalled()
        ->willReturn($entity->reveal());
    // Make sure its set as an update and not the default revision.
    $entity->setNewRevision(FALSE)
        ->shouldBeCalled();
    $entity->isDefaultRevision(FALSE)
        ->shouldBeCalled();
    $row = new Row([
        'nid' => 1,
        'vid' => 2,
    ], [
        'nid' => 1,
        'vid' => 2,
    ]);
    $row->setDestinationProperty('vid', 2);
    $this->assertEquals($entity->reveal(), $destination->getEntity($row, []));
}

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