"Fossies" - the Fresh Open Source Software Archive

Member "phpunit-9.0.1/src/TextUI/Configuration/TestSuite/TestSuiteMapper.php" (13 Feb 2020, 2341 Bytes) of package /linux/www/phpunit-9.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "TestSuiteMapper.php": 9.0.0_vs_9.0.1.

    1 <?php declare(strict_types=1);
    2 /*
    3  * This file is part of PHPUnit.
    4  *
    5  * (c) Sebastian Bergmann <sebastian@phpunit.de>
    6  *
    7  * For the full copyright and license information, please view the LICENSE
    8  * file that was distributed with this source code.
    9  */
   10 namespace PHPUnit\TextUI\Configuration;
   11 
   12 use PHPUnit\Framework\TestSuite as TestSuiteObject;
   13 use SebastianBergmann\FileIterator\Facade;
   14 
   15 /**
   16  * @internal This class is not covered by the backward compatibility promise for PHPUnit
   17  */
   18 final class TestSuiteMapper
   19 {
   20     public function map(TestSuiteCollection $configuration, string $filter): TestSuiteObject
   21     {
   22         $filterAsArray = $filter ? \explode(',', $filter) : [];
   23         $result        = new TestSuiteObject;
   24 
   25         foreach ($configuration as $testSuiteConfiguration) {
   26             if (!empty($filterAsArray) && !\in_array($testSuiteConfiguration->name(), $filterAsArray, true)) {
   27                 continue;
   28             }
   29 
   30             $testSuite      = new TestSuiteObject($testSuiteConfiguration->name());
   31             $testSuiteEmpty = true;
   32 
   33             foreach ($testSuiteConfiguration->directories() as $directory) {
   34                 if (!\version_compare(\PHP_VERSION, $directory->phpVersion(), $directory->phpVersionOperator()->asString())) {
   35                     continue;
   36                 }
   37 
   38                 $exclude = [];
   39 
   40                 foreach ($testSuiteConfiguration->exclude()->asArray() as $file) {
   41                     $exclude[] = $file->path();
   42                 }
   43 
   44                 $testSuite->addTestFiles(
   45                     (new Facade)->getFilesAsArray(
   46                         $directory->path(),
   47                         $directory->suffix(),
   48                         $directory->prefix(),
   49                         $exclude
   50                     )
   51                 );
   52 
   53                 $testSuiteEmpty = false;
   54             }
   55 
   56             foreach ($testSuiteConfiguration->files() as $file) {
   57                 if (!\version_compare(\PHP_VERSION, $file->phpVersion(), $file->phpVersionOperator()->asString())) {
   58                     continue;
   59                 }
   60 
   61                 $testSuite->addTestFile($file->path());
   62 
   63                 $testSuiteEmpty = false;
   64             }
   65 
   66             if (!$testSuiteEmpty) {
   67                 $result->addTest($testSuite);
   68             }
   69         }
   70 
   71         return $result;
   72     }
   73 }