Version 1
[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     public function testInjectClearerUsingAdd()
43     {
44         $clearer = $this->getMockClearer();
45         $clearer
46             ->expects($this->once())
47             ->method('clear');
48
49         $chainClearer = new ChainCacheClearer();
50         $chainClearer->add($clearer);
51         $chainClearer->clear(self::$cacheDir);
52     }
53
54     protected function getMockClearer()
55     {
56         return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();
57     }
58 }