public function MigrateSqlIdMapTest::testCurrentDestinationAndSource in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testCurrentDestinationAndSource()
Tests currentDestination() and currentSource().
File
- core/
modules/ migrate/ tests/ src/ Unit/ MigrateSqlIdMapTest.php, line 684
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testCurrentDestinationAndSource() {
// Simple map with one source and one destination ID.
$id_map = $this
->setupRows([
'nid',
], [
'nid',
], [
[
1,
101,
],
[
2,
102,
],
[
3,
103,
],
// Mock a failed row by setting the destination ID to NULL.
[
4,
NULL,
],
]);
// The rows are ordered by destination ID so the failed row should be first.
$id_map
->rewind();
$this
->assertEquals([], $id_map
->currentDestination());
$this
->assertEquals([
'nid' => 4,
], $id_map
->currentSource());
$id_map
->next();
$this
->assertEquals([
'nid' => 101,
], $id_map
->currentDestination());
$this
->assertEquals([
'nid' => 1,
], $id_map
->currentSource());
$id_map
->next();
$this
->assertEquals([
'nid' => 102,
], $id_map
->currentDestination());
$this
->assertEquals([
'nid' => 2,
], $id_map
->currentSource());
$id_map
->next();
$this
->assertEquals([
'nid' => 103,
], $id_map
->currentDestination());
$this
->assertEquals([
'nid' => 3,
], $id_map
->currentSource());
$id_map
->next();
}