ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
Suite.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestSuite;
24use Iterator;
25use GlobIterator;
26use FilterIterator;
27use SplFileInfo;
28
29class 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