public function EntityContentBaseTest::testImport in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest::testImport()
Test basic entity save.
@covers ::import
File
- core/
modules/ migrate/ tests/ src/ Unit/ Plugin/ migrate/ destination/ EntityContentBaseTest.php, line 59 - Contains \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest
Class
- EntityContentBaseTest
- Tests base entity migration destination functionality.
Namespace
Drupal\Tests\migrate\Unit\Plugin\migrate\destinationCode
public function testImport() {
$bundles = [];
$destination = new EntityTestDestination([], '', [], $this->migration
->reveal(), $this->storage
->reveal(), $bundles, $this->entityManager
->reveal(), $this
->prophesize(FieldTypePluginManagerInterface::class)
->reveal());
$entity = $this
->prophesize(ContentEntityInterface::class);
// Assert that save is called.
$entity
->save()
->shouldBeCalledTimes(1);
// Set an id for the entity
$entity
->id()
->willReturn(5);
$destination
->setEntity($entity
->reveal());
// Ensure the id is saved entity id is returned from import.
$this
->assertEquals([
5,
], $destination
->import(new Row([], [])));
// Assert that import set the rollback action.
$this
->assertEquals(MigrateIdMapInterface::ROLLBACK_DELETE, $destination
->rollbackAction());
}