Skip to content

Commit 8673460

Browse files
Slamdunksebastianbergmann
authored andcommitted
CacheWarmer: call all available methods for caching
1 parent 9871cf4 commit 8673460

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

src/StaticAnalysis/CacheWarmer.php

+8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ public function warmCache(string $cacheDirectory, bool $useAnnotationsForIgnorin
2929
);
3030

3131
foreach ($filter->files() as $file) {
32+
/* @noinspection UnusedFunctionResultInspection */
33+
$coveredFileAnalyser->classesIn($file);
34+
/* @noinspection UnusedFunctionResultInspection */
35+
$coveredFileAnalyser->traitsIn($file);
36+
/* @noinspection UnusedFunctionResultInspection */
37+
$coveredFileAnalyser->functionsIn($file);
3238
/* @noinspection UnusedFunctionResultInspection */
3339
$coveredFileAnalyser->linesOfCodeFor($file);
40+
/* @noinspection UnusedFunctionResultInspection */
41+
$coveredFileAnalyser->ignoredLinesFor($file);
3442

3543
/* @noinspection UnusedFunctionResultInspection */
3644
$uncoveredFileAnalyser->executableLinesIn($file);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of phpunit/php-code-coverage.
4+
*
5+
* (c) Sebastian Bergmann <[email protected]>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace SebastianBergmann\CodeCoverage\StaticAnalysis;
11+
12+
use SebastianBergmann\CodeCoverage\Filter;
13+
use SebastianBergmann\CodeCoverage\TestCase;
14+
15+
/**
16+
* @covers \SebastianBergmann\CodeCoverage\StaticAnalysis\CacheWarmer
17+
*/
18+
final class CacheWarmerTest extends TestCase
19+
{
20+
protected function tearDown(): void
21+
{
22+
parent::tearDown();
23+
24+
$this->removeTemporaryFiles();
25+
}
26+
27+
public function testEveryCachebleMethodIsCalled(): void
28+
{
29+
$filter = new Filter();
30+
$filter->includeFiles([TEST_FILES_PATH . 'BankAccount.php']);
31+
32+
(new CacheWarmer())->warmCache(self::$TEST_TMP_PATH, false, false, $filter);
33+
34+
$expectedWarmedCacheFiles = count(get_class_methods(CoveredFileAnalyser::class)) + count(get_class_methods(UncoveredFileAnalyser::class));
35+
$actualWarmedCacheFiles = count(glob(self::$TEST_TMP_PATH . DIRECTORY_SEPARATOR . '*'));
36+
37+
$this->assertSame($actualWarmedCacheFiles, $expectedWarmedCacheFiles);
38+
}
39+
}

0 commit comments

Comments
 (0)