-
Notifications
You must be signed in to change notification settings - Fork 263
Expand file tree
/
Copy pathRewriteLocationFilterTest.php
More file actions
41 lines (33 loc) · 1.09 KB
/
RewriteLocationFilterTest.php
File metadata and controls
41 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Proxy\Filter;
use PHPUnit\Framework\TestCase;
use Laminas\Diactoros\Request;
use Laminas\Diactoros\Response;
class RewriteLocationFilterTest extends TestCase
{
/**
* @var RewriteLocationFilter
*/
private $filter;
public function setUp(): Void
{
$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, $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));
}
}