Initial commit
This commit is contained in:
37
tests/Interop/Channel/StreamChannelTest.php
Normal file
37
tests/Interop/Channel/StreamChannelTest.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Ipc\Interop\Channel;
|
||||
|
||||
|
||||
|
||||
class StreamChannelTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testCreatingFromStreams()
|
||||
{
|
||||
$fd = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
|
||||
|
||||
$sc1 = new StreamChannel($fd[0]);
|
||||
$sc2 = new StreamChannel($fd[1]);
|
||||
|
||||
$frame = "Hello World";
|
||||
|
||||
$sc1->send($frame);
|
||||
$rcvd = $sc2->receive();
|
||||
|
||||
$this->assertEquals($frame, $rcvd);
|
||||
}
|
||||
|
||||
public function testCreatingPair()
|
||||
{
|
||||
[ $sc1, $sc2 ] = StreamChannel::createPair();
|
||||
|
||||
$frame = "Hello World";
|
||||
|
||||
$sc1->send($frame);
|
||||
$rcvd = $sc2->receive();
|
||||
|
||||
$this->assertEquals($frame, $rcvd);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user