Skip to content

Commit

Permalink
qa: add failing unit test for iterator extension in Headers#toArray
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Bösing <[email protected]>
  • Loading branch information
boesing committed Dec 3, 2021
1 parent 4a08a41 commit 5425384
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PHPUnit\Framework\TestCase;

use function implode;
use function sprintf;

class HeadersTest extends TestCase
{
Expand Down Expand Up @@ -439,4 +440,18 @@ public function testThrowExceptionOnInvalidHeader()
$this->expectExceptionMessage('Invalid header value detected');
$headers->get('Location');
}

public function testToArrayCanHandleIteratorExtensionForMultipleHeaderValue()
{
$headerValue = 'cookie1=value1; Expires=Sun, 02-Jan-2022 08:54:16 GMT; Domain=.example.org; Path=/;'
. ' Secure; SameSite=Lax, cookie2=value2; Expires=Sun, 02-Jan-2022 08:54:16 GMT; Domain=.example.org; Path=/;'
. ' Secure; SameSite=Lax, cookie3=value3; Expires=Sun, 02-Jan-2022 08:54:16 GMT; Domain=.example.org; Path=/;'
. ' Secure; SameSite=Lax';
$headers = Headers::fromString(sprintf('Set-Cookie: %s', $headerValue));

$headersArray = $headers->toArray();
self::assertCount(1, $headersArray);
self::assertArrayHasKey('Set-Cookie', $headersArray);
self::assertEquals($headerValue, implode(', ', $headersArray['Set-Cookie']));
}
}

0 comments on commit 5425384

Please sign in to comment.