/** * @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(); }
public function testIsUnix() { if ('\\' === DIRECTORY_SEPARATOR) { $this->assertFalse(OsHelper::isUnix()); } if ('/' === DIRECTORY_SEPARATOR) { $this->assertTrue(OsHelper::isUnix()); } }
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()); }
/** * 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); }