summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabor Hojtsy2017-05-04 14:00:14 (GMT)
committerGabor Hojtsy2017-05-04 14:00:14 (GMT)
commit5c46a67f9adc21d2423077fee961c274043433f1 (patch)
tree0a118812868a555e7fef1e188befc4bffdb383e2
parent21f49e4cfdbf66647f5db2c88dff3ac960ef4c0a (diff)
Issue #2698023 by Jo Fitzgerald, mitrpaka, mohit_aghera, gaurav.kapoor, heddn, edysmp, mikeryan: Get sourceid values sorted from Row
-rw-r--r--core/modules/migrate/src/Plugin/migrate/id_map/Sql.php2
-rw-r--r--core/modules/migrate/src/Row.php5
-rw-r--r--core/modules/migrate/tests/src/Unit/RowTest.php33
3 files changed, 37 insertions, 3 deletions
diff --git a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
index 14a0a7a..27b7569 100644
--- a/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
+++ b/core/modules/migrate/src/Plugin/migrate/id_map/Sql.php
@@ -174,7 +174,7 @@ class Sql extends PluginBase implements MigrateIdMapInterface, ContainerFactoryP
/**
* Retrieves the hash of the source identifier values.
*
- * It is public only for testing purposes.
+ * @internal
*
* @param array $source_id_values
* The source identifiers
diff --git a/core/modules/migrate/src/Row.php b/core/modules/migrate/src/Row.php
index 2824dd9..95e7f28 100644
--- a/core/modules/migrate/src/Row.php
+++ b/core/modules/migrate/src/Row.php
@@ -106,10 +106,11 @@ class Row {
* Retrieves the values of the source identifiers.
*
* @return array
- * An array containing the values of the source identifiers.
+ * An array containing the values of the source identifiers. Returns values
+ * in the same order as defined in $this->sourceIds.
*/
public function getSourceIdValues() {
- return array_intersect_key($this->source, $this->sourceIds);
+ return array_merge($this->sourceIds, array_intersect_key($this->source, $this->sourceIds));
}
/**
diff --git a/core/modules/migrate/tests/src/Unit/RowTest.php b/core/modules/migrate/tests/src/Unit/RowTest.php
index 10d7d7d..9a20bda 100644
--- a/core/modules/migrate/tests/src/Unit/RowTest.php
+++ b/core/modules/migrate/tests/src/Unit/RowTest.php
@@ -193,6 +193,39 @@ class RowTest extends UnitTestCase {
}
/**
+ * Tests the multiple source IDs.
+ */
+ public function testMultipleSourceIdValues() {
+ // Set values in same order as ids.
+ $multi_source_ids = $this->testSourceIds + [
+ 'vid' => 'Node revision',
+ 'type' => 'Node type',
+ 'langcode' => 'Node language',
+ ];
+ $multi_source_ids_values = $this->testValues + [
+ 'vid' => 1,
+ 'type' => 'page',
+ 'langcode' => 'en',
+ ];
+ $row = new Row($multi_source_ids_values, $multi_source_ids);
+ $this->assertSame(array_keys($multi_source_ids), array_keys($row->getSourceIdValues()));
+
+ // Set values in different order.
+ $multi_source_ids = $this->testSourceIds + [
+ 'vid' => 'Node revision',
+ 'type' => 'Node type',
+ 'langcode' => 'Node language',
+ ];
+ $multi_source_ids_values = $this->testValues + [
+ 'langcode' => 'en',
+ 'type' => 'page',
+ 'vid' => 1,
+ ];
+ $row = new Row($multi_source_ids_values, $multi_source_ids);
+ $this->assertSame(array_keys($multi_source_ids), array_keys($row->getSourceIdValues()));
+ }
+
+ /**
* Tests getting the source property.
*
* @covers ::getSourceProperty