1 | <?php |
||
2 | |||
3 | namespace TheCodingMachine\CacheUtils; |
||
4 | |||
5 | use Symfony\Component\Cache\Adapter\ArrayAdapter; |
||
6 | use function clearstatcache; |
||
7 | use PHPUnit\Framework\TestCase; |
||
8 | use ReflectionClass; |
||
9 | use function sleep; |
||
10 | use Symfony\Component\Cache\Simple\ArrayCache; |
||
0 ignored issues
–
show
|
|||
11 | use TheCodingMachine\CacheUtils\Fixtures\A; |
||
12 | use function touch; |
||
13 | |||
14 | class ClassBoundCacheContractTest extends TestCase |
||
15 | { |
||
16 | public function testClassBoundCacheContract(): void |
||
17 | { |
||
18 | $cache = new ArrayAdapter(); |
||
19 | $fileBoundCache = new FileBoundCache($cache, 'prefix'); |
||
20 | $classBoundCache = new ClassBoundCache($fileBoundCache, true, true, true); |
||
21 | $classBoundCacheContract = new ClassBoundCacheContract($classBoundCache); |
||
22 | |||
23 | $val = 0; |
||
24 | |||
25 | $newVal = $classBoundCacheContract->get(new ReflectionClass(A::class), function() use (&$val) { |
||
26 | return ++$val; |
||
27 | }); |
||
28 | |||
29 | $this->assertSame(1, $newVal); |
||
30 | |||
31 | $newVal2 = $classBoundCacheContract->get(new ReflectionClass(A::class), function() use (&$val) { |
||
32 | return ++$val; |
||
33 | }); |
||
34 | |||
35 | $this->assertSame(1, $newVal2); |
||
36 | |||
37 | $classToTouch = new ReflectionClass(A::class); |
||
38 | sleep(1); |
||
39 | clearstatcache($classToTouch->getFileName()); |
||
40 | touch($classToTouch->getFileName()); |
||
41 | |||
42 | $newVal3 = $classBoundCacheContract->get(new ReflectionClass(A::class), function() use (&$val) { |
||
43 | return ++$val; |
||
44 | }); |
||
45 | |||
46 | $this->assertSame(2, $newVal3); |
||
47 | } |
||
48 | |||
49 | } |
||
50 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths