Initial commit
This commit is contained in:
33
tests/Line/LineProtocolTest.php
Normal file
33
tests/Line/LineProtocolTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user