Initial commit
This commit is contained in:
30
tests/Header/HeaderPackerTest.php
Normal file
30
tests/Header/HeaderPackerTest.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\React\Http2\Header;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(HeaderBag::class)]
|
||||
#[CoversClass(HeaderPacker::class)]
|
||||
class HeaderPackerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testUnpackingExamplesFromRfc7541()
|
||||
{
|
||||
$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($expect, $out);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
38
tests/Huffman/CodecTest.php
Normal file
38
tests/Huffman/CodecTest.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\React\Http2\Huffman;
|
||||
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
|
||||
#[CoversClass(Codec::class)]
|
||||
#[CoversClass(Dictionary::class)]
|
||||
class CodecTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testDecodingExamplesFromRfc7541()
|
||||
{
|
||||
$dict = Dictionary::createRfc7541Dictionary();
|
||||
$huff = new Codec($dict);
|
||||
|
||||
$in = "\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff";
|
||||
$expect = "www.example.com";
|
||||
$out = $huff->decode($in);
|
||||
|
||||
$this->assertEquals($expect, $out);
|
||||
|
||||
}
|
||||
|
||||
public function testEncodingExamplesFromRfc7541()
|
||||
{
|
||||
$dict = Dictionary::createRfc7541Dictionary();
|
||||
$huff = new Codec($dict);
|
||||
|
||||
$in = "www.example.com";
|
||||
$expect = "\xf1\xe3\xc2\xe5\xf2\x3a\x6b\xa0\xab\x90\xf4\xff";
|
||||
$out = $huff->encode($in);
|
||||
|
||||
$this->assertEquals($expect, $out);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user