CacheTest.php 847 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace Gaufrette\Functional\Adapter;
  3. use Gaufrette\Filesystem;
  4. use Gaufrette\Adapter\Cache;
  5. use Gaufrette\Adapter\InMemory;
  6. class CacheTest extends FunctionalTestCase
  7. {
  8. public function setUp()
  9. {
  10. $this->filesystem = new Filesystem(new Cache(new InMemory(), new InMemory()));
  11. }
  12. /**
  13. * @test
  14. */
  15. public function shouldNeedReloadAfterSourceChanged()
  16. {
  17. $source = new InMemory();
  18. $cache = new InMemory();
  19. $cachedFs = new Cache($source, $cache);
  20. // The source has been updated after the cache has been created.
  21. $mtime = time();
  22. $source->setFile('foo', 'baz', $mtime - 10);
  23. $cache->setFile('foo', 'bar', $mtime - 20);
  24. $this->assertTrue($cachedFs->needsReload('foo'));
  25. $this->assertEquals('baz', $cachedFs->read('foo'));
  26. }
  27. }