Example #1
0
 /**
  * Parses options into World
  * 
  * @return array|null
  */
 protected function parseOptionsAndSetWorld()
 {
     $this->_world->setReporter($this->_reporter);
     $configOptions = $this->getConfiguration()->load();
     $arguments = array_merge($this->_arguments, $configOptions);
     $options = $this->getParser()->parse($arguments);
     $this->_world->setOptions($options);
     return $options;
 }
 /**
  * Runs tests based on the given array.
  *
  * @param \Stagehand\TestRunner\TestSuite\PHPSpecTestSuite $suite
  */
 public function run($suite)
 {
     $options = array();
     $options['specFile'] = $suite;
     $options['c'] = $this->terminal->shouldColor();
     $options['failfast'] = $this->shouldStopOnFailure();
     $reporter = new Reporter();
     if ($this->hasDetailedProgress()) {
         $reporter->addFormatter(new TerminatableFormatter(new DocumentationFormatter($reporter)));
     } else {
         $reporter->addFormatter(new TerminatableFormatter(new ProgressFormatter($reporter)));
     }
     if ($this->shouldNotify()) {
         $notificationFormatter = new NotificationFormatter($reporter);
         $reporter->addFormatter(new TerminatableFormatter($notificationFormatter));
     }
     if ($this->hasJUnitXMLFile()) {
         $junitXMLFormatter = new JUnitXMLFormatter($reporter);
         $junitXMLFormatter->setJUnitXMLWriter($this->createJUnitXMLWriter());
         $junitXMLFormatter->setTestSuite($suite);
         $junitXMLFormatter->setTestTargetRepository($this->testTargetRepository);
         $reporter->addFormatter(new TerminatableFormatter($junitXMLFormatter));
     }
     $world = new World();
     $world->setOptions($options);
     $world->setReporter($reporter);
     $oldErrorHandler = set_error_handler(function () {
     });
     restore_error_handler();
     $exampleRunner = new ExampleRunner();
     $exampleRunner->setExampleFactory(new ExampleFactory($this->testTargetRepository));
     $runner = new \PHPSpec\Runner\Cli\Runner();
     $runner->setLoader(new SpecLoaderFactory());
     $runner->setExampleRunner($exampleRunner);
     $runner->run($world);
     $reporter->notify(new ReporterEvent('termination', '', ''));
     if (!is_null($oldErrorHandler)) {
         set_error_handler($oldErrorHandler);
     }
     if ($this->shouldNotify()) {
         $this->notification = $notificationFormatter->getNotification();
     }
 }