Skip to content
Snippets Groups Projects
Commit c6aae3f8 authored by Aaron Bauman's avatar Aaron Bauman
Browse files

WIP: better test coverage for mapping crud form

parent 72a9bed2
No related branches found
No related tags found
No related merge requests found
langcode: en
status: true
dependencies:
config:
- field.storage.node.field_salesforce_test_tax_ref
- node.type.salesforce_mapping_test_content
- taxonomy.vocabulary.salesforce_test_vocabulary
id: node.salesforce_mapping_test_content.field_salesforce_test_tax_ref
field_name: field_salesforce_test_tax_ref
entity_type: node
bundle: salesforce_mapping_test_content
label: 'Salesforce Test Taxonomy Ref'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings:
handler: 'default:taxonomy_term'
handler_settings:
target_bundles:
salesforce_test_vocabulary: salesforce_test_vocabulary
sort:
field: name
direction: asc
auto_create: false
auto_create_bundle: ''
field_type: entity_reference
langcode: en
status: true
dependencies:
module:
- node
- taxonomy
id: node.field_salesforce_test_tax_ref
field_name: field_salesforce_test_tax_ref
entity_type: node
type: entity_reference
settings:
target_type: taxonomy_term
module: core
locked: false
cardinality: -1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
langcode: en
status: true
dependencies: { }
name: 'Salesforce Test Vocabulary'
vid: salesforce_test_vocabulary
description: ''
weight: 0
...@@ -31,9 +31,11 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { ...@@ -31,9 +31,11 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
'salesforce_test_rest_client', 'salesforce_test_rest_client',
'salesforce_mapping', 'salesforce_mapping',
'salesforce_mapping_ui', 'salesforce_mapping_ui',
'salesforce_mapping_test',
'user', 'user',
'link', 'link',
'dynamic_entity_reference', 'dynamic_entity_reference',
'taxonomy',
]; ];
/** /**
...@@ -66,8 +68,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { ...@@ -66,8 +68,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
$post = [ $post = [
'id' => $mapping_name, 'id' => $mapping_name,
'label' => $mapping_name, 'label' => $mapping_name,
'drupal_entity_type' => 'user', 'drupal_entity_type' => 'node',
'drupal_bundle' => 'user', 'drupal_bundle' => 'salesforce_mapping_test_content',
'salesforce_object_type' => 'Contact', 'salesforce_object_type' => 'Contact',
]; ];
$this->drupalPostForm('admin/structure/salesforce/mappings/add', $post, $this->t('Save')); $this->drupalPostForm('admin/structure/salesforce/mappings/add', $post, $this->t('Save'));
...@@ -86,8 +88,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { ...@@ -86,8 +88,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
drupal_flush_all_caches(); drupal_flush_all_caches();
$post = [ $post = [
'label' => $this->randomMachineName(), 'label' => $this->randomMachineName(),
'drupal_entity_type' => 'user', 'drupal_entity_type' => 'node',
'drupal_bundle' => 'user', 'drupal_bundle' => 'salesforce_mapping_test_content',
'salesforce_object_type' => 'Contact', 'salesforce_object_type' => 'Contact',
]; ];
$this->drupalPostForm('admin/structure/salesforce/mappings/manage/' . $mapping_name, $post, $this->t('Save')); $this->drupalPostForm('admin/structure/salesforce/mappings/manage/' . $mapping_name, $post, $this->t('Save'));
...@@ -98,12 +100,25 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase { ...@@ -98,12 +100,25 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
// cause fatal errors. // cause fatal errors.
$mappingFieldsPluginManager = \Drupal::service('plugin.manager.salesforce_mapping_field'); $mappingFieldsPluginManager = \Drupal::service('plugin.manager.salesforce_mapping_field');
$field_plugins = $mappingFieldsPluginManager->getDefinitions(); $field_plugins = $mappingFieldsPluginManager->getDefinitions();
$post = [];
$i = 0;
foreach ($field_plugins as $definition) { foreach ($field_plugins as $definition) {
if (call_user_func([$definition['class'], 'isAllowed'], $mapping)) { if (call_user_func([$definition['class'], 'isAllowed'], $mapping)) {
$post = [ // Add a new field:
'field_type' => $definition['id'], $post['field_type'] = $definition['id'];
];
$this->drupalPostForm('admin/structure/salesforce/mappings/manage/' . $mapping_name . '/fields', $post, $this->t('Add a field mapping to get started')); $this->drupalPostForm('admin/structure/salesforce/mappings/manage/' . $mapping_name . '/fields', $post, $this->t('Add a field mapping to get started'));
// Confirm that the new field shows up:
$this->assertText($definition['label']);
// Add all components of this field plugin to our post array to build up the mapping.
$this->assertField("field_mappings[$i][config][drupal_field_value]");
$this->assertField("field_mappings[$i][config][salesforce_field]");
$this->assertField("field_mappings[$i][config][description]");
$this->assertSession()->hiddenFieldExists("field_mappings[$i][drupal_field_type]");
$this->assertField("field_mappings[$i][config][direction]");
// $post[$field] = '';
// $i++;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment