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

Breadcrumb

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

class PassedTests

@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

@internal This class is not covered by the backward compatibility promise for PHPUnit

Hierarchy

  • class \PHPUnit\TestRunner\TestResult\PassedTests

Expanded class hierarchy of PassedTests

2 files declare their use of PassedTests
AbstractPhpProcess.php in vendor/phpunit/phpunit/src/Util/PHP/AbstractPhpProcess.php
TestCase.php in vendor/phpunit/phpunit/src/Framework/TestCase.php

File

vendor/phpunit/phpunit/src/Runner/TestResult/PassedTests.php, line 25

Namespace

PHPUnit\TestRunner\TestResult
View source
final class PassedTests {
    private static ?self $instance = null;
    
    /**
     * @psalm-var list<class-string>
     */
    private array $passedTestClasses = [];
    
    /**
     * @psalm-var array<string,array{returnValue: mixed, size: TestSize}>
     */
    private array $passedTestMethods = [];
    public static function instance() : self {
        if (self::$instance !== null) {
            return self::$instance;
        }
        self::$instance = new self();
        return self::$instance;
    }
    
    /**
     * @psalm-param class-string $className
     */
    public function testClassPassed(string $className) : void {
        $this->passedTestClasses[] = $className;
    }
    public function testMethodPassed(TestMethod $test, mixed $returnValue) : void {
        $size = (new Groups())->size($test->className(), $test->methodName());
        $this->passedTestMethods[$test->className() . '::' . $test->methodName()] = [
            'returnValue' => $returnValue,
            'size' => $size,
        ];
    }
    public function import(self $other) : void {
        $this->passedTestClasses = array_merge($this->passedTestClasses, $other->passedTestClasses);
        $this->passedTestMethods = array_merge($this->passedTestMethods, $other->passedTestMethods);
    }
    
    /**
     * @psalm-param class-string $className
     */
    public function hasTestClassPassed(string $className) : bool {
        return in_array($className, $this->passedTestClasses, true);
    }
    public function hasTestMethodPassed(string $method) : bool {
        return isset($this->passedTestMethods[$method]);
    }
    public function isGreaterThan(string $method, TestSize $other) : bool {
        if ($other->isUnknown()) {
            return false;
        }
        assert($other instanceof Known);
        $size = $this->passedTestMethods[$method]['size'];
        if ($size->isUnknown()) {
            return false;
        }
        assert($size instanceof Known);
        return $size->isGreaterThan($other);
    }
    public function returnValue(string $method) : mixed {
        if (isset($this->passedTestMethods[$method])) {
            return $this->passedTestMethods[$method]['returnValue'];
        }
        return null;
    }

}

Members

Title Sort descending Modifiers Object type Summary
PassedTests::$instance private static property
PassedTests::$passedTestClasses private property @psalm-var list&lt;class-string&gt;
PassedTests::$passedTestMethods private property @psalm-var array&lt;string,array{returnValue: mixed, size: TestSize}&gt;
PassedTests::hasTestClassPassed public function @psalm-param class-string $className
PassedTests::hasTestMethodPassed public function
PassedTests::import public function
PassedTests::instance public static function
PassedTests::isGreaterThan public function
PassedTests::returnValue public function
PassedTests::testClassPassed public function @psalm-param class-string $className
PassedTests::testMethodPassed public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal