Няма описание

ChainCacheClearerTest.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  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 Symfony\Component\HttpKernel\Tests\CacheClearer;
  11. use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer;
  12. class ChainCacheClearerTest extends \PHPUnit_Framework_TestCase
  13. {
  14. protected static $cacheDir;
  15. public static function setUpBeforeClass()
  16. {
  17. self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir');
  18. }
  19. public static function tearDownAfterClass()
  20. {
  21. @unlink(self::$cacheDir);
  22. }
  23. public function testInjectClearersInConstructor()
  24. {
  25. $clearer = $this->getMockClearer();
  26. $clearer
  27. ->expects($this->once())
  28. ->method('clear');
  29. $chainClearer = new ChainCacheClearer(array($clearer));
  30. $chainClearer->clear(self::$cacheDir);
  31. }
  32. public function testInjectClearerUsingAdd()
  33. {
  34. $clearer = $this->getMockClearer();
  35. $clearer
  36. ->expects($this->once())
  37. ->method('clear');
  38. $chainClearer = new ChainCacheClearer();
  39. $chainClearer->add($clearer);
  40. $chainClearer->clear(self::$cacheDir);
  41. }
  42. protected function getMockClearer()
  43. {
  44. return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
  45. }
  46. }