public function WebformLocalizationSubmissionTestCase::webformSubmissionExecute in Webform Localization 7.4
Execute the submission test.
Parameters
object $node: The webform node used to submit the values.
string $value_type: The values to be submitted to the webform. Either "sample" or "default".
1 call to WebformLocalizationSubmissionTestCase::webformSubmissionExecute()
- WebformLocalizationSubmissionTestCase::testLocalizedSubmission in tests/
webform_localization.submission.test - Create a webform with translations, and performs some submissions.
File
- tests/
webform_localization.submission.test, line 125 - This file contains test classes for testing localized webform submissions.
Class
- WebformLocalizationSubmissionTestCase
- Abstract class that defines the actual tests.
Code
public function webformSubmissionExecute($node, $value_type = 'sample') {
module_load_include('inc', 'webform', 'includes/webform.submissions');
$submission_values = $this
->webformPost($value_type);
// Visit the node page with the "foo=bar" query, to test
// [current-page:query:?] default values.
$this
->drupalGet('node/' . $node->nid, array(
'query' => array(
'foo' => 'bar',
),
));
$this
->assertText($node->title, t('Webform node created and accessible at !url', array(
'!url' => 'node/' . $node->nid,
)), t('Webform'));
// Submit our test data.
$this
->drupalPost(NULL, $submission_values, 'Submit', array(), array(), 'webform-client-form-' . $node->nid);
// Confirm that the submission has been created.
$webform = $this
->createWebformForm()->webform;
$this
->assertText(t($webform['confirmation']), t('Confirmation message "@confirmation" received.', array(
'@confirmation' => t($webform['confirmation']),
)), t('Webform'));
// Get the SID of the new submission.
$matches = array();
preg_match('/sid=([0-9]+)/', $this
->getUrl(), $matches);
$sid = $matches[1];
// Pull in the database submission and check the values.
drupal_static_reset('webform_get_submission');
$actual_submission = webform_get_submission($node->nid, $sid);
$component_info = $this->wtc
->webformComponents();
foreach ($node->webform['components'] as $cid => $component) {
$stable_value = $value_type == 'sample' ? $component_info[$component['form_key']]['database values'] : $component_info[$component['form_key']]['database default values'];
$actual_value = $actual_submission->data[$cid];
$result = $this
->assertEqual($stable_value, $actual_value, t('Component @form_key data integrity check when using @type values.', array(
'@form_key' => $component['form_key'],
'@type' => $value_type,
)), t('Webform'));
if (!$result || $result === 'fail') {
$this
->fail(t('Expected !expected', array(
'!expected' => print_r($stable_value, TRUE),
)) . "\n\n" . t('Received !received', array(
'!received' => print_r($actual_value, TRUE),
)), t('Webform'));
}
}
}