You are here

function WebformClearSubmissionTestCase::webformSubmissionExecute in Webform Clear 7.2

Execute the submission test.

Parameters

int $add_time: Seconds to add to the current time (used to fake cron running in the future).

int $override_clear_time: Override default clear time.

1 call to WebformClearSubmissionTestCase::webformSubmissionExecute()
WebformClearSubmissionTestCase::testWebformClear in ./webform_clear.test
Test submissions with different webform clear options.

File

./webform_clear.test, line 115

Class

WebformClearSubmissionTestCase

Code

function webformSubmissionExecute($add_time = 0, $override_clear_time = NULL) {
  $path = drupal_get_path('module', 'webform');
  module_load_include('inc', 'webform', 'includes/webform.submissions');
  $node = $this
    ->testWebformForm();

  // Set up new clear times.
  $edit = array();
  if (isset($override_clear_time)) {
    $edit = array(
      'clear_time' => $override_clear_time,
    );
  }
  $this
    ->drupalPost('node/' . $node->nid . '/webform/configure', $edit, 'Save configuration');
  $submission_values = array();

  // Visit the node page with the "foo=bar" query, to test %get[] default values.
  $this
    ->drupalGet('node/' . $node->nid, array(
    'query' => array(
      'foo' => 'bar',
    ),
  ));

  // Submit our test data.
  $this
    ->drupalPost(NULL, $submission_values, 'Submit', array(), array(), 'webform-client-form-' . $node->nid);

  // Get the SID of the new submission.
  $matches = array();
  preg_match('/sid=([0-9]+)/', $this
    ->getUrl(), $matches);
  $sid = $matches[1];

  // Check if submission exists.
  $submission_exists_before = !empty(webform_get_submission($node->nid, $sid, TRUE));
  _webform_clear_current_time($add_time);

  // Run the Webform Clear cron.
  webform_clear_cron();

  // Reset the time to add.
  _webform_clear_current_time(0);
  $submission_exists_after = !empty(webform_get_submission($node->nid, $sid, TRUE));
  return array(
    $submission_exists_before,
    $submission_exists_after,
  );
}