Loading core/modules/system/tests/src/Kernel/Theme/ThemeEngineTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; // cspell:ignore nyan Loading @@ -15,6 +16,7 @@ */ #[IgnoreDeprecations] #[Group('Theme')] #[RunTestsInSeparateProcesses] class ThemeEngineTest extends KernelTestBase { /** Loading core/phpstan.neon.dist +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ parameters: - phpstan-tmp/* # Skip Drupal's own PHPStan rules test fixtures. - tests/PHPStan/fixtures/* # Skip Drupal's own PHPStan vendor directory - tests/PHPStan/vendor/* # Skip Drupal 6 & 7 code. - scripts/dump-database-d?.sh - scripts/generate-d?-content.sh Loading core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ public function testTearDownWithoutSetUp(): void { /** * A class extending BrowserTestBase for testing purposes. * * @phpstan-ignore testClass.missingAttribute.Group, testClass.missingAttribute.RunInSeparateProcesses */ class BrowserTestBaseMockableClassTest extends BrowserTestBase { Loading core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public function testCapabilities($expected, ?string $mink_driver_args_webdriver, $this->putEnv("MINK_DRIVER_ARGS_WEBDRIVER", $mink_driver_args_webdriver); $this->putEnv("MINK_DRIVER_ARGS", $mink_driver_args); // @phpstan-ignore testClass.missingAttribute.Group, testClass.missingAttribute.RunInSeparateProcesses $object = new class('test') extends WebDriverTestBase { }; $method = new \ReflectionMethod($object, 'getMinkDriverArgs'); Loading core/tests/PHPStan/Rules/TestClassClassMetadata.php +36 −0 Original line number Diff line number Diff line Loading @@ -6,12 +6,16 @@ // cspell:ignore analyse testdox use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\BrowserTestBase; use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use PHPUnit\Framework\TestCase; /** Loading Loading @@ -128,6 +132,38 @@ public function processNode(Node $node, Scope $scope): array { } } } // Concrete test classes should have the Group attribute and in some cases // the RunTestsInSeparateProcesses attribute. $has_group_attribute = FALSE; $has_run_in_separate_process_attribute = FALSE; foreach ($class->getAttributes() as $attribute) { switch ($attribute->getName()) { case Group::class: $has_group_attribute = TRUE; break; case RunTestsInSeparateProcesses::class: $has_run_in_separate_process_attribute = TRUE; break; } } $should_run_in_separate_process = $class->isSubclassOfClass($this->reflectionProvider->getClass(BrowserTestBase::class)) || $class->isSubclassOfClass($this->reflectionProvider->getClass(KernelTestBase::class)); if ($should_run_in_separate_process && !$has_run_in_separate_process_attribute) { $fails[] = RuleErrorBuilder::message("Test class {$class->getName()} must have attribute \PHPUnit\Framework\Attributes\RunInSeparateProcesses.") ->identifier('testClass.missingAttribute.RunInSeparateProcesses') ->line($node->getStartLine()) ->build(); } if (!$has_group_attribute) { $fails[] = RuleErrorBuilder::message("Test class {$class->getName()} must have attribute \PHPUnit\Framework\Attributes\Group.") ->identifier('testClass.missingAttribute.Group') ->line($node->getStartLine()) ->build(); } } return $fails; Loading Loading
core/modules/system/tests/src/Kernel/Theme/ThemeEngineTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -7,6 +7,7 @@ use Drupal\KernelTests\KernelTestBase; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; // cspell:ignore nyan Loading @@ -15,6 +16,7 @@ */ #[IgnoreDeprecations] #[Group('Theme')] #[RunTestsInSeparateProcesses] class ThemeEngineTest extends KernelTestBase { /** Loading
core/phpstan.neon.dist +2 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,8 @@ parameters: - phpstan-tmp/* # Skip Drupal's own PHPStan rules test fixtures. - tests/PHPStan/fixtures/* # Skip Drupal's own PHPStan vendor directory - tests/PHPStan/vendor/* # Skip Drupal 6 & 7 code. - scripts/dump-database-d?.sh - scripts/generate-d?-content.sh Loading
core/tests/Drupal/Tests/Core/Test/BrowserTestBaseTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -102,6 +102,8 @@ public function testTearDownWithoutSetUp(): void { /** * A class extending BrowserTestBase for testing purposes. * * @phpstan-ignore testClass.missingAttribute.Group, testClass.missingAttribute.RunInSeparateProcesses */ class BrowserTestBaseMockableClassTest extends BrowserTestBase { Loading
core/tests/Drupal/Tests/Core/Test/WebDriverTestBaseTest.php +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ public function testCapabilities($expected, ?string $mink_driver_args_webdriver, $this->putEnv("MINK_DRIVER_ARGS_WEBDRIVER", $mink_driver_args_webdriver); $this->putEnv("MINK_DRIVER_ARGS", $mink_driver_args); // @phpstan-ignore testClass.missingAttribute.Group, testClass.missingAttribute.RunInSeparateProcesses $object = new class('test') extends WebDriverTestBase { }; $method = new \ReflectionMethod($object, 'getMinkDriverArgs'); Loading
core/tests/PHPStan/Rules/TestClassClassMetadata.php +36 −0 Original line number Diff line number Diff line Loading @@ -6,12 +6,16 @@ // cspell:ignore analyse testdox use Drupal\KernelTests\KernelTestBase; use Drupal\Tests\BrowserTestBase; use PhpParser\Node; use PHPStan\Analyser\Scope; use PHPStan\Node\InClassNode; use PHPStan\Reflection\ReflectionProvider; use PHPStan\Rules\Rule; use PHPStan\Rules\RuleErrorBuilder; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses; use PHPUnit\Framework\TestCase; /** Loading Loading @@ -128,6 +132,38 @@ public function processNode(Node $node, Scope $scope): array { } } } // Concrete test classes should have the Group attribute and in some cases // the RunTestsInSeparateProcesses attribute. $has_group_attribute = FALSE; $has_run_in_separate_process_attribute = FALSE; foreach ($class->getAttributes() as $attribute) { switch ($attribute->getName()) { case Group::class: $has_group_attribute = TRUE; break; case RunTestsInSeparateProcesses::class: $has_run_in_separate_process_attribute = TRUE; break; } } $should_run_in_separate_process = $class->isSubclassOfClass($this->reflectionProvider->getClass(BrowserTestBase::class)) || $class->isSubclassOfClass($this->reflectionProvider->getClass(KernelTestBase::class)); if ($should_run_in_separate_process && !$has_run_in_separate_process_attribute) { $fails[] = RuleErrorBuilder::message("Test class {$class->getName()} must have attribute \PHPUnit\Framework\Attributes\RunInSeparateProcesses.") ->identifier('testClass.missingAttribute.RunInSeparateProcesses') ->line($node->getStartLine()) ->build(); } if (!$has_group_attribute) { $fails[] = RuleErrorBuilder::message("Test class {$class->getName()} must have attribute \PHPUnit\Framework\Attributes\Group.") ->identifier('testClass.missingAttribute.Group') ->line($node->getStartLine()) ->build(); } } return $fails; Loading