3e20efbf1f2c54b93bd818165d02cef9ef11fc98
[yaffs-website] / vendor / symfony / http-kernel / Tests / CacheClearer / Psr6CacheClearerTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\HttpKernel\Tests\CacheClearer;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpKernel\CacheClearer\Psr6CacheClearer;
16 use Psr\Cache\CacheItemPoolInterface;
17
18 class Psr6CacheClearerTest extends TestCase
19 {
20     public function testClearPoolsInjectedInConstructor()
21     {
22         $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
23         $pool
24             ->expects($this->once())
25             ->method('clear');
26
27         (new Psr6CacheClearer(array('pool' => $pool)))->clear('');
28     }
29
30     public function testClearPool()
31     {
32         $pool = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
33         $pool
34             ->expects($this->once())
35             ->method('clear');
36
37         (new Psr6CacheClearer(array('pool' => $pool)))->clearPool('pool');
38     }
39
40     /**
41      * @expectedException        \InvalidArgumentException
42      * @expectedExceptionMessage Cache pool not found: unknown
43      */
44     public function testClearPoolThrowsExceptionOnUnreferencedPool()
45     {
46         (new Psr6CacheClearer())->clearPool('unknown');
47     }
48
49     /**
50      * @group legacy
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.
52      */
53     public function testClearPoolsInjectedByAdder()
54     {
55         $pool1 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
56         $pool1
57             ->expects($this->once())
58             ->method('clear');
59
60         $pool2 = $this->getMockBuilder(CacheItemPoolInterface::class)->getMock();
61         $pool2
62             ->expects($this->once())
63             ->method('clear');
64
65         $clearer = new Psr6CacheClearer(array('pool1' => $pool1));
66         $clearer->addPool($pool2);
67         $clearer->clear('');
68     }
69 }