Skip to content

Commit

Permalink
added getUri to Request
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick committed Sep 10, 2014
1 parent d5b0ee7 commit ffe65db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ public function getFiles()
return $this->files;
}

/**
* The URI which was given in order to access this page
*
* @return string
* @throws MissingRequestMetaVariableException
*/
public function getUri()
{
return $this->getServerVariable('REQUEST_URI');
}

/**
* Which request method was used to access the page;
* i.e. 'GET', 'HEAD', 'POST', 'PUT'.
Expand Down
21 changes: 21 additions & 0 deletions test/Unit/HttpRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,27 @@ public function testGetMethodException()
$request->getMethod();
}

public function testGetUri()
{
$server = ['REQUEST_URI' => '/test'];

$request = new HttpRequest([], [], [], [], $server);

$this->assertEquals(
$request->getUri(),
$server['REQUEST_URI']
);
}

/**
* @expectedException Http\MissingRequestMetaVariableException
*/
public function testGetUriException()
{
$request = new HttpRequest([], [], [], [], []);
$request->getUri();
}

public function testGetHttpAccept()
{
$server = ['HTTP_ACCEPT' => 'Accept: audio/*; q=0.2, audio/basic'];
Expand Down

0 comments on commit ffe65db

Please sign in to comment.