Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / symfony / http-kernel / Tests / CacheClearer / ChainCacheClearerTest.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\ChainCacheClearer;
16
17 class ChainCacheClearerTest extends TestCase
18 {
19     protected static $cacheDir;
20
21     public static function setUpBeforeClass()
22     {
23         self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir');
24     }
25
26     public static function tearDownAfterClass()
27     {
28         @unlink(self::$cacheDir);
29     }
30
31     public function testInjectClearersInConstructor()
32     {
33         $clearer = $this->getMockClearer();
34         $clearer
35             ->expects($this->once())
36             ->method('clear');
37
38         $chainClearer = new ChainCacheClearer(array($clearer));
39         $chainClearer->clear(self::$cacheDir);
40     }
41
42     /**
43      * @group legacy
44      */
45     public function testInjectClearerUsingAdd()
46     {
47         $clearer = $this->getMockClearer();
48         $clearer
49             ->expects($this->once())
50             ->method('clear');
51
52         $chainClearer = new ChainCacheClearer();
53         $chainClearer->add($clearer);
54         $chainClearer->clear(self::$cacheDir);
55     }
56
57     protected function getMockClearer()
58     {
59         return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
60     }
61 }