Skip to content

Commit

Permalink
Merge pull request #171 from antecedent/feature/getcachedpath-fix-test
Browse files Browse the repository at this point in the history
getCachedPath(): improve test
  • Loading branch information
antecedent authored Dec 11, 2024
2 parents b6d29d6 + 195de29 commit 1bf183a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/get-cached-path.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,27 @@ echo "\n";
$actualPath = \Patchwork\CodeManipulation\getCachedPath($file);

echo $actualPath === $expectedPath ? 'PASS' : 'FAIL';
echo "\n";

// Third pass - index.csv file exists, different file being passed.
// This test would hit a PHP 8.4 deprecation without the fix from PR #170.

// Reset the state to ensure we hit the code which would cause the deprecation
// notice without the fix from #170.
Patchwork\CodeManipulation\State::$cacheIndexFile = null;
Patchwork\Config\State::$cachePath = $cachePath;

$file = 'another-file.php';
$hash = md5($file);

$expectedPath = $cachePath . '/' . $hash . '.php';

$actualPath = \Patchwork\CodeManipulation\getCachedPath($file);

echo $actualPath === $expectedPath ? 'PASS' : 'FAIL';
echo "\n";
?>
===DONE===

--CLEAN--
<?php
Expand All @@ -46,3 +66,5 @@ rmdir(__DIR__ . '/cache');
--EXPECT--
PASS
PASS
PASS
===DONE===

0 comments on commit 1bf183a

Please sign in to comment.