addHeader() public method

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