Beware of the behavior when using FilesystemIterator::UNIX_PATHS, it's not applied as you might expect.

I guess this flag is added especially for use on windows.However, the path you construct the RecursiveDirectoryIterator or FilesystemIterator with will not be available as a unix path.I can't say this is a bug, since most methods are just purely inherited from DirectoryIterator.

DirectoryIterator::getBasename() has been also been available since 5.2.2, according to the changelog (not documented yet). It takes a parameter $suffix, and is useful if, for instance, you use a naming convention for your files (e.g. ClassName.php).

The following code uses this to add recursively All*Tests.php in any subdirectory off of tests/, basically, suites of suites.

public static function suite() {
$suite = new PHPUnit_Framework_TestSuite('AllMyTests'); // this must be something different than the class name, per PHPUnit
$it = new AllTestsFilterIterator(
new RecursiveIteratorIterator(
new RecursiveDirectoryIterator(dirname(__FILE__) . '/tests')));