Beispiel #1
0
 public function testGetSocket_asksInternalResponseOath()
 {
     $internalSocket = 'socket';
     /** @var \PHPUnit_Framework_MockObject_MockObject|ResponseOath $responseOathMock */
     $responseOathMock = $this->getMockBuilder(ResponseOath::class)->disableOriginalConstructor()->setMethods(['getSocket'])->getMock();
     $responseOathMock->expects($this->once())->method('getSocket')->willReturn($internalSocket);
     $jobOath = new JobOath($responseOathMock);
     $this->assertSame($internalSocket, $jobOath->getSocket());
 }
Beispiel #2
0
 /**
  * @param \EvWatcher $watcher
  * @param BeanieWorker $worker
  * @param JobOath $jobOath
  */
 protected function handleIncomingJob(\EvWatcher $watcher, BeanieWorker $worker, JobOath $jobOath)
 {
     pcntl_sigprocmask(SIG_BLOCK, $this->terminationSignals);
     try {
         $job = $jobOath->invoke();
         call_user_func($this->jobReceivedCallback, $job);
     } catch (SocketException $socketException) {
         $this->logger->error($socketException->getCode() . ': ' . $socketException->getMessage());
         $this->removeWatcher($watcher);
         $this->removeJobListener($worker);
         return;
     } catch (\Exception $exception) {
         $this->logger->error($exception->getCode() . ': ' . $exception->getMessage());
         $this->removeWatcher($watcher);
         return;
     } finally {
         pcntl_sigprocmask(SIG_UNBLOCK, $this->terminationSignals);
     }
     $worker->reserveOath();
 }