ChainCacheClearerTest.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(), 'sf2_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(array($clearer));
  31. $chainClearer->clear(self::$cacheDir);
  32. }
  33. protected function getMockClearer()
  34. {
  35. return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
  36. }
  37. }