class TestSuiteIterator
@template-implements RecursiveIterator<int, Test>
@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\Framework\TestSuiteIterator implements \RecursiveIterator
Expanded class hierarchy of TestSuiteIterator
File
-
vendor/
phpunit/ phpunit/ src/ Framework/ TestSuiteIterator.php, line 23
Namespace
PHPUnit\FrameworkView source
final class TestSuiteIterator implements RecursiveIterator {
private int $position = 0;
/**
* @psalm-var list<Test>
*/
private readonly array $tests;
public function __construct(TestSuite $testSuite) {
$this->tests = $testSuite->tests();
}
public function rewind() : void {
$this->position = 0;
}
public function valid() : bool {
return $this->position < count($this->tests);
}
public function key() : int {
return $this->position;
}
public function current() : Test {
return $this->tests[$this->position];
}
public function next() : void {
$this->position++;
}
/**
* @throws NoChildTestSuiteException
*/
public function getChildren() : self {
if (!$this->hasChildren()) {
throw new NoChildTestSuiteException('The current item is not a TestSuite instance and therefore does not have any children.');
}
$current = $this->current();
assert($current instanceof TestSuite);
return new self($current);
}
public function hasChildren() : bool {
return $this->valid() && $this->current() instanceof TestSuite;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TestSuiteIterator::$position | private | property | |
TestSuiteIterator::$tests | private | property | @psalm-var list<Test> |
TestSuiteIterator::current | public | function | |
TestSuiteIterator::getChildren | public | function | |
TestSuiteIterator::hasChildren | public | function | |
TestSuiteIterator::key | public | function | |
TestSuiteIterator::next | public | function | |
TestSuiteIterator::rewind | public | function | |
TestSuiteIterator::valid | public | function | |
TestSuiteIterator::__construct | public | function |