Example #1
0
 public function testCloneIsDeep()
 {
     $r = new puzzle_message_Request('GET', '/test', array('foo' => 'baz'), puzzle_stream_Stream::factory('foo'));
     $r2 = clone $r;
     $this->assertNotSame($r->getEmitter(), $r2->getEmitter());
     $this->assertEquals('foo', $r2->getBody());
     $r->getConfig()->set('test', 123);
     $this->assertFalse($r2->getConfig()->hasKey('test'));
     $r->setPath('/abc');
     $this->assertEquals('/test', $r2->getPath());
 }
 public function testSendsWithStreamingAdapter()
 {
     $response = new puzzle_message_Response(200);
     $mock = $this->getMockBuilder('puzzle_adapter_AdapterInterface')->setMethods(array('send'))->getMockForAbstractClass();
     $mock->expects($this->never())->method('send');
     $streaming = $this->getMockBuilder('puzzle_adapter_AdapterInterface')->setMethods(array('send'))->getMockForAbstractClass();
     $streaming->expects($this->once())->method('send')->will($this->returnValue($response));
     $request = new puzzle_message_Request('GET', '/');
     $request->getConfig()->set('stream', true);
     $s = new puzzle_adapter_StreamingProxyAdapter($mock, $streaming);
     $this->assertSame($response, $s->send(new puzzle_adapter_Transaction(new puzzle_Client(), $request)));
 }
Example #3
0
 /**
  * @expectedException puzzle_exception_AdapterException
  */
 public function testThrowsForStreamOption()
 {
     $request = new puzzle_message_Request('GET', puzzle_test_Server::$url . 'haha');
     $request->getConfig()->set('stream', true);
     $t = new puzzle_adapter_Transaction(new puzzle_Client(), $request);
     $f = new puzzle_adapter_curl_CurlFactory();
     $f->__invoke($t, new puzzle_message_MessageFactory());
 }