public function testCall() { $request = new Request('foo'); $this->syncDriver->expects($this->once())->method('call')->with(new Identity('bug'), $request); $this->asyncDriver->expects($this->never())->method('call'); $this->splitDriver->call(new Identity('bug'), $request); }
/** * Make sure publish is logged. */ public function testCall() { $this->innerDriver->expects(self::once())->method('call')->willReturn(new Promise(function () { return new Response(''); })); $this->logger->expects(self::exactly(2))->method('debug'); $this->driver->call(new Identity(''), new Request(''))->resolve(); }
/** * Endpoint should delegate RPC calls to the driver. */ public function testCall() { $request = new Request(''); $promise = new Promise(function () { }); $this->driver->expects($this->once())->method('call')->with($this->identity, $request)->willReturn($promise); $returned = $this->endpoint->call($request); $this->assertSame($promise, $returned); }
/** * {@inheritdoc} */ public function call(Identity $identity, Request $request) { $this->dispatcher->dispatch(CallEvent::NAME, new CallEvent($identity, $request)); $promise = $this->driver->call($identity, $request); return new Promise(function ($timeout) use($identity, $request, $promise) { $response = $promise->resolve($timeout); $this->dispatcher->dispatch(ReplyEvent::NAME, new ReplyEvent($identity, $request, $response)); return $response; }); }
/** * {@inheritdoc} */ public function call(Identity $identity, Request $request) { $this->logger->debug('Call "%method%" to service "%service%"', ['service' => $identity->getName(), 'request_method' => $request->getMethod(), 'request_arguments' => $request->getArguments(), 'request_headers' => $request->getHeaders(), 'driver' => get_class($this->driver)]); $promise = $this->driver->call($identity, $request); return new Promise(function ($timeout) use($identity, $request, $promise) { $response = $promise->resolve($timeout); $this->logger->debug('Response from "%service%"', ['service' => $identity->getName(), 'request_method' => $request->getMethod(), 'response_value' => $response->getValue(), 'response_headers' => $response->getHeaders(), 'driver' => get_class($this->driver)]); return $response; }); }
public function testCall() { $this->driverA->expects(self::any())->method('supports')->willReturnCallback(function ($schema) { return $schema == 'foo'; }); $this->driverA->expects(self::once())->method('call')->with(self::anything(), new Request('foo')); $this->driverB->expects(self::any())->method('supports')->willReturnCallback(function ($schema) { return $schema == 'bar'; }); $this->driverB->expects(self::once())->method('call')->with(self::anything(), new Request('bar')); $this->arrayDriver->call(new Identity('foo', ['foo://localhost']), new Request('foo')); $this->arrayDriver->call(new Identity('bar', ['bar://localhost']), new Request('bar')); }
/** * 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 Promise($resolver)); $this->driver->call(new Identity('foo'), $this->request); }
/** * {@inheritdoc} */ public function call(RequestInterface $request) { return $this->driver->call($this->identity, Request::cast($request)); }
/** * {@inheritdoc} */ public function call(Identity $identity, Request $request) { return $this->syncDriver->call($identity, $request); }