public function publish(array $message, array $options = [])
{
$fileName = microtime(false);
$fileName = str_replace(' ', '', $fileName);
$path = substr(hash('md5', $fileName), 0, 3);
$fs = new Filesystem();
if (!$fs->exists($this->queuePath . DIRECTORY_SEPARATOR . $path)) {
$fs->mkdir($this->queuePath . DIRECTORY_SEPARATOR . $path);
}
$fs->dumpFile($this->queuePath . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $fileName . '.json', json_encode($message));
return $fileName;
}
public function testOnMessageReceived() { $this->provider->create(); $id = $this->provider->publish(['foo' => 'bar']); $path = substr(hash('md5', $id), 0, 3); $this->assertTrue(is_file($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json')); $this->provider->onMessageReceived(new MessageEvent('test', $this->provider->receive()[0])); $this->assertFalse(is_file($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json')); }