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 function str_replace; |
||||
10 | use Symfony\Component\Cache\Simple\ArrayCache; |
||||
0 ignored issues
–
show
|
|||||
11 | use function sys_get_temp_dir; |
||||
12 | use PHPUnit\Framework\TestCase; |
||||
13 | use function touch; |
||||
14 | |||||
15 | class FileBoundCacheTest extends TestCase |
||||
16 | { |
||||
17 | public function testFileBoundCache(): void |
||||
18 | { |
||||
19 | $cache = new ArrayAdapter(); |
||||
20 | $fileBoundCache = new FileBoundCache($cache, 'prefix'); |
||||
21 | |||||
22 | $tmpPath = sys_get_temp_dir().'/tmpCacheTest'; |
||||
23 | touch($tmpPath); |
||||
24 | |||||
25 | $fileBoundCache->set('foo', 'bar', [ |
||||
26 | $tmpPath |
||||
27 | ]); |
||||
28 | |||||
29 | $this->assertSame('bar', $fileBoundCache->get('foo')); |
||||
30 | |||||
31 | sleep(1); |
||||
32 | clearstatcache($tmpPath); |
||||
0 ignored issues
–
show
$tmpPath of type string is incompatible with the type boolean expected by parameter $clear_realpath_cache of clearstatcache() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
33 | touch($tmpPath); |
||||
34 | |||||
35 | $this->assertNull($fileBoundCache->get('foo')); |
||||
36 | } |
||||
37 | |||||
38 | public function testException(): void |
||||
39 | { |
||||
40 | $cache = new ArrayAdapter(); |
||||
41 | $fileBoundCache = new FileBoundCache($cache, 'prefix'); |
||||
42 | |||||
43 | $this->expectException(FileAccessException::class); |
||||
44 | $fileBoundCache->set('foo', 'bar', [ |
||||
45 | 'notExists' |
||||
46 | ]); |
||||
47 | } |
||||
48 | } |
||||
49 |
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