Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit f5559e2

Browse files
committed
Added failing unit test for X-Forwarded-Host
1 parent 825e3bf commit f5559e2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/functions/MarshalUriFromSapiTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,36 @@ public function returnsUrlWithCorrectHttpSchemeFromArraysProvider() : array
7474
'empty' => ['', 'http'],
7575
];
7676
}
77+
78+
/**
79+
* @dataProvider returnsUrlWithCorrectSchemeAndHostFromArrays
80+
*/
81+
public function testReturnsUrlWithCorrectSchemeAndHostFromArrays(string $expectedScheme, string $expectedHost, array $server, array $headers) : void
82+
{
83+
$uri = marshalUriFromSapi($server, $headers);
84+
self::assertSame($expectedScheme, $uri->getScheme());
85+
self::assertSame($expectedHost, $uri->getHost());
86+
}
87+
88+
public function returnsUrlWithCorrectSchemeAndHostFromArrays() : array
89+
{
90+
return [
91+
'x-forwarded-proto' => [
92+
'https',
93+
'localhost',
94+
[
95+
'SERVER_NAME' => 'localhost',
96+
],
97+
['X-Forwarded-Proto' => 'https'],
98+
],
99+
'x-forwarded-host' => [
100+
'http',
101+
'example.org',
102+
[
103+
'SERVER_NAME' => 'localhost',
104+
],
105+
['X-Forwarded-Host' => 'example.org'],
106+
],
107+
];
108+
}
77109
}

0 commit comments

Comments
 (0)