You are here

class RulesConditionalTestStubContainer in Conditional Rules 8

Same name and namespace in other branches
  1. 7 tests/rules_conditional_test.inc \RulesConditionalTestStubContainer

Test base conditional.

@method RulesConditional test() test().

Hierarchy

Expanded class hierarchy of RulesConditionalTestStubContainer

1 string reference to 'RulesConditionalTestStubContainer'
rules_conditional_test_rules_plugin_info in tests/rules_conditional_test.module
Implements hook_rules_plugin_info().

File

tests/rules_conditional_test.inc, line 12
Testing implementations.

View source
class RulesConditionalTestStubContainer extends RulesConditionalContainer {
  protected $itemName = 'stub conditional';
  protected $interceptMethods = array(
    'test',
  );

  /**
   * Selects the branches to evaluate for this conditional.
   *
   * @param RulesState $state
   *   Rules state to use.
   * @return RulesConditionalElement[]
   *   An array of branches to evaluate.
   */
  protected function selectBranches(RulesState $state) {

    // Pick the first element to pass.
    foreach ($this->children as $element) {
      if ($element
        ->canEvaluate($state)) {
        return array(
          $element,
        );
      }
    }
    return array();
  }

  /**
   * Intercepts the 'test' method.
   */
  protected function call_test() {
    throw new Exception('intercept');
  }

  /**
   * Sets a fluent element.
   */
  public function fluent(RulesActionContainer $element) {
    $this->fluentElement = $element;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RulesConditionalContainer::$fluentElement protected property
RulesConditionalContainer::$providesVariables protected property
RulesConditionalContainer::action public function Adds an action to the active fluent statement.
RulesConditionalContainer::delete public function Deletes the container and its children.
RulesConditionalContainer::dependencies public function
RulesConditionalContainer::destroy public function
RulesConditionalContainer::evaluate public function Evaluates the conditional statement.
RulesConditionalContainer::exportSettings protected function
RulesConditionalContainer::label public function
RulesConditionalContainer::providesVariables public function Provides intersections of variables in all branches, at least one default.
RulesConditionalContainer::resetInternalCache public function
RulesConditionalContainer::stateVariables protected function Declares only parent state variables for individual branches.
RulesConditionalContainer::variableInfoAssertions protected function Asserts no variables (since a conditional is *conditionally* evaluated).
RulesConditionalContainer::__call public function Intercepts calls to magic methods, possibly using reserved keywords.
RulesConditionalTestStubContainer::$interceptMethods protected property Magic methods to intercept. Overrides RulesConditionalContainer::$interceptMethods
RulesConditionalTestStubContainer::$itemName protected property
RulesConditionalTestStubContainer::call_test protected function Intercepts the 'test' method.
RulesConditionalTestStubContainer::fluent public function Sets a fluent element.
RulesConditionalTestStubContainer::selectBranches protected function Selects the branches to evaluate for this conditional. Overrides RulesConditionalContainer::selectBranches