Unverified Commit bb2ef5d7 authored by alexpott's avatar alexpott
Browse files

Issue #2960611 by msankhala, dmitryl, benjifisher: Change lookupSourceID and...

Issue #2960611 by msankhala, dmitryl, benjifisher: Change lookupSourceID and lookupDestinationID to lookupSourceId and lookupDestinationId in the Migrate module
parent 636aafde
......@@ -197,7 +197,7 @@ public function testEntityDisplaySettings() {
$component = $display->getComponent('field_test_datetime');
$this->assertIdentical($expected, $component);
// Test that our Id map has the correct data.
$this->assertIdentical(['node', 'story', 'teaser', 'field_test'], $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationID(['story', 'teaser', 'node', 'field_test']));
$this->assertIdentical(['node', 'story', 'teaser', 'field_test'], $this->getMigration('d6_field_formatter_settings')->getIdMap()->lookupDestinationId(['story', 'teaser', 'node', 'field_test']));
// Test hidden field.
$this->assertComponentNotExists('node.test_planet.teaser', 'field_test_text_single_checkbox');
......
......@@ -44,7 +44,7 @@ public function testUploadEntityDisplay() {
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
$this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationID(['page']));
$this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_display')->getIdMap()->lookupDestinationId(['page']));
}
/**
......
......@@ -44,7 +44,7 @@ public function testUploadEntityFormDisplay() {
$component = $display->getComponent('upload');
$this->assertTrue(is_null($component));
$this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationID(['page']));
$this->assertIdentical(['node', 'page', 'default', 'upload'], $this->getMigration('d6_upload_entity_form_display')->getIdMap()->lookupDestinationId(['page']));
}
/**
......
......@@ -31,7 +31,7 @@ protected function setUp() {
public function testUpload() {
$field_storage = FieldStorageConfig::load('node.upload');
$this->assertIdentical('node.upload', $field_storage->id());
$this->assertIdentical(['node', 'upload'], $this->getMigration('d6_upload_field')->getIdMap()->lookupDestinationID(['']));
$this->assertIdentical(['node', 'upload'], $this->getMigration('d6_upload_field')->getIdMap()->lookupDestinationId(['']));
}
}
......@@ -43,7 +43,7 @@ public function testUploadFieldInstance() {
$field = FieldConfig::load('node.article.upload');
$this->assertTrue(is_null($field));
$this->assertIdentical(['node', 'page', 'upload'], $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationID(['page']));
$this->assertIdentical(['node', 'page', 'upload'], $this->getMigration('d6_upload_field_instance')->getIdMap()->lookupDestinationId(['page']));
}
}
......@@ -197,7 +197,7 @@ public function getRowsNeedingUpdate($count);
* The source identifier keyed values of the record, e.g. ['nid' => 5], or
* an empty array on failure.
*/
public function lookupSourceID(array $destination_id_values);
public function lookupSourceId(array $destination_id_values);
/**
* Looks up the destination identifier corresponding to a source key.
......
......@@ -48,7 +48,7 @@ public function getRowsNeedingUpdate($count) {
/**
* {@inheritdoc}
*/
public function lookupSourceID(array $destination_id_values) {
public function lookupSourceId(array $destination_id_values) {
return [];
}
......
......@@ -529,7 +529,7 @@ public function getRowsNeedingUpdate($count) {
/**
* {@inheritdoc}
*/
public function lookupSourceID(array $destination_id_values) {
public function lookupSourceId(array $destination_id_values) {
$source_id_fields = $this->sourceIdFields();
$query = $this->getDatabase()->select($this->mapTableName(), 'map');
foreach ($source_id_fields as $source_field_name => $idmap_field_name) {
......@@ -789,7 +789,7 @@ public function delete(array $source_id_values, $messages_only = FALSE) {
public function deleteDestination(array $destination_id_values) {
$map_query = $this->getDatabase()->delete($this->mapTableName());
$message_query = $this->getDatabase()->delete($this->messageTableName());
$source_id_values = $this->lookupSourceID($destination_id_values);
$source_id_values = $this->lookupSourceId($destination_id_values);
if (!empty($source_id_values)) {
foreach ($this->destinationIdFields() as $field_name => $destination_id) {
$map_query->condition($destination_id, $destination_id_values[$field_name]);
......
......@@ -134,7 +134,7 @@ protected function exists($value) {
$idMap = $this->migration->getIdMap();
foreach ($query->execute() as $id) {
$dest_id_values[$this->configuration['field']] = $id;
if ($idMap->lookupSourceID($dest_id_values)) {
if ($idMap->lookupSourceId($dest_id_values)) {
return TRUE;
}
}
......
......@@ -579,7 +579,7 @@ public function testGetRowByDestination() {
}
/**
* Data provider for testLookupSourceIDMapping().
* Data provider for testLookupSourceIdMapping().
*
* Scenarios to test (for both hits and misses) are:
* - Single-value destination ID to single-value source ID.
......@@ -590,7 +590,7 @@ public function testGetRowByDestination() {
* @return array
* An array of data values.
*/
public function lookupSourceIDMappingDataProvider() {
public function lookupSourceIdMappingDataProvider() {
return [
[1, 1],
[2, 2],
......@@ -607,9 +607,9 @@ public function lookupSourceIDMappingDataProvider() {
* @param int $num_destination_fields
* Number of destination fields to test.
*
* @dataProvider lookupSourceIDMappingDataProvider
* @dataProvider lookupSourceIdMappingDataProvider
*/
public function testLookupSourceIDMapping($num_source_fields, $num_destination_fields) {
public function testLookupSourceIdMapping($num_source_fields, $num_destination_fields) {
// Adjust the migration configuration according to the number of source and
// destination fields.
$this->sourceIds = [];
......@@ -635,10 +635,10 @@ public function testLookupSourceIDMapping($num_source_fields, $num_destination_f
$this->saveMap($row);
$id_map = $this->getIdMap();
// Test for a valid hit.
$source_id = $id_map->lookupSourceID($destination_id_values);
$source_id = $id_map->lookupSourceId($destination_id_values);
$this->assertSame($expected_result, $source_id);
// Test for a miss.
$source_id = $id_map->lookupSourceID($nonexistent_id_values);
$source_id = $id_map->lookupSourceId($nonexistent_id_values);
$this->assertSame(0, count($source_id));
}
......
......@@ -198,7 +198,7 @@ public function testDedupeMigrated() {
// Entity 'forums' is pre-existing, entity 'test_vocab' was migrated.
$this->idMap
->method('lookupSourceID')
->method('lookupSourceId')
->will($this->returnValueMap([
[['test_field' => 'forums'], FALSE],
[['test_field' => 'test_vocab'], ['source_id' => 42]],
......
......@@ -197,7 +197,7 @@ public function testMakeUniqueEntityFieldMigrated() {
// Entity 'forums' is pre-existing, entity 'test_vocab' was migrated.
$this->idMap
->method('lookupSourceID')
->method('lookupSourceId')
->will($this->returnValueMap([
[['test_field' => 'forums'], FALSE],
[['test_field' => 'test_vocab'], ['source_id' => 42]],
......
......@@ -38,7 +38,7 @@ public function testNodeType() {
$this->assertIdentical(TRUE, $node_type_page->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_page->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_page->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(['test_page']), ['test_page']);
$this->assertIdentical($id_map->lookupDestinationId(['test_page']), ['test_page']);
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_page', 'body');
......@@ -57,7 +57,7 @@ public function testNodeType() {
$this->assertIdentical(TRUE, $node_type_story->displaySubmitted());
$this->assertIdentical(FALSE, $node_type_story->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_story->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(['test_story']), ['test_story']);
$this->assertIdentical($id_map->lookupDestinationId(['test_story']), ['test_story']);
// Test we don't have a body field.
$field = FieldConfig::loadByName('node', 'test_story', 'body');
......@@ -76,7 +76,7 @@ public function testNodeType() {
$this->assertIdentical(TRUE, $node_type_event->displaySubmitted());
$this->assertIdentical(TRUE, $node_type_event->isNewRevision());
$this->assertIdentical(DRUPAL_OPTIONAL, $node_type_event->getPreviewMode());
$this->assertIdentical($id_map->lookupDestinationID(['test_event']), ['test_event']);
$this->assertIdentical($id_map->lookupDestinationId(['test_event']), ['test_event']);
// Test we have a body field.
$field = FieldConfig::loadByName('node', 'test_event', 'body');
......
......@@ -29,7 +29,7 @@ public function testViewModes() {
$this->assertIdentical(FALSE, is_null($view_mode), 'Preview view mode loaded.');
$this->assertIdentical('Preview', $view_mode->label(), 'View mode has correct label.');
// Test the ID map.
$this->assertIdentical(['node', 'preview'], $this->getMigration('d6_view_modes')->getIdMap()->lookupDestinationID([1]));
$this->assertIdentical(['node', 'preview'], $this->getMigration('d6_view_modes')->getIdMap()->lookupDestinationId([1]));
}
}
......@@ -68,7 +68,7 @@ public function testUrlAlias() {
];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('1', $conditions, $path);
$this->assertIdentical($id_map->lookupDestinationID([$path['pid']]), ['1'], "Test IdMap");
$this->assertIdentical($id_map->lookupDestinationId([$path['pid']]), ['1'], "Test IdMap");
$conditions = [
'source' => '/node/2',
......
......@@ -32,7 +32,7 @@ public function testTaxonomyVocabulary() {
for ($i = 0; $i < 3; $i++) {
$j = $i + 1;
$vocabulary = Vocabulary::load("vocabulary_{$j}_i_{$i}_");
$this->assertSame($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationID([$j]), [$vocabulary->id()]);
$this->assertSame($this->getMigration('d6_taxonomy_vocabulary')->getIdMap()->lookupDestinationId([$j]), [$vocabulary->id()]);
$this->assertSame("vocabulary $j (i=$i)", $vocabulary->label());
$this->assertSame("description of vocabulary $j (i=$i)", $vocabulary->getDescription());
$this->assertSame($i, $vocabulary->getHierarchy());
......
......@@ -45,7 +45,7 @@ public function testVocabularyEntityDisplay() {
$this->assertSame('entity_reference_label', $component['type']);
$this->assertSame(20, $component['weight']);
// Test the Id map.
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationID([4, 'article']));
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_display')->getIdMap()->lookupDestinationId([4, 'article']));
// Tests that a vocabulary named like a D8 base field will be migrated and
// prefixed with 'field_' to avoid conflicts.
......
......@@ -45,7 +45,7 @@ public function testVocabularyEntityFormDisplay() {
$this->assertSame('options_select', $component['type']);
$this->assertSame(20, $component['weight']);
// Test the Id map.
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationID([4, 'article']));
$this->assertSame(['node', 'article', 'default', 'field_tags'], $this->getMigration('d6_vocabulary_entity_form_display')->getIdMap()->lookupDestinationId([4, 'article']));
// Test the term widget tags setting.
$entity_form_display = EntityFormDisplay::load('node.story.default');
......
......@@ -58,7 +58,7 @@ public function testVocabularyFieldInstance() {
$this->assertSame(['field_tags'], $settings['handler_settings']['target_bundles'], 'The target_bundles handler setting is correct.');
$this->assertSame(TRUE, $settings['handler_settings']['auto_create'], 'The "auto_create" setting is correct.');
$this->assertSame(['node', 'article', 'field_tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationID([4, 'article']));
$this->assertSame(['node', 'article', 'field_tags'], $this->getMigration('d6_vocabulary_field_instance')->getIdMap()->lookupDestinationId([4, 'article']));
// Test the the field vocabulary_1_i_0_.
$field_id = 'node.story.field_vocabulary_1_i_0_';
......
......@@ -39,7 +39,7 @@ public function testVocabularyField() {
$this->assertSame('taxonomy_term', $settings['target_type'], "Target type is correct.");
$this->assertSame(1, $field_storage->getCardinality(), "Field cardinality in 1.");
$this->assertSame(['node', 'field_tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationID([4]), "Test IdMap");
$this->assertSame(['node', 'field_tags'], $this->getMigration('d6_vocabulary_field')->getIdMap()->lookupDestinationId([4]), "Test IdMap");
// Tests that a vocabulary named like a D8 base field will be migrated and
// prefixed with 'field_' to avoid conflicts.
......
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