function RulesConditionContainerTest::testDeletingNestedCondition

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->assertCount(0, $nested_container->getIterator());
}