Skip to content

Commit

Permalink
EWPP-4730: Improve ensure of PHPUnit batching.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle committed Oct 14, 2024
1 parent e3bd129 commit 8b0928a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/src/EnsurePHPUnitBatchingTestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Drupal\Tests\oe_theme;

use PHPUnit\Framework\TestCase;
use PHPUnit\Runner\BeforeTestHook;
use PHPUnit\Runner\Exception;

Expand All @@ -21,10 +22,14 @@ class EnsurePHPUnitBatchingTestExtension implements BeforeTestHook {
public function executeBeforeTest(string $test): void {
[$class] = \explode('::', $test);
$reflection = new \ReflectionClass($class);
if (in_array('Throwable', $reflection->getInterfaceNames())) {
if (!$reflection->isSubclassOf(TestCase::class)) {
return;
}
if (!(bool) preg_match('/@group batch(\d+)/', $reflection->getDocComment())) {
$doc_comment = $reflection->getDocComment();
if ($doc_comment === FALSE) {
throw new Exception("The following test has no doc comment: " . $test);
}
if (!(bool) preg_match('/@group batch(\d+)/', $doc_comment)) {
throw new Exception("The following test has not been assigned to a test batch: " . $test);
}
}
Expand Down

0 comments on commit 8b0928a

Please sign in to comment.