public function testSetResponse() { $this->provider->register('response', function () { $response = new Response(); return $response->withStatus(500); }); $this->assertEquals(500, $this->provider->getResponse()->getStatusCode()); $newResponse = new Response(); $newResponse = $newResponse->withStatus(404); $this->provider->setResponse($newResponse); $this->assertEquals(404, $this->provider->getResponse()->getStatusCode()); }
public function testToString() { $string = "HTTP/1.1 200 OK\n"; $string .= "X-Some: foo\n\n"; $string .= "some some"; $stream = fopen('php://temp', 'r+'); $streamObject = new Stream($stream); $response = new Response($streamObject, 200, ['X-Some' => 'foo'], '1.1'); $response->write('some some'); $this->expectOutputString($string); echo $response; }