/**
  * @param string $message
  *
  * @return string
  */
 public function ask($message)
 {
     $runAgainText = "Press <Enter> to reexecute, press any other key and <Enter> to stop...";
     if ($message != $runAgainText) {
         return parent::ask($message);
     }
     /** @var \mageekguy\atoum\writers\std\out $outputWriter */
     $outputWriter = $this->getOutputWriter();
     $watcher = new ResourceWatcher();
     $onEvent = function (FilesystemEvent $event) use($watcher, $outputWriter) {
         $outputWriter->write($event->getResource()->getId() . " has been modified." . PHP_EOL);
         $watcher->stop();
     };
     foreach ($this->configuration->getWatchedFiles() as $watchedFile) {
         $watcher->track($watchedFile, $watchedFile);
         $watcher->addListener($watchedFile, $onEvent);
     }
     foreach ($this->getRunner()->getTestPaths() as $path) {
         $watcher->track($path, $path);
         $watcher->addListener($path, $onEvent);
     }
     $outputWriter->write('Waiting for a file to change to run the test(s)... (Use CTRL+C to stop)' . PHP_EOL);
     $watcher->start();
     return '';
 }
Beispiel #2
0
 /**
  * @return string
  */
 public function runAgain()
 {
     /** @var \mageekguy\atoum\writers\std\out $outputWriter */
     $outputWriter = $this->runner->getOutputWriter();
     $watcher = new ResourceWatcher();
     $onEvent = function (FilesystemEvent $event) use($watcher, $outputWriter) {
         $outputWriter->write((string) $event->getResource() . " has been modified." . PHP_EOL);
         $watcher->stop();
     };
     foreach ($this->configuration->getWatchedFiles() as $watchedFile) {
         $watcher->track($watchedFile, $watchedFile);
         $watcher->addListener($watchedFile, $onEvent);
     }
     foreach ($this->runner->getRunner()->getTestPaths() as $path) {
         $watcher->track($path, $path);
         $watcher->addListener($path, $onEvent);
     }
     $outputWriter->write('Waiting for a file to change to run the test(s)... (Use CTRL+C to stop)' . PHP_EOL);
     $watcher->start();
     return '';
 }
Beispiel #3
0
 /**
  * @param array $watchedFiles
  *
  * @return $this
  */
 public function setWatchedFiles(array $watchedFiles = array())
 {
     $this->configuration->setWatchedFiles($watchedFiles);
     return $this;
 }