Ergo\Http\ResponseBuilder::found PHP Method

found() public method

Configures response as a '302 Found' temporary redirect.
public found ( string $location )
$location string
    public function found($location)
    {
        $this->_location = $location;
        return $this->setStatusCode(302);
    }

Usage Example

Example #1
0
 public function testRedirectTemporary()
 {
     $builder = new Http\ResponseBuilder();
     $response = $builder->found('http://example.org/test')->build();
     $this->assertEquals($response->getStatus()->getCode(), 302);
     $this->assertFalse($response->hasBody());
     $headers = $response->getHeaders()->toArray();
     $this->assertEquals(count($headers), 2, 'should be 2 header: %s');
     $this->assertEquals($headers[0], "Location: http://example.org/test\r\n");
     $this->assertEquals($headers[1], "Content-Length: 0\r\n");
 }