test: harden clear() namespace isolation, tag invalidation and deleteItem() return value - #124
Conversation
Add an optional createCachePoolWithOtherNamespace() extension point and a test that saves the same key in two pools sharing the same storage under different namespaces. The test is skipped when the implementation returns null.
The test used overlapping tags, so an implementation that only invalidates the first tag of the list still passed. Use disjoint tags plus a control item tagged with none of the invalidated tags.
The return value was ignored, so an implementation returning false while the deletion actually happened still passed.
9f64b72 to
e61cecb
Compare
|
Nice find on all three. Few things before I merge.
Small one: On |
Three small additions to the contract, found while implementing a PSR-6 adapter for MongoDB (symfony/symfony#65468). In each case the current tests pass on an implementation that is actually wrong.
clear() must not touch another namespace on the same storage
When several pools share a single storage, a table or a collection for instance, clearing one pool must only remove its own keys. Nothing checks that today, because the tests only ever use one pool.
CachePoolTestgains an optionalcreateCachePoolWithOtherNamespace(), which returns a second pool on the same storage under another namespace. It returns null by default, and the newtestClearDoesNotAffectOtherNamespacesis then skipped, so existing implementations are unaffected. When a pool is given, the test writes the same key in both, clears the first one, and checks that the second still holds its own value.testInvalidateTags now uses disjoint tags
keywas tagged with tag1 and tag2 whilekey2was tagged with tag1, so invalidating tag1 alone was enough to pass. Each item now carries a single distinct tag, and a third item, tagged with none of the invalidated tags, checks that the invalidation does not reach too far.deleteItem() return value on a tagged item
testRemoveTagWhenItemIsRemovedignored whatdeleteItem()returned. It is now asserted to be true.