private function assertCacheEntry($iterator, $content, $files, $deleted = false) { $entry = $this->cache->getEntry($this->target->generateCacheKey($iterator)); $this->assertNotNull($entry); $this->assertInstanceOf(CacheBinderEntry::class, $entry); $this->assertEquals($content, $entry->getContent()); $this->assertEquals($files, $entry->getFiles()); $this->assertNotEmpty($entry->getLastModified()); $this->assertNotEmpty($entry->getMimeType()); $this->assertNotEmpty($entry->getContext()); foreach ($files as $file => $time) { $this->assertEquals($deleted, $this->cache->hasDeleted($file)); } }
/** * @test */ public function process_successInternalFileChangedCache() { $file1 = 'example1.file'; $file2 = 'example2.file'; $time = new DateTime(); $newTime = (new DateTime())->setTimestamp($time->getTimestamp() + 42); $entry1 = $this->stubCacheEntry('cached1', $file1, $time); $this->stubFile($file1, 'content', $time); $this->target->process($file1); $entry2 = $this->stubCacheEntry('cached2', $file2, $time, [$file2 => $time, $file1 => $time]); $this->stubFile($file1, 'content', $newTime); $this->stubFile($file2, 'content', $time); $this->assertEquals('cached2', $this->target->process($file2)); $this->assertEquals($entry1->serialize(), $this->cache->getEntry($file1)); $this->assertEquals($entry2->serialize(), $this->cache->getEntry($file2)); }