function EntityContentBaseTest::testImport
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest::testImport()
- 8.9.x core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest::testImport()
- 11.x core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php \Drupal\Tests\migrate\Unit\Plugin\migrate\destination\EntityContentBaseTest::testImport()
Tests basic entity save.
@covers ::import
File
-
core/
modules/ migrate/ tests/ src/ Unit/ Plugin/ migrate/ destination/ EntityContentBaseTest.php, line 29
Class
- EntityContentBaseTest
- Tests base entity migration destination functionality.
Namespace
Drupal\Tests\migrate\Unit\Plugin\migrate\destinationCode
public function testImport() : void {
$bundles = [];
$destination = new EntityTestDestination([], '', [], $this->migration
->reveal(), $this->storage
->reveal(), $bundles, $this->entityFieldManager
->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)
->reveal(), $this->prophesize(AccountSwitcherInterface::class)
->reveal());
$entity = $this->prophesize(ContentEntityInterface::class);
$entity->isValidationRequired()
->shouldBeCalledTimes(1);
// Assert that save is called.
$entity->save()
->shouldBeCalledTimes(1);
// Syncing should be set once.
$entity->setSyncing(Argument::exact(TRUE))
->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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.