Skip to content

Commit 1bf183a

Browse files
authored
Merge pull request #171 from antecedent/feature/getcachedpath-fix-test
getCachedPath(): improve test
2 parents b6d29d6 + 195de29 commit 1bf183a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/get-cached-path.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,27 @@ echo "\n";
3434
$actualPath = \Patchwork\CodeManipulation\getCachedPath($file);
3535

3636
echo $actualPath === $expectedPath ? 'PASS' : 'FAIL';
37+
echo "\n";
38+
39+
// Third pass - index.csv file exists, different file being passed.
40+
// This test would hit a PHP 8.4 deprecation without the fix from PR #170.
41+
42+
// Reset the state to ensure we hit the code which would cause the deprecation
43+
// notice without the fix from #170.
44+
Patchwork\CodeManipulation\State::$cacheIndexFile = null;
45+
Patchwork\Config\State::$cachePath = $cachePath;
46+
47+
$file = 'another-file.php';
48+
$hash = md5($file);
49+
50+
$expectedPath = $cachePath . '/' . $hash . '.php';
51+
52+
$actualPath = \Patchwork\CodeManipulation\getCachedPath($file);
53+
54+
echo $actualPath === $expectedPath ? 'PASS' : 'FAIL';
55+
echo "\n";
3756
?>
57+
===DONE===
3858

3959
--CLEAN--
4060
<?php
@@ -46,3 +66,5 @@ rmdir(__DIR__ . '/cache');
4666
--EXPECT--
4767
PASS
4868
PASS
69+
PASS
70+
===DONE===

0 commit comments

Comments
 (0)