Example #1
0
 /**
  * Collects tests.
  *
  * @return mixed
  * @throws \UnexpectedValueException
  */
 public function collect()
 {
     $self = $this;
     $this->testTargetRepository->walkOnResources(function ($resource, $index, TestTargetRepository $testTargetRepository) use($self) {
         $absoluteTargetPath = realpath($resource);
         if ($absoluteTargetPath === false) {
             throw new \UnexpectedValueException(sprintf('The directory or file [ %s ] is not found', $resource));
         }
         if (is_dir($absoluteTargetPath)) {
             $finder = Finder::create()->files()->in($absoluteTargetPath)->depth($self->isRecursive() ? '>= 0' : '== 0')->sortByName();
             foreach ($finder as $file) {
                 call_user_func(array($self, 'collectTestCasesFromFile'), $file->getPathname());
             }
         } else {
             call_user_func(array($self, 'collectTestCasesFromFile'), $absoluteTargetPath);
         }
     });
     return $this->suite;
 }
 /**
  * Collects tests.
  *
  * @return mixed
  * @throws \UnexpectedValueException
  */
 public function collect()
 {
     $self = $this;
     $fileSystem = new FileSystem();
     $environment = $this->environment;
     $this->testTargetRepository->walkOnResources(function ($resource, $index, TestTargetRepository $testTargetRepository) use($self, $fileSystem, $environment) {
         $absoluteTargetPath = $fileSystem->getAbsolutePath($resource, $environment->getWorkingDirectoryAtStartup());
         if (!file_exists($absoluteTargetPath)) {
             throw new \UnexpectedValueException(sprintf('The directory or file [ %s ] is not found', $absoluteTargetPath));
         }
         if (is_dir($absoluteTargetPath)) {
             $finder = Finder::create()->files()->in($absoluteTargetPath)->depth($self->isRecursive() ? '>= 0' : '== 0')->sortByName();
             foreach ($finder as $file) {
                 call_user_func(array($self, 'collectTestCasesFromFile'), $file->getPathname());
             }
         } else {
             call_user_func(array($self, 'collectTestCasesFromFile'), $absoluteTargetPath);
         }
     });
     return $this->suite;
 }
 /**
  * @param string $command
  *
  * @return array
  */
 protected function buildOptions($command)
 {
     $options = array();
     if (basename(trim($command, '\'"')) != 'testrunner') {
         $configFile = $this->getPHPConfigDir();
         if ($configFile !== false) {
             $options[] = '-c';
             $options[] = escapeshellarg($configFile);
         }
         $options[] = escapeshellarg($_SERVER['argv'][0]);
     }
     if ($this->terminal->shouldColor()) {
         $options[] = '--ansi';
     }
     $options[] = escapeshellarg(strtolower($this->plugin->getPluginID()));
     if (!is_null($this->environment->getPreloadScript())) {
         $options[] = '-p ' . escapeshellarg($this->environment->getPreloadScript());
     }
     $options[] = '-R';
     if ($this->runner->shouldNotify()) {
         $options[] = '-m';
     }
     if ($this->runner->shouldStopOnFailure()) {
         $options[] = '--stop-on-failure';
     }
     if (!$this->testTargetRepository->isDefaultFilePattern()) {
         $options[] = '--test-file-pattern=' . escapeshellarg($this->testTargetRepository->getFilePattern());
     }
     if ($this->runner->hasDetailedProgress()) {
         $options[] = '--detailed-progress';
     }
     if (!is_null($this->commandLineOptionBuilder)) {
         $options = $this->commandLineOptionBuilder->build($options);
     }
     $this->testTargetRepository->walkOnResources(function ($resource, $index, TestTargetRepository $testTargetRepository) use(&$options) {
         $options[] = escapeshellarg($resource);
     });
     return $options;
 }
Example #4
0
 /**
  * @return array
  */
 protected function buildRunnerOptions()
 {
     $options = array();
     if (basename(trim($this->runnerCommand, '\'"')) != 'testrunner') {
         $configFile = $this->getPHPConfigDir();
         if ($configFile !== false) {
             $options[] = '-c';
             $options[] = escapeshellarg($configFile);
         }
         $options[] = escapeshellarg($_SERVER['argv'][0]);
     }
     if ($this->terminal->shouldColor()) {
         $options[] = '--ansi';
     }
     $options[] = escapeshellarg(strtolower(ApplicationContext::getInstance()->getPlugin()->getPluginID()));
     if (!is_null(ApplicationContext::getInstance()->getEnvironment()->getPreloadScript())) {
         $options[] = '-p ' . escapeshellarg(ApplicationContext::getInstance()->getEnvironment()->getPreloadScript());
     }
     $options[] = '-R';
     if ($this->runnerFactory->create()->shouldNotify()) {
         $options[] = '-m';
     }
     if ($this->runnerFactory->create()->shouldStopOnFailure()) {
         $options[] = '--stop-on-failure';
     }
     if (!$this->testTargetRepository->isDefaultFilePattern()) {
         $options[] = '--test-file-pattern=' . escapeshellarg($this->testTargetRepository->getFilePattern());
     }
     if ($this->runnerFactory->create()->hasDetailedProgress()) {
         $options[] = '--detailed-progress';
     }
     $options = array_merge($options, $this->doBuildRunnerOptions());
     $this->testTargetRepository->walkOnResources(function ($resource, $index, TestTargetRepository $testTargetRepository) use(&$options) {
         $options[] = escapeshellarg($resource);
     });
     return $options;
 }