DrupalComponentTestListenerTrait.php in Drupal 10
File
core/tests/Drupal/Tests/Listeners/DrupalComponentTestListenerTrait.php
View source
<?php
namespace Drupal\Tests\Listeners;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\UnitTestCase;
use PHPUnit\Framework\AssertionFailedError;
trait DrupalComponentTestListenerTrait {
protected function componentEndTest($test, $time) {
if (substr($test
->toString(), 0, 22) == 'Drupal\\Tests\\Component') {
if ($test instanceof BrowserTestBase || $test instanceof KernelTestBase || $test instanceof UnitTestCase) {
$error = new AssertionFailedError('Component tests should not extend a core test base class.');
$test
->getTestResultObject()
->addFailure($test, $error, $time);
}
}
}
}