/** * @param \Stagehand\TestRunner\Notification\Notification $notification * @return string */ protected function buildNotifyCommand(Notification $notification) { if ($notification->isPassed()) { $title = self::TITLE_PASSED; $icon = self::$ICON_PASSED; } elseif ($notification->isFailed()) { $title = self::TITLE_FAILED; $icon = self::$ICON_FAILED; } elseif ($notification->isStopped()) { $title = self::TITLE_STOPPED; $icon = self::$ICON_STOPPED; } if ($this->os->isWin()) { return sprintf('growlnotify /t:%s /p:-2 /i:%s /a:Stagehand_TestRunner /r:%s,%s,%s /n:%s /silent:true %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg(self::TITLE_PASSED), escapeshellarg(self::TITLE_FAILED), escapeshellarg(self::TITLE_STOPPED), escapeshellarg($title), escapeshellarg($notification->getMessage())); } elseif ($this->os->isDarwin()) { return sprintf('growlnotify --name %s --priority -2 --image %s --title %s --message %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg($title), escapeshellarg($notification->getMessage())); } elseif ($this->os->isLinux()) { return sprintf('notify-send --urgency=low --icon=%s %s %s', escapeshellarg($icon), escapeshellarg($title), escapeshellarg(str_replace('\\', '\\\\', $notification->getMessage()))); } }
/** * @param \Stagehand\TestRunner\Notification\Notification $notification * * @return string */ protected function buildNotifyCommand(Notification $notification) { if ($notification->isPassed()) { $title = self::TITLE_PASSED; $icon = self::$ICON_PASSED; $sound = self::SOUND_PASSED; } elseif ($notification->isFailed()) { $title = self::TITLE_FAILED; $icon = self::$ICON_FAILED; $sound = self::SOUND_FAILED; } elseif ($notification->isStopped()) { $title = self::TITLE_STOPPED; $icon = self::$ICON_STOPPED; $sound = self::SOUND_STOPPED; } if ($this->os->isWin()) { return sprintf('growlnotify /t:%s /p:-2 /i:%s /a:Stagehand_TestRunner /r:%s,%s,%s /n:%s /silent:true %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg(self::TITLE_PASSED), escapeshellarg(self::TITLE_FAILED), escapeshellarg(self::TITLE_STOPPED), escapeshellarg($title), escapeshellarg($notification->getMessage())); } elseif ($this->os->isAfterMarvericks() && !$this->hasGrowl('osascript')) { return sprintf('osascript -e "display notification \\"%s\\" subtitle \\"%s\\" sound name \\"%s\\""', escapeshellarg($notification->getMessage()), escapeshellcmd($title), escapeshellcmd($sound)); } elseif ($this->os->isDarwin()) { return sprintf('growlnotify --name %s --priority -2 --image %s --title %s --message %s', escapeshellarg($title), escapeshellarg($icon), escapeshellarg($title), escapeshellarg($notification->getMessage())); } elseif ($this->os->isLinux()) { return sprintf('notify-send --urgency=low --icon=%s %s %s', escapeshellarg($icon), escapeshellarg($title), escapeshellarg(str_replace('\\', '\\\\', $notification->getMessage()))); } }
/** * @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); }