Пример #1
0
 public function testHasRequestAndClient()
 {
     $c = new puzzle_Client();
     $req = new puzzle_message_Request('GET', '/');
     $response = new puzzle_message_Response(200);
     $t = new puzzle_adapter_Transaction($c, $req);
     $this->assertSame($c, $t->getClient());
     $this->assertSame($req, $t->getRequest());
     $this->assertNull($t->getResponse());
     $t->setResponse($response);
     $this->assertSame($response, $t->getResponse());
 }
Пример #2
0
 public function testUsesDefaultBodyIfNoneSet()
 {
     $t = new puzzle_adapter_Transaction(new puzzle_Client(), new puzzle_message_Request('GET', 'http://httbin.org'));
     $t->setResponse(new puzzle_message_Response(200));
     $m = new puzzle_adapter_curl_RequestMediator($t, new puzzle_message_MessageFactory());
     $this->assertEquals(3, $m->writeResponseBody(null, 'foo'));
     $this->assertEquals('foo', (string) $t->getResponse()->getBody());
 }
Пример #3
0
 public function testAddsMockResponseToRequestFromClient()
 {
     $response = new puzzle_message_Response(200);
     $t = new puzzle_adapter_Transaction(new puzzle_Client(), new puzzle_message_Request('GET', '/'));
     $m = new puzzle_subscriber_Mock(array($response));
     $ev = new puzzle_event_BeforeEvent($t);
     $m->onBefore($ev);
     $this->assertSame($response, $t->getResponse());
 }