4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\Tests\CacheClearer;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
16 use Psr\Cache\CacheItemPoolInterface;
18 class Psr6CacheClearerTest extends TestCase
20 public function testClearPoolsInjectedInConstructor()
22 $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
24 ->expects($this->once())
27 (new Psr6CacheClearer(array('pool' => $pool)))->clear('');
30 public function testClearPool()
32 $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
34 ->expects($this->once())
37 (new Psr6CacheClearer(array('pool' => $pool)))->clearPool('pool');
41 * @expectedException \InvalidArgumentException
42 * @expectedExceptionMessage Cache pool not found: unknown
44 public function testClearPoolThrowsExceptionOnUnreferencedPool()
46 (new Psr6CacheClearer())->clearPool('unknown');
51 * @expectedDeprecation The Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer::addPool() method is deprecated since Symfony 3.3 and will be removed in 4.0. Pass an array of pools indexed by name to the constructor instead.
53 public function testClearPoolsInjectedByAdder()
55 $pool1 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
57 ->expects($this->once())
60 $pool2 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
62 ->expects($this->once())
65 $clearer = new Psr6CacheClearer(array('pool1' => $pool1));
66 $clearer->addPool($pool2);