function DrupalListener::startTest
Same name in other branches
- 8.9.x core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit6/DrupalListener.php \Drupal\TestTools\PhpUnitCompatibility\PhpUnit6\DrupalListener::startTest()
- 8.9.x core/tests/Drupal/TestTools/PhpUnitCompatibility/PhpUnit7/DrupalListener.php \Drupal\TestTools\PhpUnitCompatibility\PhpUnit7\DrupalListener::startTest()
- 10 core/tests/Drupal/Tests/Listeners/DrupalListener.php \Drupal\Tests\Listeners\DrupalListener::startTest()
- 11.x core/tests/Drupal/Tests/Listeners/DrupalListener.php \Drupal\Tests\Listeners\DrupalListener::startTest()
File
-
core/
tests/ Drupal/ Tests/ Listeners/ DrupalListener.php, line 78
Class
- DrupalListener
- Listens to PHPUnit test runs.
Namespace
Drupal\Tests\ListenersCode
public function startTest(Test $test) : void {
// Check for deprecated @expectedDeprecation annotations before the
// Symfony error handler has a chance to swallow this deprecation notice.
$annotations = UtilTest::parseTestMethodAnnotations(get_class($test), $test->getName(FALSE));
if (isset($annotations['method']['expectedDeprecation'])) {
@trigger_error('The @expectedDeprecation annotation on ' . get_class($test) . '::' . $test->getName(FALSE) . '() is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. Use the expectDeprecation() method instead. See https://www.drupal.org/node/3176667', E_USER_DEPRECATED);
}
// The Drupal error handler has to be registered prior to the Symfony error
// handler that is registered in
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::startTest()
// that handles expected deprecations.
$this->registerErrorHandler();
$this->symfonyListener
->startTest($test);
// Check for missing void return typehints in concrete test classes'
// methods. If the method is inherited from a base test class, do
// nothing.
$class = new \ReflectionClass($test);
foreach ($this->methodsWithVoidReturn as $method) {
if ($class->hasMethod($method)) {
$reflected_method = $class->getMethod($method);
if ($reflected_method->getDeclaringClass()
->getName() === get_class($test)) {
if (!$reflected_method->hasReturnType() || $reflected_method->getReturnType()
->getName() !== 'void') {
@trigger_error("Declaring ::{$method} without a void return typehint in " . get_class($test) . " is deprecated in drupal:9.0.0. Typehinting will be required before drupal:10.0.0. See https://www.drupal.org/node/3114724", E_USER_DEPRECATED);
}
}
}
}
// Check for incorrect visibility of the $modules property.
if ($class->hasProperty('modules') && !$class->getProperty('modules')
->isProtected()) {
@trigger_error('The ' . get_class($test) . '::$modules property must be declared protected. See https://www.drupal.org/node/2909426', E_USER_DEPRECATED);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.