Added MultiStreamChannel to handle multiple endpoints
This commit is contained in:
44
tests/Interop/Channel/MultiStreamChannelTest.php
Normal file
44
tests/Interop/Channel/MultiStreamChannelTest.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace NoccyLabs\Ipc\Interop\Channel;
|
||||
|
||||
|
||||
|
||||
class MultiStreamChannelTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function testCreatingMultipleClients()
|
||||
{
|
||||
$master = new MultiStreamChannel();
|
||||
|
||||
$client1 = $master->createClient();
|
||||
$client2 = $master->createClient();
|
||||
$client3 = $master->createClient();
|
||||
|
||||
$master->send("Hello World");
|
||||
|
||||
$this->assertEquals("Hello World", $client1->receive());
|
||||
$this->assertEquals("Hello World", $client2->receive());
|
||||
$this->assertEquals("Hello World", $client3->receive());
|
||||
|
||||
}
|
||||
|
||||
public function testReadingFromMultipleClients()
|
||||
{
|
||||
$master = new MultiStreamChannel();
|
||||
|
||||
$client1 = $master->createClient();
|
||||
$client2 = $master->createClient();
|
||||
$client3 = $master->createClient();
|
||||
|
||||
$client1->send("a");
|
||||
$client2->send("b");
|
||||
$client3->send("c");
|
||||
|
||||
$this->assertEquals("a", $master->receive());
|
||||
$this->assertEquals("b", $master->receive());
|
||||
$this->assertEquals("c", $master->receive());
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user