/** * 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); }
* @copyright 2011-2012 KUBO Atsuhiro <*****@*****.**> * @copyright 2011 Shigenobu Nishikawa <*****@*****.**> * @copyright 2015 evalphobia <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * * @version Release: @package_version@ * * @since File available since Release 2.18.0 */ namespace Stagehand\TestRunner\Notification; use Stagehand\TestRunner\Util\LegacyProxy; use Stagehand\TestRunner\Util\OS; Notifier::$ICON_PASSED = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . 'passed.png'; Notifier::$ICON_FAILED = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . 'failed.png'; Notifier::$ICON_STOPPED = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Resources' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . 'stopped.png'; /** * @copyright 2011-2012 KUBO Atsuhiro <*****@*****.**> * @copyright 2011 Shigenobu Nishikawa <*****@*****.**> * @copyright 2015 evalphobia <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * * @version Release: @package_version@ * * @since Class available since Release 2.18.0 */ class Notifier { const TITLE_PASSED = 'Test Passed'; const TITLE_FAILED = 'Test Failed'; const TITLE_STOPPED = 'Test Stopped';
* POSSIBILITY OF SUCH DAMAGE. * * @package Stagehand_TestRunner * @copyright 2011-2012 KUBO Atsuhiro <*****@*****.**> * @copyright 2011 Shigenobu Nishikawa <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version Release: @package_version@ * @since File available since Release 2.18.0 */ namespace Stagehand\TestRunner\Notification; use Stagehand\TestRunner\Util\LegacyProxy; use Stagehand\TestRunner\Util\OS; Notifier::$ICON_PASSED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'passed.png'; Notifier::$ICON_FAILED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'failed.png'; Notifier::$ICON_STOPPED = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'stopped.png'; /** * @package Stagehand_TestRunner * @copyright 2011-2012 KUBO Atsuhiro <*****@*****.**> * @copyright 2011 Shigenobu Nishikawa <*****@*****.**> * @license http://www.opensource.org/licenses/bsd-license.php New BSD License * @version Release: @package_version@ * @since Class available since Release 2.18.0 */ class Notifier { const TITLE_PASSED = 'Test Passed'; const TITLE_FAILED = 'Test Failed'; const TITLE_STOPPED = 'Test Stopped'; public static $ICON_PASSED; public static $ICON_FAILED;
/** * @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())); } }