php-ipc/tests/Interop/Channel/MultiStreamChannelTest.php

44 lines
1.1 KiB
PHP
Raw Normal View History

<?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());
}
}