public function testLookupWithInvalidResponseEntry() { $newIdentity = new Identity('foo', ['http://localhost']); $this->backend->expects(self::exactly(2))->method('get')->with('foo')->willReturnOnConsecutiveCalls(null, $newIdentity); $this->discovery->expects(self::once())->method('call')->with(new Discover())->willReturn(new Promise(function () { return new Response([['name' => 'foo', 'urls' => ['http://localhost']], ['invalid']]); })); $this->backend->expects(self::once())->method('register')->with($newIdentity); $identity = $this->registry->get('foo'); self::assertSame($newIdentity, $identity); }
public function testHandleRPCException() { $this->endpoint->expects($this->once())->method('call')->willThrowException(new \Exception('foo', 129)); $request = new Delivery($this->channel, 'cons', 1, false, '', 'boo', '{}', ['reply-to' => 'foo']); $reply = $this->handler->handle($request); $this->assertNotNull($reply); $headers = $reply->getHeaders(); $this->assertArrayHasKey('x-error', $headers); $this->assertEquals('foo', $headers['x-error']); $this->assertArrayHasKey('x-error-code', $headers); $this->assertEquals(129, $headers['x-error-code']); }
/** * {@inheritdoc} */ protected function setUp() { $this->endpoint = $this->createMock(EndpointInterface::class); $this->endpoint->expects(self::once())->method('getIdentity')->willReturn(new Identity('foo')); $this->discovery = new ArrayDiscovery([$this->endpoint]); }