ChainCacheClearerTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\HttpKernel\CacheClearer\ChainCacheClearer;
  13. class ChainCacheClearerTest extends TestCase
  14. {
  15. protected static $cacheDir;
  16. public static function setUpBeforeClass()
  17. {
  18. self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf_cache_clearer_dir');
  19. }
  20. public static function tearDownAfterClass()
  21. {
  22. @unlink(self::$cacheDir);
  23. }
  24. public function testInjectClearersInConstructor()
  25. {
  26. $clearer = $this->getMockClearer();
  27. $clearer
  28. ->expects($this->once())
  29. ->method('clear');
  30. $chainClearer = new ChainCacheClearer([$clearer]);
  31. $chainClearer->clear(self::$cacheDir);
  32. }
  33. protected function getMockClearer()
  34. {
  35. return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
  36. }
  37. }