/** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testPubSubWithClientUsedInSubClosure() { $process = CM_Process::getInstance(); $process->fork(function () { $redisClient = CM_Service_Manager::getInstance()->getRedis(); $clientCount = 0; while ($clientCount == 0) { $clientCount = $redisClient->publish('foo', 'test'); usleep(50 * 1000); } }); $this->_client->set('check', 'bar'); $response = $this->_client->subscribe('foo', function ($channel, $message) { if ($message == 'test') { return [$channel, $message, $this->_client->get('check')]; } else { return false; } }); $this->assertSame(['foo', 'test', 'bar'], $response); $process->waitForChildren(); }