rPath = CACHE_TMP_PATH . 'bouquet_map'; if (is_file($this->rPath)) { $this->rSaved = file_get_contents($this->rPath); } } protected function tearDown(): void { if ($this->rSaved !== null) { file_put_contents($this->rPath, $this->rSaved); } else { @unlink($this->rPath); } } private function writeMap(array $rMap, int $rMtime): void { file_put_contents($this->rPath, igbinary_serialize($rMap)); touch($this->rPath, $rMtime); } public function testReturnsTheBouquetsHoldingAStream(): void { $this->writeMap([5 => [1, 2]], time() - 100); $this->assertSame([1, 2], BouquetService::getMapEntry(5)); $this->assertSame([], BouquetService::getMapEntry(9)); } public function testSeesARebuiltMap(): void { $this->writeMap([5 => [1]], time() - 50); $this->assertSame([1], BouquetService::getMapEntry(5)); // The cache pass rewrites the file: the memo must not keep the old answer. $this->writeMap([5 => [3]], time() - 10); $this->assertSame([3], BouquetService::getMapEntry(5)); } }