function EntityRevisionTest::testGetEntityUpdateRevision

Same name in other branches
  1. 8.9.x core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php \Drupal\Tests\migrate\Unit\destination\EntityRevisionTest::testGetEntityUpdateRevision()
  2. 10 core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php \Drupal\Tests\migrate\Unit\destination\EntityRevisionTest::testGetEntityUpdateRevision()
  3. 11.x 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 97

Class

EntityRevisionTest
Tests entity revision destination.

Namespace

Drupal\Tests\migrate\Unit\destination

Code

public function testGetEntityUpdateRevision() {
    $destination = $this->getEntityRevisionDestination([]);
    $entity = $this->prophesize('\\Drupal\\Core\\Entity\\RevisionableInterface');
    $entity_type = $this->prophesize('\\Drupal\\Core\\Entity\\EntityTypeInterface');
    $entity_type->getKey('id')
        ->willReturn('nid');
    $entity_type->getKey('revision')
        ->willReturn('vid');
    $this->storage
        ->getEntityType()
        ->willReturn($entity_type->reveal());
    // 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.