Kraken\_Module\Channel\ChannelModelTest::testChannelModel_SendsAndReceivesDataCorrectlyThroughUnicast_InPairWithOfflineBuffer PHP Метод

testChannelModel_SendsAndReceivesDataCorrectlyThroughUnicast_InPairWithOfflineBuffer() публичный Метод

    public function testChannelModel_SendsAndReceivesDataCorrectlyThroughUnicast_InPairWithOfflineBuffer($data)
    {
        $this->simulate(function (SimulationInterface $sim) use($data) {
            $loop = $sim->getLoop();
            $sim->delayOnce('pass', 3, function () use($sim) {
                $sim->done();
            });
            $master = $this->createModel($data['master'], $loop);
            $slaver = $this->createModel($data['slave1'], $loop);
            $slaver->on('recv', function ($alias, $message) use($sim) {
                $sim->expect('recv', [$alias, $message]);
                $sim->emit('pass');
            });
            $sim->onStart(function () use($slaver, $master) {
                $master->start();
                $slaver->start();
            });
            $sim->onStop(function () use($slaver, $master) {
                $master->stop();
                $slaver->stop();
            });
            $master->unicast(self::ALIAS_B, self::MSG_1, Channel::MODE_BUFFER_OFFLINE);
            $master->unicast(self::ALIAS_B, self::MSG_2, Channel::MODE_BUFFER_OFFLINE);
            $master->unicast(self::ALIAS_B, [self::MSG_3, self::MSG_4], Channel::MODE_BUFFER_OFFLINE);
        })->expect([['recv', [self::ALIAS_A, [self::MSG_1]]], ['recv', [self::ALIAS_A, [self::MSG_2]]], ['recv', [self::ALIAS_A, [self::MSG_3, self::MSG_4]]]], Simulation::EVENTS_COMPARE_RANDOMLY);
    }