From 9bba2c902a72f6bead4a21b80a525b31837cbbe0 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 8 Nov 2018 06:02:52 -0500 Subject: [PATCH] Only run isBeforeClassMethod(), isBeforeMethod(), isAfterMethod(), and isAfterClassMethod() on likely candidates --- src/Util/Test.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Util/Test.php b/src/Util/Test.php index c0c1ec78f63..fe23e05b739 100644 --- a/src/Util/Test.php +++ b/src/Util/Test.php @@ -10,6 +10,7 @@ namespace PHPUnit\Util; use PharIo\Version\VersionConstraintParser; +use PHPUnit\Framework\Assert; use PHPUnit\Framework\CodeCoverageException; use PHPUnit\Framework\Exception; use PHPUnit\Framework\InvalidCoversTargetException; @@ -706,6 +707,14 @@ public static function getHookMethods(string $className): array $class = new ReflectionClass($className); foreach ($class->getMethods() as $method) { + if ($method->getDeclaringClass()->getName() === Assert::class) { + continue; + } + + if ($method->getDeclaringClass()->getName() === TestCase::class) { + continue; + } + if (self::isBeforeClassMethod($method)) { \array_unshift( self::$hookMethods[$className]['beforeClass'],