ParaTest\Runners\PHPUnit\TestFileLoader::loadPath PHP Method

loadPath() public method

A valid path can be a directory or file
public loadPath ( $path, $pattern = null ) : string[]
$path
$pattern
return string[]
    public function loadPath($path, $pattern = null)
    {
        $this->files = array();
        $path = $path ?: $this->options->path;
        $pattern = is_null($pattern) ? self::TEST_PATTERN : $pattern;
        if (!file_exists($path)) {
            throw new \InvalidArgumentException("{$path} is not a valid directory or file");
        }
        if (is_dir($path)) {
            $this->loadDir($path, $pattern);
        } elseif (file_exists($path)) {
            $this->loadFile($path);
        }
        return $this->files;
    }

Usage Example

Beispiel #1
0
 /**
  * Populates the loaded suite collection. Will load suites
  * based off a phpunit xml configuration or a specified path
  *
  * @param string $path
  * @throws \RuntimeException
  */
 public function load($path = '')
 {
     if (is_object($this->options) && isset($this->options->filtered['configuration'])) {
         $configuration = $this->options->filtered['configuration'];
     } else {
         $configuration = new Configuration('');
     }
     if ($path) {
         $testFileLoader = new TestFileLoader($this->options);
         $this->files = array_merge($this->files, $testFileLoader->loadPath($path));
     } elseif (isset($this->options->testsuite) && $this->options->testsuite) {
         foreach ($configuration->getSuiteByName($this->options->testsuite) as $suite) {
             foreach ($suite as $suitePath) {
                 $testFileLoader = new TestFileLoader($this->options);
                 $this->files = array_merge($this->files, $testFileLoader->loadSuitePath($suitePath));
             }
         }
     } elseif ($suites = $configuration->getSuites()) {
         foreach ($suites as $suite) {
             foreach ($suite as $suitePath) {
                 $testFileLoader = new TestFileLoader($this->options);
                 $this->files = array_merge($this->files, $testFileLoader->loadSuitePath($suitePath));
             }
         }
     }
     if (!$this->files) {
         throw new \RuntimeException("No path or configuration provided (tests must end with Test.php)");
     }
     $this->files = array_unique($this->files);
     // remove duplicates
     $this->initSuites();
 }