public function NodeIsOfTypeTest::testConditionEvaluation in Rules 8.3
Tests evaluating the condition.
@covers ::evaluate
File
- tests/
src/ Unit/ Integration/ Condition/ NodeIsOfTypeTest.php, line 36
Class
- NodeIsOfTypeTest
- @coversDefaultClass \Drupal\rules\Plugin\Condition\NodeIsOfType @group RulesCondition
Namespace
Drupal\Tests\rules\Unit\Integration\ConditionCode
public function testConditionEvaluation() {
$node = $this
->prophesizeEntity(NodeInterface::class);
$node
->getType()
->willReturn('page');
// Set the node context value.
$this->condition
->setContextValue('node', $node
->reveal());
// Test evaluation with a list that contains the actual node type.
$this->condition
->setContextValue('types', [
'page',
'article',
]);
$this
->assertTrue($this->condition
->evaluate());
// Test with a list that does not contain the actual node type.
$this->condition
->setContextValue('types', [
'apple',
'banana',
]);
$this
->assertFalse($this->condition
->evaluate());
}