ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Suite.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 use Iterator;
25 use GlobIterator;
26 use FilterIterator;
27 use SplFileInfo;
28 
29 class Suite extends TestSuite
30 {
31  public static function suite(): Suite
32  {
33  $suite = new self();
34  // Get namespace path from class name.
35  $namespace = preg_replace('/\\\\[^\\\\]+$/', '\\', self::class);
36 
37  foreach (self::collectTestFiles() as $file) {
38  require_once $file->getRealPath();
39  $suite->addTestSuite($namespace . preg_replace('/.php$/', '', (string) $file->getFileName()));
40  }
41 
42  return $suite;
43  }
44 
45  private static function collectTestFiles(): Iterator
46  {
47  return new class (new GlobIterator(__DIR__ . '/*.php')) extends FilterIterator {
48  public function accept(): bool
49  {
50  return $this->current() instanceof SplFileInfo && __FILE__ !== $this->current()->getRealPath();
51  }
52  };
53  }
54 }
if($err=$client->getError()) $namespace