FunctionalTest::testPubSub PHP Method

testPubSub() public method

public testPubSub ( )
    public function testPubSub()
    {
        $consumer = $this->client;
        $producer = $this->createClient();
        $channel = 'channel:test:' . mt_rand();
        // consumer receives a single message
        $deferred = new Deferred();
        $consumer->on('message', $this->expectCallableOnce());
        $consumer->on('message', array($deferred, 'resolve'));
        $consumer->subscribe($channel)->then($this->expectCallableOnce());
        $this->waitFor($consumer);
        // producer sends a single message
        $producer->publish($channel, 'hello world')->then($this->expectCallableOnce());
        $this->waitFor($producer);
        // expect "message" event to take no longer than 0.1s
        Block\await($deferred->promise(), $this->loop, 0.1);
    }