ChainCacheClearerTest.php 1.1 KB

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