1
0
mirror of https://github.com/danog/parallel.git synced 2024-12-02 09:37:57 +01:00
parallel/test/Sync/ChannelParserTest.php
Aaron Piotrowski 4cbdddd052
Fix code style
2018-01-22 17:36:50 -06:00

40 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);
}
}