You are here

public function NodeIsStickyTest::testConditionEvaluation in Rules 8.3

Tests evaluating the condition.

@covers ::evaluate

File

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

Class

NodeIsStickyTest
@coversDefaultClass \Drupal\rules\Plugin\Condition\NodeIsSticky @group RulesCondition

Namespace

Drupal\Tests\rules\Unit\Integration\Condition

Code

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

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

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