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);
42 public function testInjectClearerUsingAdd()
44 $clearer = $this->getMockClearer();
46 ->expects($this->once())
49 $chainClearer = new ChainCacheClearer();
50 $chainClearer->add($clearer);
51 $chainClearer->clear(self::$cacheDir);
54 protected function getMockClearer()
56 return $this->getMockBuilder('Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface')->getMock();