function EntityIsOfBundleTest::testConditionEvaluation
Tests evaluating the condition.
@covers ::evaluate
File
-
tests/
src/ Unit/ Integration/ Condition/ EntityIsOfBundleTest.php, line 35
Class
- EntityIsOfBundleTest
- @coversDefaultClass \Drupal\rules\Plugin\Condition\EntityIsOfBundle @group RulesCondition
Namespace
Drupal\Tests\rules\Unit\Integration\ConditionCode
public function testConditionEvaluation() {
$entity = $this->prophesizeEntity(EntityInterface::class);
$entity->getEntityTypeId()
->willReturn('node')
->shouldBeCalledTimes(3);
$entity->bundle()
->willReturn('page')
->shouldBeCalledTimes(3);
// Add the test node to our context as the evaluated entity, along with
// explicit entity type and bundle strings.
// First, test with values that should evaluate TRUE.
$this->condition
->setContextValue('entity', $entity->reveal())
->setContextValue('type', 'node')
->setContextValue('bundle', 'page');
$this->assertTrue($this->condition
->evaluate());
// Then test with values that should evaluate FALSE.
$this->condition
->setContextValue('bundle', 'article');
$this->assertFalse($this->condition
->evaluate());
$this->condition
->setContextValue('type', 'taxonomy_term')
->setContextValue('bundle', 'page');
$this->assertFalse($this->condition
->evaluate());
}