You are here

public function RulesConditionContainerTest::testDeletingNestedCondition in Rules 8.3

Tests deleting a nested condition from the container.

File

tests/src/Unit/RulesConditionContainerTest.php, line 153

Class

RulesConditionContainerTest
@coversDefaultClass \Drupal\rules\Engine\ConditionExpressionContainer @group Rules

Namespace

Drupal\Tests\rules\Unit

Code

public function testDeletingNestedCondition() {
  $container = $this
    ->getMockForAbstractClass(RulesConditionContainerTestStub::class, [
    [],
    'test_id',
    [],
    $this
      ->prophesize(ExpressionManagerInterface::class)
      ->reveal(),
    $this
      ->prophesize(LoggerChannelInterface::class)
      ->reveal(),
  ], '', TRUE);
  $container
    ->addExpressionObject($this->trueConditionExpression
    ->reveal());
  $nested_container = $this
    ->getMockForAbstractClass(RulesConditionContainerTestStub::class, [
    [],
    'test_id',
    [],
    $this
      ->prophesize(ExpressionManagerInterface::class)
      ->reveal(),
    $this
      ->prophesize(LoggerChannelInterface::class)
      ->reveal(),
  ], '', TRUE);
  $nested_container
    ->addExpressionObject($this->falseConditionExpression
    ->reveal());
  $container
    ->addExpressionObject($nested_container);
  $uuid = $this->falseConditionExpression
    ->reveal()
    ->getUuid();
  $this
    ->assertTrue($container
    ->deleteExpression($uuid));
  $this
    ->assertEquals(0, count($nested_container
    ->getIterator()));
}