Skip to content

Commit fadafdc

Browse files
committed
add testcase
1 parent 2eaa19f commit fadafdc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\HttpKernel\CacheWarmer;
1313

14+
use Symfony\Component\HttpKernel\Tests\CacheWarmer\CacheWarmerAggregateTest;
15+
1416
/**
1517
* Aggregates several cache warmers into a single one.
1618
*
@@ -50,7 +52,7 @@ public function enableOnlyOptionalWarmers()
5052
*/
5153
public function warmUp($cacheDir)
5254
{
53-
if ($collectDeprecations = $this->debug && !\defined('PHPUNIT_COMPOSER_INSTALL')) {
55+
if ($collectDeprecations = $this->debug && (!\defined('PHPUNIT_COMPOSER_INSTALL') || file_exists(CacheWarmerAggregateTest::$emptyFile))) {
5456
$collectedLogs = [];
5557
$previousHandler = set_error_handler(function ($type, $message, $file, $line) use (&$collectedLogs, &$previousHandler) {
5658
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) {

src/Symfony/Component/HttpKernel/Tests/CacheWarmer/CacheWarmerAggregateTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717

1818
class CacheWarmerAggregateTest extends TestCase
1919
{
20+
public static $emptyFile;
2021
protected static $cacheDir;
2122

2223
public static function setUpBeforeClass(): void
2324
{
2425
self::$cacheDir = tempnam(sys_get_temp_dir(), 'sf_cache_warmer_dir');
26+
self::$emptyFile = tempnam(sys_get_temp_dir(), 'empty_file');
2527
}
2628

2729
public static function tearDownAfterClass(): void
@@ -68,4 +70,12 @@ public function testWarmupDoesNotCallWarmupOnOptionalWarmersWhenEnableOptionalWa
6870
$aggregate = new CacheWarmerAggregate([$warmer]);
6971
$aggregate->warmUp(self::$cacheDir);
7072
}
73+
74+
public function testWarmupEmptyFile()
75+
{
76+
file_put_contents(self::$emptyFile, null);
77+
self::assertFalse(unserialize(file_get_contents(self::$emptyFile)));
78+
$aggregate = new CacheWarmerAggregate([], true, self::$emptyFile);
79+
$aggregate->warmUp(self::$cacheDir);
80+
}
7181
}

0 commit comments

Comments
 (0)