public function testOnMessageReceived() { $this->provider->create(); $id = $this->provider->publish(['foo' => 'bar']); $path = substr(hash('md5', $id), 0, 3); $this->assertTrue(is_file($this->path . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json')); $this->provider->onMessageReceived(new MessageEvent('test', $this->provider->receive()[0])); $this->assertFalse(is_file($this->path . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $id . '.json')); }
public function testCleanUp() { $this->provider->create(); $provider = $this->getFileProvider(['message_expiration' => 1]); $provider->publish(['testing']); $provider->publish(['testing 123']); sleep(1); $provider->cleanUp(); $messages = $provider->receive(); $this->assertEmpty($messages); }
/** * @see https://github.com/uecode/qpush-bundle/issues/93 */ public function testCleanUpDoesNotRemoveCurrentMessages() { $this->provider->create(); $provider = $this->getFileProvider(['message_expiration' => 10]); $currentMessage = ['dont remove me']; $id = $provider->publish(['testing']); $this->mockMessageAge($id, 3600); $id = $provider->publish(['testing 123']); $this->mockMessageAge($id, 3600); $provider->publish($currentMessage); $provider->cleanUp(); $messages = $provider->receive(); $this->assertCount(1, $messages); $this->assertSame($currentMessage, $messages[0]->getBody()); }