public function MigrateSourceTest::testPrepareRow in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testPrepareRow()
Test basic row preparation.
@covers ::prepareRow
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSourceTest.php, line 287 - Contains \Drupal\Tests\migrate\Unit\MigrateSourceTest.
Class
- MigrateSourceTest
- @coversDefaultClass \Drupal\migrate\Plugin\migrate\source\SourcePluginBase @group migrate
Namespace
Drupal\Tests\migrate\UnitCode
public function testPrepareRow() {
$this->migrationConfiguration['id'] = 'test_migration';
// Get a new migration with an id.
$migration = $this
->getMigration();
$source = new StubSourcePlugin([], '', [], $migration);
$row = new Row();
$module_handler = $this
->prophesize(ModuleHandlerInterface::class);
$module_handler
->invokeAll('migrate_prepare_row', [
$row,
$source,
$migration,
])
->willReturn([
TRUE,
TRUE,
])
->shouldBeCalled();
$module_handler
->invokeAll('migrate_' . $migration
->id() . '_prepare_row', [
$row,
$source,
$migration,
])
->willReturn([
TRUE,
TRUE,
])
->shouldBeCalled();
$source
->setModuleHandler($module_handler
->reveal());
// Ensure we don't log this to the mapping table.
$this->idMap
->expects($this
->never())
->method('saveIdMapping');
$this
->assertTrue($source
->prepareRow($row));
// Track_changes...
$source = new StubSourcePlugin([
'track_changes' => TRUE,
], '', [], $migration);
$row2 = $this
->prophesize(Row::class);
$row2
->rehash()
->shouldBeCalled();
$module_handler
->invokeAll('migrate_prepare_row', [
$row2,
$source,
$migration,
])
->willReturn([
TRUE,
TRUE,
])
->shouldBeCalled();
$module_handler
->invokeAll('migrate_' . $migration
->id() . '_prepare_row', [
$row2,
$source,
$migration,
])
->willReturn([
TRUE,
TRUE,
])
->shouldBeCalled();
$source
->setModuleHandler($module_handler
->reveal());
$this
->assertTrue($source
->prepareRow($row2
->reveal()));
}