/** * Test finalize * * Pre-conditions: * Case A: Response status is 200 * Case B: Response status is 204 * Case C: Response status is 304 * * Post-conditions: * Case A: Response has body and content-length * Case B: Response does not have body and content-length * Case C: Response does not have body and content-length */ public function testFinalize() { //Case A $r1 = new Response(); $r1->body('body1'); $r1->finalize(); $this->assertEquals($r1->body(), 'body1'); $this->assertEquals($r1->header('Content-Length'), 5); //Case B $r2 = new Response(); $r2->body('body2'); $r2->status(204); $r2->finalize(); $this->assertEquals($r2->body(), ''); $this->assertNull($r2->header('Content-Type')); //Case C $r3 = new Response(); $r3->body('body3'); $r3->status(304); $r3->finalize(); $this->assertEquals($r3->body(), ''); $this->assertNull($r3->header('Content-Type')); }