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\ChainCacheClearer;
17 class ChainCacheClearerTest extends TestCase
19 protected static $cacheDir;
21 public static function setUpBeforeClass()
23 self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf2_cache_clearer_dir');
26 public static function tearDownAfterClass()
28 @unlink(self::$cacheDir);
31 public function testInjectClearersInConstructor()
33 $clearer = $this->getMockClearer();
35 ->expects($this->once())
38 $chainClearer = new ChainCacheClearer(array($clearer));
39 $chainClearer->clear(self::$cacheDir);
45 public function testInjectClearerUsingAdd()
47 $clearer = $this->getMockClearer();
49 ->expects($this->once())
52 $chainClearer = new ChainCacheClearer();
53 $chainClearer->add($clearer);
54 $chainClearer->clear(self::$cacheDir);
57 protected function getMockClearer()
59 return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();