FilesystemCacheTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Assetic package, an OpenSky project.
  4. *
  5. * (c) 2010-2011 OpenSky Project Inc
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Assetic\Test\Cache;
  11. use Assetic\Cache\FilesystemCache;
  12. class FilesystemCacheTest extends \PHPUnit_Framework_TestCase
  13. {
  14. public function testCache()
  15. {
  16. $cache = new FilesystemCache(sys_get_temp_dir());
  17. $this->assertFalse($cache->has('foo'));
  18. $cache->set('foo', 'bar');
  19. $this->assertEquals('bar', $cache->get('foo'));
  20. $this->assertTrue($cache->has('foo'));
  21. $cache->remove('foo');
  22. $this->assertFalse($cache->has('foo'));
  23. }
  24. public function testSetCreatesDir()
  25. {
  26. $dir = sys_get_temp_dir().'/assetic/fscachetest';
  27. $tearDown = function() use($dir)
  28. {
  29. array_map('unlink', glob($dir.'/*'));
  30. @rmdir($dir);
  31. };
  32. $tearDown();
  33. $cache = new FilesystemCache($dir);
  34. $cache->set('foo', 'bar');
  35. $this->assertFileExists($dir.'/foo');
  36. $tearDown();
  37. }
  38. }