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

Commit e383d13

Browse files
committed
Add test to verify Scheme retrieval is correct
This adds the test and the CHANGELOG-entry for the changed method # Conflicts: # CHANGELOG.md
1 parent ae3aec8 commit e383d13

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22

33
All notable changes to this project will be documented in this file, in reverse chronological order by release.
44

5+
## 1.8.7 - TBD
6+
7+
### Added
8+
9+
- Nothing.
10+
11+
### Changed
12+
13+
- Nothing.
14+
15+
### Deprecated
16+
17+
- Nothing.
18+
19+
### Removed
20+
21+
- Nothing.
22+
23+
### Fixed
24+
25+
- [#364](https://github.com/zendframework/zend-diactoros/issues/364) modifies detection of HTTPS schemas via the `$_SERVER['HTTPS']` value
26+
such that an empty HTTPS-key will result in a scheme of `http` and not
27+
`https`.
28+
529
## 1.8.6 - 2018-09-05
630

731
### Added
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository
4+
* @copyright Copyright (c) 2018 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
namespace ZendTest\Diactoros\functions;
9+
10+
use PHPUnit\Framework\TestCase;
11+
use function Zend\Diactoros\marshalUriFromSapi;
12+
13+
class MarshalUriFromSapiTest extends TestCase
14+
{
15+
/** @dataProvider returnsUrlWithCorrectHttpSchemeFromArraysProvider */
16+
public function testReturnsUrlWithCorrectHttpSchemeFromArrays(string $httpsValue, string $expectedScheme) : void
17+
{
18+
$server = [
19+
"HTTPS" => $httpsValue,
20+
"SERVER_NAME"=> "localhost",
21+
"SERVER_PORT"=>"80",
22+
"SERVER_ADDR"=> "172.22.0.4",
23+
"REMOTE_PORT"=> "36852",
24+
"REMOTE_ADDR" => "172.22.0.1",
25+
"SERVER_SOFTWARE" => "nginx/1.11.8",
26+
"GATEWAY_INTERFACE" => "CGI/1.1",
27+
"SERVER_PROTOCOL" => "HTTP/1.1",
28+
"DOCUMENT_ROOT" => "/var/www/public",
29+
"DOCUMENT_URI" => "/index.php",
30+
"REQUEST_URI" => "/api/messagebox-schema",
31+
"PATH_TRANSLATED" => "/var/www/public",
32+
"PATH_INFO" => "",
33+
"SCRIPT_NAME" => "/index.php",
34+
"CONTENT_LENGTH" => "",
35+
"CONTENT_TYPE" => "",
36+
"REQUEST_METHOD" => "GET",
37+
"QUERY_STRING" => "",
38+
"SCRIPT_FILENAME" => "/var/www/public/index.php",
39+
"FCGI_ROLE" => "RESPONDER",
40+
"PHP_SELF" => "/index.php",
41+
];
42+
43+
$headers = [
44+
"HTTP_COOKIE" => '',
45+
"HTTP_ACCEPT_LANGUAGE" => "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
46+
"HTTP_ACCEPT_ENCODING" => "gzip, deflate, br",
47+
"HTTP_REFERER" => "http://localhost:8080/index.html",
48+
"HTTP_USER_AGENT" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/67.0.3396.99 Chrome/67.0.3396.99 Safari/537.36",
49+
"HTTP_ACCEPT" => "application/json,*/*",
50+
"HTTP_CONNECTION" => "keep-alive",
51+
"HTTP_HOST" => "localhost:8080",
52+
];
53+
54+
$url = marshalUriFromSapi($server, $headers);
55+
56+
self::assertSame($expectedScheme, $url->getScheme());
57+
}
58+
59+
public function returnsUrlWithCorrectHttpSchemeFromArraysProvider() : array
60+
{
61+
return [
62+
'on-lowercase' => ['on', 'https'],
63+
'on-uppercase' => ['ON', 'https'],
64+
'off-lowercase' => ['off', 'http'],
65+
'off-mixed-case' => ['oFf', 'http'],
66+
'neither-on-nor-off' => ['foo', 'http'],
67+
'empty' => ['', 'http'],
68+
];
69+
}
70+
}

0 commit comments

Comments
 (0)