You are here

abstract class RulesConditionalBaseTestCase in Conditional Rules 8

Same name and namespace in other branches
  1. 7 tests/rules_conditional.test \RulesConditionalBaseTestCase

Base class for conditional rules testing.

Hierarchy

Expanded class hierarchy of RulesConditionalBaseTestCase

File

tests/rules_conditional.test, line 10
SimpleTest testing suites.

View source
abstract class RulesConditionalBaseTestCase extends DrupalWebTestCase {

  /**
   * Asserts a test message from the execution of a rule configuration.
   *
   * @param $error
   * @param RulesPlugin $config
   * @param array $args
   * @param string $message
   */
  protected function assertExecution($error, $config, array $args = array(), $message = '') {
    if (empty($message)) {
      $message = t('Message "@error" captured by executing rule configuration.', array(
        '@error' => $error,
      ));
    }
    try {
      $config
        ->executeByArgs($args);
      return $this
        ->fail($message);
    } catch (RulesConditionalTestException $ex) {
      return $this
        ->assertEqual($error, $ex
        ->getMessage(), $message);
    }
  }

  /**
   * Retrieves a file in the test directory.
   */
  protected function getFileContents($fileName) {
    $filePath = drupal_get_path('module', 'rules_conditional_test') . '/' . $fileName;
    return file_get_contents($filePath);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesConditionalBaseTestCase::assertExecution protected function Asserts a test message from the execution of a rule configuration.
RulesConditionalBaseTestCase::getFileContents protected function Retrieves a file in the test directory.