Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php namespace Proxy\Filter; | ||
|
||
use Zend\Diactoros\Request; | ||
use Zend\Diactoros\Response; | ||
|
||
class RewriteLocationFilterTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var RewriteLocationFilter | ||
*/ | ||
private $filter; | ||
|
||
public function setUp() | ||
{ | ||
$this->filter = new RewriteLocationFilter(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function filter_rewrites_location() | ||
{ | ||
$_SERVER['SCRIPT_NAME'] = ""; | ||
$redirect_url = 'http://www.example.com/path?arg1=123&arg2=456'; | ||
$request = new Request; | ||
$response = new Response('php://memory', 200, [RewriteLocationFilter::LOCATION => $redirect_url]); | ||
$next = function () use ($response) { return $response; }; | ||
|
||
$response = call_user_func($this->filter, $request, $response, $next); | ||
|
||
$this->assertTrue($response->hasHeader('X-Proxy-Location')); | ||
$this->assertTrue($response->hasHeader(RewriteLocationFilter::LOCATION)); | ||
$this->assertEquals('/path?arg1=123&arg2=456', $response->getHeaderLine(RewriteLocationFilter::LOCATION)); | ||
} | ||
|
||
} |