You are here

public function IntegrityCheckTest::testMissingCondition in Rules 8.3

Tests that a missing condition plugin ID results in a violation.

File

tests/src/Unit/Integration/Engine/IntegrityCheckTest.php, line 102

Class

IntegrityCheckTest
Test the integrity check functionality during configuration time.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testMissingCondition() {
  $rule = $this->rulesExpressionManager
    ->createRule();
  $condition = $this->rulesExpressionManager
    ->createCondition('');
  $rule
    ->addExpressionObject($condition);
  $violations = RulesComponent::create($rule)
    ->checkIntegrity();
  $this
    ->assertEquals(1, iterator_count($violations));
  $this
    ->assertEquals('Condition plugin ID is missing', (string) $violations[0]
    ->getMessage());
  $this
    ->assertEquals($condition
    ->getUuid(), $violations[0]
    ->getUuid());
}