Kraken\_Module\Channel\ChannelTest::testChannel_PushesAndReceivesData_InPairWithOnlineBuffer PHP Method

testChannel_PushesAndReceivesData_InPairWithOnlineBuffer() public method

    public function testChannel_PushesAndReceivesData_InPairWithOnlineBuffer($data)
    {
        $this->simulate(function (SimulationInterface $sim) use($data) {
            $loop = $sim->getLoop();
            $sim->delayOnce('pass', 3, function () use($sim) {
                $sim->done();
            });
            $master = $this->createChannel($data['master'], $loop);
            $slaver = $this->createChannel($data['slave1'], $loop);
            $master->on('start', function () use($master, $slaver) {
                $master->push(self::ALIAS_B, self::MSG_1, Channel::MODE_BUFFER_ONLINE);
                $master->push(self::ALIAS_B, self::MSG_2, Channel::MODE_BUFFER_ONLINE);
                $master->push(self::ALIAS_B, [self::MSG_3, self::MSG_4], Channel::MODE_BUFFER_ONLINE);
                $slaver->start();
            });
            $slaver->on('input', function ($alias, $message) use($sim) {
                $sim->expect('input', [$alias, $message->getMessage()]);
                $sim->emit('pass');
            });
            $sim->onStart(function () use($slaver, $master) {
                $master->start();
            });
            $sim->onStop(function () use($slaver, $master) {
                $master->stop();
                $slaver->stop();
                usleep(200000.0);
            });
        })->expect([['input', [self::ALIAS_A, self::MSG_1]], ['input', [self::ALIAS_A, self::MSG_2]], ['input', [self::ALIAS_A, [self::MSG_3, self::MSG_4]]]], Simulation::EVENTS_COMPARE_RANDOMLY);
    }