Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TestSuite.php

function TestSuite::fromClassReflector

3 calls to TestSuite::fromClassReflector()
TestSuite::addTestSuite in vendor/phpunit/phpunit/src/Framework/TestSuite.php
Adds the tests from the given class to the suite.
TestSuite::fromClassName in vendor/phpunit/phpunit/src/Framework/TestSuite.php
@psalm-param class-string $className
TestSuiteBuilder::testSuiteFromPath in vendor/phpunit/phpunit/src/TextUI/Configuration/TestSuiteBuilder.php
@psalm-param non-empty-string $path @psalm-param list<non-empty-string> $suffixes @psalm-param ?TestSuite $suite

File

vendor/phpunit/phpunit/src/Framework/TestSuite.php, line 109

Class

TestSuite
@template-implements IteratorAggregate<int, Test>

Namespace

PHPUnit\Framework

Code

public static function fromClassReflector(ReflectionClass $class) : static {
    $testSuite = new static($class->getName());
    $constructor = $class->getConstructor();
    if ($constructor !== null && !$constructor->isPublic()) {
        Event\Facade::emitter()->testRunnerTriggeredWarning(sprintf('Class "%s" has no public constructor.', $class->getName()));
        return $testSuite;
    }
    foreach (Reflection::publicMethodsInTestClass($class) as $method) {
        if ($method->getDeclaringClass()
            ->getName() === Assert::class) {
            continue;
        }
        if ($method->getDeclaringClass()
            ->getName() === TestCase::class) {
            continue;
        }
        if (!TestUtil::isTestMethod($method)) {
            continue;
        }
        $testSuite->addTestMethod($class, $method);
    }
    if ($testSuite->isEmpty()) {
        Event\Facade::emitter()->testRunnerTriggeredWarning(sprintf('No tests found in class "%s".', $class->getName()));
    }
    return $testSuite;
}
RSS feed
Powered by Drupal