public function __construct($processes)
 {
     if (!is_array($processes)) {
         $processes = array($processes);
     }
     foreach ($processes as $process) {
         $check = new ProcessRunning($process);
         $check->setLabel(sprintf('Process "%s" running', $process));
         $this->checks[sprintf('process_%s_running', $process)] = $check;
     }
 }
 /**
  * Covers the specific diagnostic checks for the module.
  *
  * @return array
  */
 public function getDiagnostics()
 {
     return array('Cache & Log Directories Available' => function () {
         $diagnostic = new DirWritable(array(__DIR__ . '/../../data/cache', __DIR__ . '/../../data/log'));
         return $diagnostic->check();
     }, 'Check PHP extensions' => function () {
         $diagnostic = new ExtensionLoaded(array('json', 'pdo', 'pdo_pgsql', 'intl', 'session', 'pcre', 'zlib', 'Zend OPcache'));
         return $diagnostic->check();
     }, 'Check Apache is running' => function () {
         $diagnostic = new ProcessRunning('apache2');
         return $diagnostic->check();
     }, 'Check PostgreSQL is running' => function () {
         $diagnostic = new ProcessRunning('postgresql');
         return $diagnostic->check();
     }, 'Check Memcached is running' => function () {
         $diagnostic = new ProcessRunning('beanstalkd');
         return $diagnostic->check();
     }, 'Check PHP Version' => function () {
         $diagnostic = new PhpVersion('5.3.0', '>=');
         return $diagnostic->check();
     });
 }
 public function testProcessRunning()
 {
     if (!($phpPid = @getmypid())) {
         $this->markTestSkipped('Unable to retrieve PHP process\' PID');
     }
     $check = new ProcessRunning($phpPid);
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Success', $result);
     $check = new ProcessRunning(32768);
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Failure', $result);
     $this->assertStringMatchesFormat('%sPID 32768%s', $result->getMessage());
     // try to retrieve full PHP process command string
     $phpCommand = shell_exec('ps -o command= -p ' . $phpPid);
     if (!$phpCommand || strlen($phpCommand) < 4) {
         $this->markTestSkipped('Unable to retrieve PHP process command name.');
     }
     $check = new ProcessRunning(substr($phpCommand, 0, ceil(strlen($phpPid) / 2)));
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Success', $result);
     $check = new ProcessRunning('improbable process name 9999999999999999');
     $result = $check->check();
     $this->assertInstanceOf('ZendDiagnostics\\Result\\Failure', $result);
     $this->assertStringMatchesFormat('%simprobable process name 9999999999999999%s', $result->getMessage());
 }