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()
- 10 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()
Test basic entity save.
@covers ::import
File
-
core/
modules/ migrate/ tests/ src/ Unit/ Plugin/ migrate/ destination/ EntityContentBaseTest.php, line 30
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->entityFieldManager
->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)
->reveal());
$entity = $this->prophesize(ContentEntityInterface::class);
$entity->isValidationRequired()
->shouldBeCalledTimes(1);
// 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());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.