public function testHasRequestAndClient() { $c = new Client(); $req = new Request('GET', '/'); $response = new Response(200); $t = new 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()); }
public function testUsesDefaultBodyIfNoneSet() { $t = new Transaction(new Client(), new Request('GET', 'http://httbin.org')); $t->setResponse(new Response(200)); $m = new RequestMediator($t, new MessageFactory()); $this->assertEquals(3, $m->writeResponseBody(null, 'foo')); $this->assertEquals('foo', (string) $t->getResponse()->getBody()); }
public function testAddsMockResponseToRequestFromClient() { $response = new Response(200); $t = new Transaction(new Client(), new Request('GET', '/')); $m = new Mock([$response]); $ev = new BeforeEvent($t); $m->onBefore($ev); $this->assertSame($response, $t->getResponse()); }