This repository has been archived by the owner on Jan 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for marshalHeadersFromSapi function
- integer keys should be ignored - `_` should be changed to `-` in key (also for `CONTENT_*` headers)
- Loading branch information
1 parent
aaf7c43
commit 3a045fe
Showing
1 changed file
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
/** | ||
* @see https://github.com/zendframework/zend-diactoros for the canonical source repository | ||
* @copyright Copyright (c) 2019 Zend Technologies USA Inc. (https://www.zend.com) | ||
* @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ZendTest\Diactoros\functions; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
use function Zend\Diactoros\marshalHeadersFromSapi; | ||
|
||
class MarshalHeadersFromSapiTest extends TestCase | ||
{ | ||
public function testReturnsHeaders() : void | ||
{ | ||
$server = [ | ||
'REDIRECT_CONTENT_FOO' => 'redirect-foo', | ||
'CONTENT_FOO' => null, | ||
'REDIRECT_CONTENT_BAR' => 'redirect-bar', | ||
'CONTENT_BAR' => '', | ||
'REDIRECT_CONTENT_BAZ' => 'redirect-baz', | ||
'CONTENT_BAZ' => 'baz', | ||
'REDIRECT_CONTENT_VAR' => 'redirect-var', | ||
|
||
'REDIRECT_HTTP_ABC' => 'redirect-abc', | ||
'HTTP_ABC' => null, | ||
'REDIRECT_HTTP_DEF' => 'redirect-def', | ||
'HTTP_DEF' => '', | ||
'REDIRECT_HTTP_GHI' => 'redirect-ghi', | ||
'HTTP_GHI' => 'ghi', | ||
'REDIRECT_HTTP_JKL' => 'redirect-jkl', | ||
|
||
'HTTP_TEST_MNO' => 'mno', | ||
'HTTP_TEST_PQR' => '', | ||
'HTTP_TEST_STU' => null, | ||
'CONTENT_TEST_VW' => 'vw', | ||
'CONTENT_TEST_XY' => '', | ||
'CONTENT_TEST_ZZ' => null, | ||
|
||
123 => 'integer', | ||
]; | ||
|
||
$expectedHeaders = [ | ||
'content-foo' => null, | ||
'content-baz' => 'baz', | ||
'content-var' => 'redirect-var', | ||
|
||
'abc' => null, | ||
'ghi' => 'ghi', | ||
'jkl' => 'redirect-jkl', | ||
|
||
'test-mno' => 'mno', | ||
'test-stu' => null, | ||
'content-test-vw' => 'vw', | ||
'content-test-zz' => null, | ||
]; | ||
|
||
$headers = marshalHeadersFromSapi($server); | ||
|
||
self::assertSame($expectedHeaders, $headers); | ||
} | ||
} |