This interface is implemented by transports to provide means to send requests over the wire.
Пример #1
0
 public function testAppendingParams()
 {
     $this->serializer->expects($this->once())->method('serialize')->with('methodName', array('p0', 'p1', 'p2', 'p3'))->will($this->returnValue('REQUEST'));
     $this->transport->expects($this->once())->method('send')->with('http://foo.com', 'REQUEST')->will($this->returnValue('RESPONSE'));
     $this->parser->expects($this->once())->method('parse')->with('RESPONSE')->will($this->returnValue('NATIVE VALUE'));
     $this->assertSame(array(), $this->client->getAppendParams());
     $this->client->appendParams(array('p2', 'p3'));
     $this->assertSame(array('p2', 'p3'), $this->client->getAppendParams());
     $this->assertSame('NATIVE VALUE', $this->client->call('methodName', array('p0', 'p1')));
 }
Пример #2
0
 /** {@inheritdoc} */
 public function send($endpoint, $payload)
 {
     $this->lastResponse = $this->lastException = null;
     $this->lastRequest = $payload;
     try {
         $this->lastResponse = $this->transport->send($endpoint, $payload);
         return $this->lastResponse;
     } catch (Exception $e) {
         $this->lastException = $e;
         throw $e;
     }
 }
Пример #3
0
 /** {@inheritdoc} */
 public function call($methodName, array $params = [])
 {
     if (!is_string($methodName)) {
         throw InvalidArgumentException::expectedParameter(0, 'string', $methodName);
     }
     $params = array_merge($this->prependParams, $params, $this->appendParams);
     $payload = $this->serializer->serialize($methodName, $params);
     $response = $this->transport->send($this->uri, $payload);
     return $this->parser->parse($response);
 }
Пример #4
0
 private function transportFail(InvocationMatcher $matcher = null)
 {
     $matcher = $matcher ?: $this->once();
     $this->transport->expects($matcher)->method('send')->willThrowException($this->exception);
 }
Пример #5
0
 private function mockTransport($endpoint, $request, $response)
 {
     $this->transport->expects($this->once())->method('send')->with($endpoint, $request)->willReturn($response);
 }