You are here

function PatternsTestCase::quickRun in Patterns 7.2

Same name and namespace in other branches
  1. 7 tests/patterns.test \PatternsTestCase::quickRun()

Runs a pattern through the Quick Run interface and checks the output screen for errors messages.

Parameters

mixed $pattern A string representation of a pattern:

mixed $name An alphanumeric name or short sentence: to be displayed next to the test results

mixed $format (optional) The format of the pattern: to be executed. Defaults 'yaml' for historical reasons

bool $valid (optional) If TRUE, it assumed that the executed: pattern should not raise errors. Defaults TRUE

mixed $mode (optional) The execution mode of the pattern: Defaults 'php'

1 call to PatternsTestCase::quickRun()
PatternsTestCase::runFile in tests/patterns.test
Loads a pattern file and runs it.

File

tests/patterns.test, line 120
The base of the Patterns Component tests.

Class

PatternsTestCase
Abstract base class for testing pattern component behavior.

Code

function quickRun($pattern, $name, $format = 'yaml', $valid = TRUE, $mode = 'php') {

  // Fill the form.
  $edit = array();
  $edit['format'] = $format;
  $edit['mode'] = $mode;
  $edit['content'] = $pattern;

  // Post the form.
  $this
    ->drupalPost('admin/patterns/quickrun', $edit, t('Run'));
  if ($valid) {

    // Check for a valid syntax run.
    $this
      ->assertUniqueText(t('ran successfully.', array(
      '@pattern' => $name,
    )), t('Valid pattern runs without errors.'));
    $this
      ->assertNoText(t('Error(s) while processing pattern:'), t('Valid pattern does not produce errors.'));
  }
  else {
    $this
      ->assertUniqueText(t('Error(s) while processing pattern:'), t('Invalid pattern produces errors.'));
    $this
      ->assertNoText(t('ran successfully.', array(
      '@pattern' => $name,
    )), t('Invalid pattern does not run without errors.'));
  }
}