You are here

public function NodeIsPublishedTest::testConditionEvaluation in Rules 8.3

Tests evaluating the condition.

@covers ::evaluate

File

tests/src/Unit/Integration/Condition/NodeIsPublishedTest.php, line 36

Class

NodeIsPublishedTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\NodeIsPublished @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

public function testConditionEvaluation() {
  $published_node = $this
    ->prophesizeEntity(NodeInterface::class);
  $published_node
    ->isPublished()
    ->willReturn(TRUE)
    ->shouldBeCalledTimes(1);

  // Set the node context value.
  $this->condition
    ->setContextValue('node', $published_node
    ->reveal());
  $this
    ->assertTrue($this->condition
    ->evaluate());
  $unpublished_node = $this
    ->prophesizeEntity(NodeInterface::class);
  $unpublished_node
    ->isPublished()
    ->willReturn(FALSE)
    ->shouldBeCalledTimes(1);

  // Set the node context value.
  $this->condition
    ->setContextValue('node', $unpublished_node
    ->reveal());
  $this
    ->assertFalse($this->condition
    ->evaluate());
}