1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 17:52:14 +01:00
parallel/test/Sync/ChannelParserTest.php
Aaron Piotrowski b654463339
Fix code style
2018-10-07 09:50:45 -05:00

44 lines
1.2 KiB
PHP

<?php
namespace Amp\Parallel\Test\Sync;
use Amp\Parallel\Sync\ChannelParser;
use Amp\PHPUnit\TestCase;
class ChannelParserTest extends TestCase
{
/**
* @expectedException \Amp\Parallel\Sync\SerializationException
* @expectedExceptionMessage Exception thrown when unserializing data
*/
public function testCorruptedData()
{
$data = "Invalid serialized data";
$data = \pack("CL", 0, \strlen($data)) . $data;
$parser = new ChannelParser($this->createCallback(0));
$parser->push($data);
}
/**
* @expectedException \Amp\Parallel\Sync\ChannelException
* @expectedExceptionMessage Invalid packet received: Invalid packet
*/
public function testInvalidHeaderData()
{
$data = "Invalid packet";
$parser = new ChannelParser($this->createCallback(0));
$parser->push($data);
}
/**
* @expectedException \Amp\Parallel\Sync\ChannelException
* @expectedExceptionMessage Invalid packet received: B \xf3\xf2\x0\x1
*/
public function testInvalidHeaderBinaryData()
{
$data = "\x42\x20\xf3\xf2\x00\x01";
$parser = new ChannelParser($this->createCallback(0));
$parser->push($data);
}
}