public function delete($id)
{
$success = false;
if (isset($this->filePointerList[$id])) {
$fileName = $id;
$path = substr(hash('md5', (string) $fileName), 0, 3);
$fs = new Filesystem();
$fs->remove($this->queuePath . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $fileName . '.json');
fclose($this->filePointerList[$id]);
unset($this->filePointerList[$id]);
$success = true;
}
if (rand(1, 10) === 5) {
$this->cleanUp();
}
return $success;
}
public function testDelete() { $this->provider->create(); $path = substr(hash('md5', '123'), 0, 3); mkdir($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path); touch($this->basePath . DIRECTORY_SEPARATOR . $this->queueHash . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . '123.json'); $messages = $this->provider->receive(); $this->assertNotEmpty($messages); $this->assertTrue($this->provider->delete(123)); }