function MigrateSqlIdMapTest::testCurrentDestinationAndSource
Same name in other branches
- 9 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testCurrentDestinationAndSource()
- 8.9.x core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testCurrentDestinationAndSource()
- 11.x 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 699
Class
- MigrateSqlIdMapTest
- Tests the SQL ID map plugin.
Namespace
Drupal\Tests\migrate\UnitCode
public function testCurrentDestinationAndSource() : void {
// 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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.