Util/Cache: add unit tests - #1480
Conversation
|
Thanks for taking a look when you get to this — and for the earlier note on #1479 about covering On CI: the two red checks don’t look related to the new Cache tests. Happy to dig further or adjust anything on the Cache tests if you’d like. |
No need to worry about those unrelated CI failures. The markdown failure should be fixed via #1483. And PHP 8.6 builds are not required to pass yet. For now, I've isolated the issue with the Generator code on PHP 8.6/Windows and have reported the problem to PHP Core: php/php-src#23326. If this is a deliberate change for PHP 8.6, I will fix the PHPCS code to handle the new format, but for now, we should wait to hear back from PHP Core whether this is a bug or a feature. |
Based on the discussion in the PHP Core issue, this is an intentional change coming from a more recent |
Description
Util\Cachecurrently has no test coverage. This PR adds a unit test suite for it, pinning down the currentbehaviour before anyone changes it.
Two test classes under
tests/Core/Util/Cache/:GetSetGetSizeTest—get,set, andgetSizeLoadSaveTest—load/save, including an explicit--cache=file, entries being cleared when thestamped config no longer matches, and the auto-chosen cache path (
XDG_CACHE_HOME, system temp fallback,shared ancestor of the scanned files, empty file list)
They follow the existing Core Util patterns: separate processes for the static store,
ConfigDouble, temp filesremoved in
tearDown(),XDG_CACHE_HOMErestored afterwards. Assertions are on observable behaviour and onwhere the cache file ends up, not on the internal hash values, so these shouldn't get in the way if the hash
composition changes later.
I ran into the gap while reading the cache code for #1479. This stands on its own regardless of what happens
with that proposal — the coverage seemed worth having either way, including for any changes you'd want to make
to
Cacheyourselves. Happy to adjust the file split, naming or scope if it doesn't match how you'd like Utiltests laid out.
Suggested changelog entry
n/a
Related issues/external references
#1479 — where the missing coverage came up.
Types of changes
PR checklist