PageRenderTime 42ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Util/Test.php

http://github.com/sebastianbergmann/phpunit
PHP | 38 lines | 22 code | 5 blank | 11 comment | 2 complexity | ab62dc284176086fd008a2ab3ff8a1bf MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php declare(strict_types=1);
  2. /*
  3. * This file is part of PHPUnit.
  4. *
  5. * (c) Sebastian Bergmann <sebastian@phpunit.de>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace PHPUnit\Util;
  11. use function str_starts_with;
  12. use PHPUnit\Metadata\Parser\Registry;
  13. use ReflectionMethod;
  14. /**
  15. * @internal This class is not covered by the backward compatibility promise for PHPUnit
  16. */
  17. final class Test
  18. {
  19. public static function isTestMethod(ReflectionMethod $method): bool
  20. {
  21. if (!$method->isPublic()) {
  22. return false;
  23. }
  24. if (str_starts_with($method->getName(), 'test')) {
  25. return true;
  26. }
  27. $metadata = Registry::parser()->forMethod(
  28. $method->getDeclaringClass()->getName(),
  29. $method->getName()
  30. );
  31. return $metadata->isTest()->isNotEmpty();
  32. }
  33. }