function ExpectDeprecationTrait::setUpErrorHandler

Sets up the test error handler.

This method is run before each test's ::setUp() method, and when the DeprecationHandler is active, resets the extension to be able to collect the test's deprecations, and sets TestErrorHandler as the current error handler.

See also

\Drupal\TestTools\ErrorHandler\TestErrorHandler

File

core/tests/Drupal/TestTools/Extension/DeprecationBridge/ExpectDeprecationTrait.php, line 37

Class

ExpectDeprecationTrait
A trait to include in Drupal tests to manage expected deprecations.

Namespace

Drupal\TestTools\Extension\DeprecationBridge

Code

public function setUpErrorHandler() : void {
    if (!DeprecationHandler::isEnabled()) {
        return;
    }
    DeprecationHandler::reset();
    set_error_handler(new TestErrorHandler(Error::currentErrorHandler(), $this));
}

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