Christopher Vagnetoft
d41cfb1be2
* Made headers public readonly in HeadersFrame * Fetching headers by value implemented * Initial tests for HeaderBag
34 lines
938 B
PHP
34 lines
938 B
PHP
<?php
|
|
|
|
namespace NoccyLabs\React\Http2\Header;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
#[CoversClass(HeaderBag::class)]
|
|
#[CoversClass(HeaderPacker::class)]
|
|
class HeaderBagTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
|
|
public function testHeadersInExamplesFromRfc7541()
|
|
{
|
|
$packer = new HeaderPacker();
|
|
|
|
$in = "\x82\x86\x84\x41\x8c\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff";
|
|
$expect = new HeaderBag([
|
|
':method' => 'GET',
|
|
':scheme' => 'http',
|
|
':path' => '/',
|
|
':authority' => 'www.example.com'
|
|
]);
|
|
$out = $packer->unpackHeaders($in);
|
|
|
|
$this->assertEquals('GET', $out->getHeaderLine(':method'));
|
|
$this->assertEquals('http', $out->getHeaderLine(':scheme'));
|
|
$this->assertEquals('/', $out->getHeaderLine(':path'));
|
|
$this->assertEquals('www.example.com', $out->getHeaderLine(':authority'));
|
|
|
|
}
|
|
|
|
|
|
}
|