1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TheCodingMachine\CacheUtils; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Cache\Adapter\ArrayAdapter; |
6
|
|
|
use function clearstatcache; |
7
|
|
|
use function file_get_contents; |
8
|
|
|
use function file_put_contents; |
9
|
|
|
use ReflectionClass; |
10
|
|
|
use function sleep; |
11
|
|
|
use function str_replace; |
12
|
|
|
use Symfony\Component\Cache\Simple\ArrayCache; |
|
|
|
|
13
|
|
|
use function sys_get_temp_dir; |
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use TheCodingMachine\CacheUtils\Fixtures\A; |
16
|
|
|
use function touch; |
17
|
|
|
|
18
|
|
|
class ClassBoundMemoryAdapterTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
public function testMemory(): void |
21
|
|
|
{ |
22
|
|
|
$cache = new ArrayAdapter(); |
23
|
|
|
$fileBoundCache = new FileBoundCache($cache, 'prefix'); |
24
|
|
|
$classBoundCache = new ClassBoundCache($fileBoundCache); |
25
|
|
|
$adapter = new ClassBoundMemoryAdapter($classBoundCache); |
26
|
|
|
|
27
|
|
|
$classToTouch = new ReflectionClass(A::class); |
28
|
|
|
sleep(1); |
29
|
|
|
clearstatcache($classToTouch->getFileName()); |
|
|
|
|
30
|
|
|
touch($classToTouch->getFileName()); |
31
|
|
|
|
32
|
|
|
$adapter->set('foo', 'bar', $classToTouch); |
33
|
|
|
|
34
|
|
|
$this->assertSame('bar', $adapter->get('foo')); |
35
|
|
|
|
36
|
|
|
$adapter2 = new ClassBoundMemoryAdapter($classBoundCache); |
37
|
|
|
$this->assertSame('bar', $adapter2->get('foo')); |
38
|
|
|
|
39
|
|
|
sleep(1); |
40
|
|
|
clearstatcache($classToTouch->getFileName()); |
41
|
|
|
touch($classToTouch->getFileName()); |
42
|
|
|
|
43
|
|
|
$this->assertSame('bar', $adapter->get('foo')); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
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