Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
salesforce-3257058
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
salesforce-3257058
Commits
247335f0
Commit
247335f0
authored
4 years ago
by
Aaron Bauman
Browse files
Options
Downloads
Patches
Plain Diff
Adds better test coverage for fields form. This will be failing now. Need to fix elsewhere
parent
c6aae3f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php
+24
-11
24 additions, 11 deletions
...ce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php
with
24 additions
and
11 deletions
modules/salesforce_mapping_ui/src/Tests/SalesforceMappingCrudFormTest.php
+
24
−
11
View file @
247335f0
...
...
@@ -73,11 +73,8 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
'salesforce_object_type'
=>
'Contact'
,
];
$this
->
drupalPostForm
(
'admin/structure/salesforce/mappings/add'
,
$post
,
$this
->
t
(
'Save'
));
$
newurl
=
parse_url
(
$this
->
getUrl
(
));
$
this
->
assertSession
()
->
pageTextContainsOnce
(
$this
->
t
(
'The mapping has been successfully saved.'
));
// Make sure the redirect was correct (and therefore form was submitted
// successfully).
$this
->
assertEqual
(
$newurl
[
'path'
],
$base_path
.
'admin/structure/salesforce/mappings/manage/'
.
$mapping_name
.
'/fields'
);
$mapping
=
$mappingStorage
->
load
(
$mapping_name
);
// Make sure mapping was saved correctly.
$this
->
assertEqual
(
$mapping
->
id
(),
$mapping_name
);
...
...
@@ -103,25 +100,41 @@ class SalesforceMappingCrudFormTest extends BrowserTestBase {
$post
=
[];
$i
=
0
;
$this
->
drupalGet
(
'admin/structure/salesforce/mappings/manage/'
.
$mapping_name
.
'/fields'
);
foreach
(
$field_plugins
as
$definition
)
{
if
(
call_user_func
([
$definition
[
'class'
],
'isAllowed'
],
$mapping
))
{
// Add a new field:
$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'
));
$post
[
'
buttons[
field_type
]
'
]
=
$definition
[
'id'
];
$this
->
drupalPostForm
(
NULL
,
$post
,
$this
->
t
(
'Add a field mapping to get started'
));
// Confirm that the new field shows up:
$this
->
assertText
(
$definition
[
'label'
]);
// @TODO need an interface for field plugins that will tell us which config values are applicable.
// Add all components of this field plugin to our post array to build up the mapping.
$this
->
assert
Field
(
"
field_mappings[
$i
][config][drupal_field_value]"
);
$this
->
assert
Field
(
"
field_mappings[
$i
][config][salesforce_field]"
);
$this
->
assert
ElementPresent
(
"[name='field_mappings[
$i
][config][drupal_field_value]'], [name='
field_mappings[
$i
][config][drupal_field_value]
[setting]']
"
);
$this
->
assert
ElementPresent
(
"[name='
field_mappings[
$i
][config][salesforce_field]
'], [name='field_mappings[
$i
][config][drupal_constant]']
"
);
$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++;
$this
->
assertSession
()
->
hiddenFieldExists
(
"field_mappings[
$i
][drupal_field_type]"
);
if
(
$this
->
getSession
()
->
getPage
()
->
find
(
'css'
,
"select[name='field_mappings[
$i
][config][salesforce_field]'] option[value='LastName']"
))
{
$post
[
"field_mappings[
$i
][config][salesforce_field]"
]
=
'LastName'
;
}
if
(
$this
->
getSession
()
->
getPage
()
->
find
(
'css'
,
"select[name='field_mappings[
$i
][config][drupal_field_value]'] option[value='title']"
))
{
$post
[
"field_mappings[
$i
][config][drupal_field_value]"
]
=
'title'
;
}
$i
++
;
}
}
// Confirm that form saves correctly.
$this
->
drupalPostForm
(
NULL
,
$post
,
$this
->
t
(
'Save'
));
$this
->
assertSession
()
->
pageTextContainsOnce
(
$this
->
t
(
'The mapping has been successfully saved.'
));
// Confirm that the changes are stored properly by reloading and counting the fields.
$this
->
drupalGet
(
'admin/structure/salesforce/mappings/manage/'
.
$mapping_name
.
'/fields'
);
for
(
$j
=
0
;
$j
<
$i
;
$j
++
)
{
$this
->
assertSession
()
->
elementExists
(
'css'
,
"#edit-field-mappings-
$j
"
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment