function MigrateSourceTest::testPrepareRow
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testPrepareRow()
- 10 core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testPrepareRow()
- 11.x core/modules/migrate/tests/src/Unit/MigrateSourceTest.php \Drupal\Tests\migrate\Unit\MigrateSourceTest::testPrepareRow()
Tests basic row preparation.
@covers ::prepareRow
File
-
core/
modules/ migrate/ tests/ src/ Unit/ MigrateSourceTest.php, line 290
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()));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.