You are here

public function RuleExpressionTest::testTwoConditionsTrue in Rules 8.3

Tests that an action fires if a condition passes.

@covers ::execute

File

tests/src/Unit/RuleExpressionTest.php, line 141

Class

RuleExpressionTest
@coversDefaultClass \Drupal\rules\Plugin\RulesExpression\RuleExpression @group Rules

Namespace

Drupal\Tests\rules\Unit

Code

public function testTwoConditionsTrue() {

  // The method on the test action must be called once.
  $this->testActionExpression
    ->executeWithState(Argument::type(ExecutionStateInterface::class))
    ->shouldBeCalledTimes(1);
  $this->trueConditionExpression
    ->getWeight()
    ->willReturn(0);
  $second_condition = $this
    ->prophesize(ConditionExpressionInterface::class);
  $second_condition
    ->getUuid()
    ->willReturn('true_uuid2');
  $second_condition
    ->getWeight()
    ->willReturn(0);
  $second_condition
    ->executeWithState(Argument::type(ExecutionStateInterface::class))
    ->willReturn(TRUE);
  $this->rule
    ->addExpressionObject($this->trueConditionExpression
    ->reveal())
    ->addExpressionObject($second_condition
    ->reveal())
    ->addExpressionObject($this->testActionExpression
    ->reveal())
    ->execute();
}