Psr6CacheClearerTest.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Psr6CacheClearer;
  13. use Psr\Cache\CacheItemPoolInterface;
  14. class Psr6CacheClearerTest extends TestCase
  15. {
  16. public function testClearPoolsInjectedInConstructor()
  17. {
  18. $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
  19. $pool
  20. ->expects($this->once())
  21. ->method('clear');
  22. (new Psr6CacheClearer(array('pool' => $pool)))->clear('');
  23. }
  24. public function testClearPool()
  25. {
  26. $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
  27. $pool
  28. ->expects($this->once())
  29. ->method('clear');
  30. (new Psr6CacheClearer(array('pool' => $pool)))->clearPool('pool');
  31. }
  32. /**
  33. * @expectedException \InvalidArgumentException
  34. * @expectedExceptionMessage Cache pool not found: unknown
  35. */
  36. public function testClearPoolThrowsExceptionOnUnreferencedPool()
  37. {
  38. (new Psr6CacheClearer())->clearPool('unknown');
  39. }
  40. }