/** * Runs tests. * * @since Method available since Release 2.1.0 */ public function run() { $this->outputBuffering->clearOutputHandlers(); $this->result = $this->runner->run($this->collector->collect()); if ($this->runner->shouldNotify()) { $this->notifier->notifyResult($this->runner->getNotification()); } }
/** * @param \Stagehand\TestRunner\Notification\Notification $notification * * @throws \LogicException * * @since Method available since Release 4.0.0 */ protected function notifyResult(Notification $notification) { if (is_null($notification->getMessage()) || strlen($notification->getMessage()) == 0) { $notificationMessage = 'The notification message is empty. This may be caused by unexpected output.'; if ($notification->isPassed()) { $notification = new Notification(Notification::RESULT_PASSED, $notificationMessage); } elseif ($notification->isFailed()) { $notification = new Notification(Notification::RESULT_FAILED, $notificationMessage); } else { throw new \LogicException('The notification result must be either Notification::RESULT_PASSED or Notification::RESULT_FAILED.'); } } $this->notifier->notifyResult($notification); }
/** * @param string $commandLine * * @since Method available since Release 2.18.0 */ public function runTests($commandLine) { $streamOutput = ''; if ($this->os->isWin()) { // TODO: Remove Windows specific code if the bug #60120 and #51800 are really fixed. ob_start(function ($buffer) use(&$streamOutput) { $streamOutput .= $buffer; return $buffer; }, 2); passthru($commandLine, $exitStatus); ob_end_flush(); } else { $process = new Process($commandLine); $process->setTimeout(60); $exitStatus = $process->run(function ($type, $data) { echo $data; }); $streamOutput = $process->getOutput(); } if ($exitStatus != 0 && $this->runner->shouldNotify()) { $fatalError = new FatalError($streamOutput); $this->notifier->notifyResult(new Notification(Notification::RESULT_STOPPED, $fatalError->getFullMessage())); } }