class TestMethod
@psalm-immutable
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
Hierarchy
- class \PHPUnit\Event\Code\Test
- class \PHPUnit\Event\Code\TestMethod extends \PHPUnit\Event\Code\Test
Expanded class hierarchy of TestMethod
9 files declare their use of TestMethod
- Collector.php in vendor/
phpunit/ phpunit/ src/ Runner/ TestResult/ Collector.php - DataProvider.php in vendor/
phpunit/ phpunit/ src/ Metadata/ Api/ DataProvider.php - JunitXmlLogger.php in vendor/
phpunit/ phpunit/ src/ Logging/ JUnit/ JunitXmlLogger.php - PassedTests.php in vendor/
phpunit/ phpunit/ src/ Runner/ TestResult/ PassedTests.php - ResultPrinter.php in vendor/
phpunit/ phpunit/ src/ TextUI/ Output/ Default/ ResultPrinter.php
File
-
vendor/
phpunit/ phpunit/ src/ Event/ Value/ Test/ TestMethod.php, line 23
Namespace
PHPUnit\Event\CodeView source
final class TestMethod extends Test {
/**
* @psalm-var class-string
*/
private readonly string $className;
/**
* @psalm-var non-empty-string
*/
private readonly string $methodName;
/**
* @psalm-var non-negative-int
*/
private readonly int $line;
private readonly TestDox $testDox;
private readonly MetadataCollection $metadata;
private readonly TestDataCollection $testData;
/**
* @psalm-param class-string $className
* @psalm-param non-empty-string $methodName
* @psalm-param non-empty-string $file
* @psalm-param non-negative-int $line
*/
public function __construct(string $className, string $methodName, string $file, int $line, TestDox $testDox, MetadataCollection $metadata, TestDataCollection $testData) {
parent::__construct($file);
$this->className = $className;
$this->methodName = $methodName;
$this->line = $line;
$this->testDox = $testDox;
$this->metadata = $metadata;
$this->testData = $testData;
}
/**
* @psalm-return class-string
*/
public function className() : string {
return $this->className;
}
/**
* @psalm-return non-empty-string
*/
public function methodName() : string {
return $this->methodName;
}
/**
* @psalm-return non-negative-int
*/
public function line() : int {
return $this->line;
}
public function testDox() : TestDox {
return $this->testDox;
}
public function metadata() : MetadataCollection {
return $this->metadata;
}
public function testData() : TestDataCollection {
return $this->testData;
}
/**
* @psalm-assert-if-true TestMethod $this
*/
public function isTestMethod() : bool {
return true;
}
/**
* @psalm-return non-empty-string
*/
public function id() : string {
$buffer = $this->className . '::' . $this->methodName;
if ($this->testData()
->hasDataFromDataProvider()) {
$buffer .= '#' . $this->testData
->dataFromDataProvider()
->dataSetName();
}
return $buffer;
}
/**
* @psalm-return non-empty-string
*/
public function nameWithClass() : string {
return $this->className . '::' . $this->name();
}
/**
* @psalm-return non-empty-string
*/
public function name() : string {
if (!$this->testData
->hasDataFromDataProvider()) {
return $this->methodName;
}
$dataSetName = $this->testData
->dataFromDataProvider()
->dataSetName();
if (is_int($dataSetName)) {
$dataSetName = sprintf(' with data set #%d', $dataSetName);
}
else {
$dataSetName = sprintf(' with data set "%s"', $dataSetName);
}
return $this->methodName . $dataSetName;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Test::$file | private | property | @psalm-var non-empty-string | ||
Test::file | public | function | @psalm-return non-empty-string | ||
Test::isPhpt | public | function | @psalm-assert-if-true Phpt $this | 1 | |
TestMethod::$className | private | property | @psalm-var class-string | ||
TestMethod::$line | private | property | @psalm-var non-negative-int | ||
TestMethod::$metadata | private | property | |||
TestMethod::$methodName | private | property | @psalm-var non-empty-string | ||
TestMethod::$testData | private | property | |||
TestMethod::$testDox | private | property | |||
TestMethod::className | public | function | @psalm-return class-string | ||
TestMethod::id | public | function | @psalm-return non-empty-string | Overrides Test::id | |
TestMethod::isTestMethod | public | function | @psalm-assert-if-true TestMethod $this | Overrides Test::isTestMethod | |
TestMethod::line | public | function | @psalm-return non-negative-int | ||
TestMethod::metadata | public | function | |||
TestMethod::methodName | public | function | @psalm-return non-empty-string | ||
TestMethod::name | public | function | @psalm-return non-empty-string | Overrides Test::name | |
TestMethod::nameWithClass | public | function | @psalm-return non-empty-string | ||
TestMethod::testData | public | function | |||
TestMethod::testDox | public | function | |||
TestMethod::__construct | public | function | @psalm-param class-string $className @psalm-param non-empty-string $methodName @psalm-param non-empty-string $file @psalm-param non-negative-int $line |
Overrides Test::__construct |