public function testCall()
 {
     $request = new Request('foo', '1');
     $this->syncDriver->expects($this->once())->method('call')->with(new Location('bug'), $request);
     $this->asyncDriver->expects($this->never())->method('call');
     $this->splitDriver->call(new Location('bug'), $request);
 }
 /**
  * Endpoint should delegate RPC calls to the driver.
  */
 public function testCall()
 {
     $request = new Request('', null);
     $promise = new Response\Promise(function () {
     });
     $this->driver->expects($this->once())->method('call')->with('calc', $request)->willReturn($promise);
     $returned = $this->endpoint->call($request);
     $this->assertSame($promise, $returned);
 }
 /**
  * {@inheritdoc}
  */
 public function call(LocationInterface $location, Request $request)
 {
     $this->dispatcher->dispatch(CallEvent::NAME, new CallEvent($location, $request));
     $promise = $this->driver->call($location, $request);
     return new Response\Promise(function ($timeout) use($location, $request, $promise) {
         $response = $promise->resolve($timeout);
         $this->dispatcher->dispatch(ReplyEvent::NAME, new ReplyEvent($location, $request, $response));
         return $response;
     });
 }
 public function testCallSkipDriverWhenThresholdIsReached()
 {
     $this->primaryDriver->expects($this->exactly(5))->method('call')->willThrowException(new \Exception('Error'));
     $this->secondaryDriver->expects($this->exactly(6))->method('call');
     for ($tries = 0; $tries < 6; ++$tries) {
         $this->fallbackDriver->call(new Location('foo'), new Request('foo', '0'));
     }
 }
 /**
  * Make sure ReplyEvent is not dispatched if response is not resolved.
  */
 public function testReplyNotDispatchedWhenResponseNotResolved()
 {
     $listener = $this->getCallableMock();
     $listener->expects($this->never())->method('__invoke');
     $resolver = $this->getCallableMock();
     $resolver->expects($this->never())->method('__invoke');
     $this->driver->getDispatcher()->addListener(self::REPLY_EVENT_NAME, $listener);
     $this->innerDriver->expects($this->once())->method('call')->willReturn(new Response\Promise($resolver));
     $this->driver->call(new Location('foo'), $this->request);
 }
 /**
  * Service bus should broadcast messages using given driver.
  */
 public function testBroadcast()
 {
     $request = new Request('', null);
     $this->driver->expects($this->once())->method('broadcast')->with($request);
     $this->serviceBus->broadcast($request);
 }
 /**
  * {@inheritdoc}
  */
 public function broadcast(Request $request)
 {
     $this->driver->broadcast($request);
     return $this;
 }
 /**
  * {@inheritdoc}
  */
 public function call(Request $request)
 {
     return $this->driver->call($this->location, $request);
 }
 /**
  * {@inheritdoc}
  */
 public function call(LocationInterface $location, Request $request)
 {
     return $this->syncDriver->call($location, $request);
 }