Namespace
Drupal\Tests\rules\Unit\Integration\Condition
File
-
tests/src/Unit/Integration/Condition/EntityIsOfBundleTest.php
View source
<?php
namespace Drupal\Tests\rules\Unit\Integration\Condition;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Tests\rules\Unit\Integration\RulesEntityIntegrationTestBase;
class EntityIsOfBundleTest extends RulesEntityIntegrationTestBase {
protected $condition;
protected function setUp() : void {
parent::setUp();
$this->condition = $this->conditionManager
->createInstance('rules_entity_is_of_bundle');
}
public function testConditionEvaluation() {
$entity = $this->prophesizeEntity(EntityInterface::class);
$entity->getEntityTypeId()
->willReturn('node')
->shouldBeCalledTimes(3);
$entity->bundle()
->willReturn('page')
->shouldBeCalledTimes(3);
$this->condition
->setContextValue('entity', $entity->reveal())
->setContextValue('type', 'node')
->setContextValue('bundle', 'page');
$this->assertTrue($this->condition
->evaluate());
$this->condition
->setContextValue('bundle', 'article');
$this->assertFalse($this->condition
->evaluate());
$this->condition
->setContextValue('type', 'taxonomy_term')
->setContextValue('bundle', 'page');
$this->assertFalse($this->condition
->evaluate());
}
}
Classes
| Title |
Deprecated |
Summary |
| EntityIsOfBundleTest |
|
@coversDefaultClass \Drupal\rules\Plugin\Condition\EntityIsOfBundle[[api-linebreak]]
@group RulesCondition |