public function getMicrotime()
{
if (fseek($this->fileHandle, 0) !== 0) {
throw new StorageException("Could not move to beginning of the file.");
}
$data = fread($this->fileHandle, 8);
if ($data === false) {
throw new StorageException("Could not read from storage.");
}
return DoublePacker::unpack($data);
}
/** * Tests readinging too little in getMicrotime(). * * @expectedException bandwidthThrottle\tokenBucket\storage\StorageException */ public function testGetMicrotimeReadsToLittle() { $data = new vfsStreamFile("data"); $data->setContent("1234567"); vfsStream::setup('test')->addChild($data); $storage = new FileStorage(vfsStream::url("test/data")); $storage->getMicrotime(); }