/**
  * {@inheritdoc}
  */
 public function isSupported()
 {
     if (OsHelper::isMacOS() && version_compare(OsHelper::getMacOSVersion(), '10.9.0', '>=')) {
         return parent::isSupported();
     }
     return false;
 }
 public function __construct()
 {
     $this->notifier = NotifierFactory::create();
     if (self::$is_darwin === null) {
         self::$is_darwin = OsHelper::isMacOS();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function getExpectedCommandLineForNotificationWithAllOptions()
 {
     if (OsHelper::isMacOS() && version_compare(OsHelper::getMacOSVersion(), '10.9.0', '>=')) {
         return "'terminal-notifier' '-message' 'I'\\''m the notification body' '-title' 'I'\\''m the notification title' '-appIcon' '/home/toto/Images/my-icon.png'";
     }
     return "'terminal-notifier' '-message' 'I'\\''m the notification body' '-title' 'I'\\''m the notification title'";
 }
 public function testIsSupported()
 {
     $notifier = $this->getNotifier();
     if (OsHelper::isMacOS() && version_compare(OsHelper::getMacOSVersion(), '10.9.0', '>=')) {
         $this->assertTrue($notifier->isSupported());
     } else {
         $this->assertFalse($notifier->isSupported());
     }
 }
Example #5
0
 /**
  * @return Notifier[]
  */
 public static function getDefaultNotifiers()
 {
     // Don't retrieve notifiers which are certainly not supported on this
     // system. This helps to lower the number of process to run.
     if (OsHelper::isUnix()) {
         return self::getUnixNotifiers();
     }
     return self::getWindowsNotifiers();
 }
Example #6
0
 public function testGetMacOSVersion()
 {
     if (!OsHelper::isMacOS()) {
         $this->markTestSkipped('Can only be run on MacOS');
     }
     $expectedMacOsVersion = exec('sw_vers -productVersion', $output);
     $macOsVersion = OsHelper::getMacOSVersion();
     $this->assertRegExp('#\\d{1,2}\\.\\d{1,2}(\\.\\d{1,2})?#', $macOsVersion);
     $this->assertSame($expectedMacOsVersion, $macOsVersion);
 }
 public function testIsSupported()
 {
     if (OsHelper::isUnix()) {
         $commandLine = 'command -v ' . static::BINARY . ' >/dev/null 2>&1';
     } else {
         $commandLine = 'where ' . static::BINARY;
     }
     passthru($commandLine, $return);
     $supported = 0 === $return;
     $this->assertSame($supported, $this->getNotifier()->isSupported());
 }
 /**
  * {@inheritdoc}
  */
 protected function configureProcess(ProcessBuilder $processBuilder, Notification $notification)
 {
     $processBuilder->add('-message');
     $processBuilder->add($notification->getBody());
     if ($notification->getTitle()) {
         $processBuilder->add('-title');
         $processBuilder->add($notification->getTitle());
     }
     if ($notification->getIcon() && version_compare(OsHelper::getMacOSVersion(), '10.9.0', '>=')) {
         $processBuilder->add('-appIcon');
         $processBuilder->add($notification->getIcon());
     }
 }
 /**
  * Check whether a binary is available.
  *
  * @return bool
  */
 protected function isBinaryAvailable()
 {
     if (OsHelper::isUnix()) {
         // Do not use the 'which' program to check if a binary exists.
         // See also http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
         $builder = new ProcessBuilder(['command', '-v', $this->getBinary(), '>/dev/null', '2>&1']);
     } else {
         // 'where' is available on Windows since Server 2003
         $builder = new ProcessBuilder(['where', $this->getBinary()]);
     }
     $process = $builder->getProcess();
     $process->run();
     return $process->isSuccessful();
 }
 public function testCreateUsesDefaultNotifiers()
 {
     $notifier = NotifierFactory::create();
     if ($notifier instanceof NullNotifier) {
         $this->markTestSkipped('This test needs that at least one notifier is supported');
     }
     $this->assertInstanceOf('Joli\\JoliNotif\\Notifier', $notifier);
     if (OsHelper::isUnix()) {
         $expectedNotifierClasses = ['Joli\\JoliNotif\\Notifier\\GrowlNotifyNotifier', 'Joli\\JoliNotif\\Notifier\\TerminalNotifierNotifier', 'Joli\\JoliNotif\\Notifier\\AppleScriptNotifier', 'Joli\\JoliNotif\\Notifier\\NotifySendNotifier'];
     } else {
         $expectedNotifierClasses = ['Joli\\JoliNotif\\Notifier\\ToasterNotifier', 'Joli\\JoliNotif\\Notifier\\NotifuNotifier'];
     }
     $this->assertContains(get_class($notifier), $expectedNotifierClasses);
 }
Example #11
0
 /**
  * {@inheritdoc}
  */
 public function canBeUsed()
 {
     return OsHelper::isWindows() && OsHelper::isWindowsEightOrHigher();
 }
Example #12
0
 /**
  * {@inheritdoc}
  */
 public function canBeUsed()
 {
     return OsHelper::isWindows() && OsHelper::isWindowsSeven();
 }