function AndExpressionTest::testTwoConditions

Tests two true conditions.

File

tests/src/Unit/AndExpressionTest.php, line 58

Class

AndExpressionTest
@coversDefaultClass \Drupal\rules\Plugin\RulesExpression\AndExpression[[api-linebreak]] @group Rules

Namespace

Drupal\Tests\rules\Unit

Code

public function testTwoConditions() {
  // The method on the test condition must be called once.
  $this->trueConditionExpression
    ->executeWithState(Argument::type(ExecutionStateInterface::class))
    ->shouldBeCalledTimes(1);
  $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)
    ->shouldBeCalledTimes(1);
  $this->and
    ->addExpressionObject($this->trueConditionExpression
    ->reveal())
    ->addExpressionObject($second_condition->reveal());
  $this->assertTrue($this->and
    ->execute(), 'Two conditions returns TRUE.');
}