Example #1
0
 public function testBasicUsage()
 {
     $builder = new Ergo_Http_ResponseBuilder();
     $builder->addHeader('Content-Type', 'text/plain')->setBody('test')->addHeader('X-Blarg', 'meh')->setStatusCode(418);
     $response = $builder->build();
     $this->assertIsA($response, 'Ergo_Http_Response');
     $this->assertEqual($response->getStatus()->getCode(), 418);
     $this->assertTrue($response->hasBody());
     $this->assertEqual($response->getBody(), 'test');
     $headers = $response->getHeaders()->toArray();
     $this->assertEqual(count($headers), 3, 'should be 3 headers: %s');
     $this->assertEqual($headers[0], "Content-Type: text/plain\r\n");
     $this->assertEqual($headers[1], "X-Blarg: meh\r\n");
     $this->assertEqual($headers[2], "Content-Length: 4\r\n");
 }