public function testReadsRequestBody()
 {
     $response = new puzzle_message_Response(200);
     $m = new puzzle_adapter_MockAdapter($response);
     $m->setResponse($response);
     $body = puzzle_stream_Stream::factory('foo');
     $request = new puzzle_message_Request('PUT', 'http://httpbin.org/put', array(), $body);
     $this->assertSame($response, $m->send(new puzzle_adapter_Transaction(new puzzle_Client(), $request)));
     $this->assertEquals(3, $body->tell());
 }
Exemple #2
0
 public function testSendingRequestCanBeIntercepted()
 {
     $response = new puzzle_message_Response(200);
     $this->_closure_testSendingRequestCanBeIntercepted_response = new puzzle_message_Response(200);
     $adapter = new puzzle_adapter_MockAdapter();
     $adapter->setResponse($response);
     $client = new puzzle_Client(array('adapter' => $adapter));
     $client->getEmitter()->on('before', array($this, '__callback_testSendingRequestCanBeIntercepted'));
     $this->assertSame($this->_closure_testSendingRequestCanBeIntercepted_response, $client->get('http://test.com'));
     $this->assertEquals('http://test.com', $this->_closure_testSendingRequestCanBeIntercepted_response->getEffectiveUrl());
 }