function TestSubscriber::setException

Sets an exception to throw for a specific event.

This method is static to enable setting the expected results before this module is enabled.

Parameters

\Throwable|null $error: The exception to throw, or NULL to delete a stored exception.

string $event: The event class.

2 calls to TestSubscriber::setException()
StageBaseTest::testLoggedOnError in core/modules/package_manager/tests/src/Kernel/StageBaseTest.php
@covers \Drupal\package_manager\StageBase::dispatch
StageOwnershipTest::testClaim in core/modules/package_manager/tests/src/Kernel/StageOwnershipTest.php
Tests behavior of claiming a stage.

File

core/modules/package_manager/tests/modules/package_manager_test_validation/src/EventSubscriber/TestSubscriber.php, line 94

Class

TestSubscriber
Defines an event subscriber for testing validation of Package Manager events.

Namespace

Drupal\package_manager_test_validation\EventSubscriber

Code

public static function setException(?\Throwable $error, string $event) : void {
    $key = self::getStateKey($event);
    $state = \Drupal::state();
    if (isset($error)) {
        $state->set($key, $error);
    }
    else {
        $state->delete($key);
    }
}

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