Initial commit

This commit is contained in:
Christopher Vagnetoft
2026-04-02 22:29:35 +02:00
commit 62a1167055
31 changed files with 3759 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
<?php
namespace NoccyLabs\React\Protocol\Line;
use PHPUnit\Framework\Attributes\CoversClass;
use React\Stream\CompositeStream;
use React\Stream\ThroughStream;
#[CoversClass(LineProtocol::class)]
class LineProtocolTest extends \PHPUnit\Framework\TestCase
{
public function testFrameSeparators()
{
$proto = new LineProtocol("\n");
$packed = $proto->packFrame(['foo', 'bar']);
$this->assertEquals("foo bar\n", $packed);
}
public function testConsumingFrames()
{
$proto = new LineProtocol(
lineBreak: "\n"
);
$buffer = "foo true\nbar false\n";
$msg1 = $proto->consumeFrame($buffer);
$msg2 = $proto->consumeFrame($buffer);
$this->assertEquals(['foo','true'], $msg1);
$this->assertEquals(['bar','false'], $msg2);
}
}