/vendor/kriswallsmith/assetic/tests/Assetic/Test/Cache/FilesystemCacheTest.php

https://bitbucket.org/arturoblack/tomoyo · PHP · 51 lines · 29 code · 14 blank · 8 comment · 0 complexity · fc399c3521b4b6454df32ac2ca50fa0a MD5 · raw file

  1. <?php
  2. /*
  3. * This file is part of the Assetic package, an OpenSky project.
  4. *
  5. * (c) 2010-2013 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. array_map('unlink', glob($dir.'/*'));
  29. @rmdir($dir);
  30. };
  31. $tearDown();
  32. $cache = new FilesystemCache($dir);
  33. $cache->set('foo', 'bar');
  34. $this->assertFileExists($dir.'/foo');
  35. $tearDown();
  36. }
  37. }