function StageEventsTest::testExceptionIfNoErrorBeforeStopPropagation

Tests exception is thrown if error is not added before stopPropagation().

File

core/modules/package_manager/tests/src/Kernel/StageEventsTest.php, line 208

Class

StageEventsTest
Tests that the stage fires events during its lifecycle.

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testExceptionIfNoErrorBeforeStopPropagation() : void {
    $listener = function (PreCreateEvent $event) : void {
        $event->stopPropagation();
    };
    $this->addEventTestListener($listener, PreCreateEvent::class);
    $this->expectException(SandboxEventException::class);
    $this->expectExceptionMessage('Event propagation stopped without any errors added to the event. This bypasses the package_manager validation system.');
    $stage = $this->createStage();
    $stage->create();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.