You are here

public function MigrateSqlIdMapTest::testGetRowBySource in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest::testGetRowBySource()

Tests the getRowBySource method.

File

core/modules/migrate/tests/src/Unit/MigrateSqlIdMapTest.php, line 323
Contains \Drupal\Tests\migrate\Unit\MigrateSqlIdMapTest.

Class

MigrateSqlIdMapTest
Tests the SQL ID map plugin.

Namespace

Drupal\Tests\migrate\Unit

Code

public function testGetRowBySource() {
  $this
    ->getDatabase([]);
  $row = [
    'sourceid1' => 'source_id_value_1',
    'sourceid2' => 'source_id_value_2',
    'destid1' => 'destination_id_value_1',
  ] + $this
    ->idMapDefaults();
  $this
    ->saveMap($row);
  $row = [
    'sourceid1' => 'source_id_value_3',
    'sourceid2' => 'source_id_value_4',
    'destid1' => 'destination_id_value_2',
  ] + $this
    ->idMapDefaults();
  $this
    ->saveMap($row);
  $source_id_values = [
    'source_id_property' => $row['sourceid1'],
    'sourceid2' => $row['sourceid2'],
  ];
  $id_map = $this
    ->getIdMap();
  $result_row = $id_map
    ->getRowBySource($source_id_values);
  $this
    ->assertSame($row, $result_row);
  $source_id_values = [
    'source_id_property' => 'missing_value_1',
    'sourceid2' => 'missing_value_2',
  ];
  $result_row = $id_map
    ->getRowBySource($source_id_values);
  $this
    ->assertFalse($result_row);
}