Commit 5c46a67f authored by Gábor Hojtsy's avatar Gábor Hojtsy

Issue #2698023 by Jo Fitzgerald, mitrpaka, mohit_aghera, gaurav.kapoor, heddn,...

Issue #2698023 by Jo Fitzgerald, mitrpaka, mohit_aghera, gaurav.kapoor, heddn, edysmp, mikeryan: Get sourceid values sorted from Row
parent 21f49e4c
...@@ -174,7 +174,7 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -174,7 +174,7 @@ public static function create(ContainerInterface $container, array $configuratio
/** /**
* Retrieves the hash of the source identifier values. * Retrieves the hash of the source identifier values.
* *
* It is public only for testing purposes. * @internal
* *
* @param array $source_id_values * @param array $source_id_values
* The source identifiers * The source identifiers
......
...@@ -106,10 +106,11 @@ public function __construct(array $values = [], array $source_ids = [], $is_stub ...@@ -106,10 +106,11 @@ public function __construct(array $values = [], array $source_ids = [], $is_stub
* Retrieves the values of the source identifiers. * Retrieves the values of the source identifiers.
* *
* @return array * @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() { public function getSourceIdValues() {
return array_intersect_key($this->source, $this->sourceIds); return array_merge($this->sourceIds, array_intersect_key($this->source, $this->sourceIds));
} }
/** /**
......
...@@ -192,6 +192,39 @@ public function testSourceIdValues() { ...@@ -192,6 +192,39 @@ public function testSourceIdValues() {
$this->assertSame(['nid' => $this->testValues['nid']], $row->getSourceIdValues()); $this->assertSame(['nid' => $this->testValues['nid']], $row->getSourceIdValues());
} }
/**
* 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. * Tests getting the source property.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment