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\CacheWarmer;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer;
17 class CacheWarmerTest extends TestCase
19 protected static $cacheFile;
21 public static function setUpBeforeClass()
23 self::$cacheFile = tempnam(sys_get_temp_dir(), 'sf2_cache_warmer_dir');
26 public static function tearDownAfterClass()
28 @unlink(self::$cacheFile);
31 public function testWriteCacheFileCreatesTheFile()
33 $warmer = new TestCacheWarmer(self::$cacheFile);
34 $warmer->warmUp(dirname(self::$cacheFile));
36 $this->assertFileExists(self::$cacheFile);
40 * @expectedException \RuntimeException
42 public function testWriteNonWritableCacheFileThrowsARuntimeException()
44 $nonWritableFile = '/this/file/is/very/probably/not/writable';
45 $warmer = new TestCacheWarmer($nonWritableFile);
46 $warmer->warmUp(dirname($nonWritableFile));
50 class TestCacheWarmer extends CacheWarmer
54 public function __construct($file)
59 public function warmUp($cacheDir)
61 $this->writeCacheFile($this->file, 'content');
64 public function isOptional()