3 * This file is part of PHPUnit.
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
12 * Iterator for test suites.
14 * @since Class available since Release 3.1.0
16 class PHPUnit_Util_TestSuiteIterator implements RecursiveIterator
24 * @var PHPUnit_Framework_Test[]
29 * @param PHPUnit_Framework_TestSuite $testSuite
31 public function __construct(PHPUnit_Framework_TestSuite $testSuite)
33 $this->tests = $testSuite->tests();
37 * Rewinds the Iterator to the first element.
39 public function rewind()
45 * Checks if there is a current element after calls to rewind() or next().
49 public function valid()
51 return $this->position < count($this->tests);
55 * Returns the key of the current element.
61 return $this->position;
65 * Returns the current element.
67 * @return PHPUnit_Framework_Test
69 public function current()
71 return $this->valid() ? $this->tests[$this->position] : null;
75 * Moves forward to next element.
77 public function next()
83 * Returns the sub iterator for the current element.
85 * @return PHPUnit_Util_TestSuiteIterator
87 public function getChildren()
90 $this->tests[$this->position]
95 * Checks whether the current element has children.
99 public function hasChildren()
101 return $this->tests[$this->position] instanceof PHPUnit_Framework_TestSuite;