@@ -194,6 +194,84 @@ public function testKnownTagVersionsTtl()
194
194
$ this ->assertTrue ($ pool ->getItem ('foo ' )->isHit ());
195
195
}
196
196
197
+ public function testTagEntryIsCreatedForItemWithoutTags ()
198
+ {
199
+ $ pool = $ this ->createCachePool ();
200
+
201
+ $ itemKey = 'foo ' ;
202
+ $ item = $ pool ->getItem ($ itemKey );
203
+ $ pool ->save ($ item );
204
+
205
+ $ adapter = new FilesystemAdapter ();
206
+ $ this ->assertTrue ($ adapter ->hasItem (TagAwareAdapter::TAGS_PREFIX .$ itemKey ));
207
+ }
208
+
209
+ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemTags ()
210
+ {
211
+ $ pool = $ this ->createCachePool ();
212
+
213
+ $ itemKey = 'foo ' ;
214
+ $ item = $ pool ->getItem ($ itemKey );
215
+ $ pool ->save ($ item );
216
+
217
+ $ anotherPool = $ this ->createCachePool ();
218
+
219
+ $ adapter = new FilesystemAdapter ();
220
+ $ adapter ->deleteItem (TagAwareAdapter::TAGS_PREFIX .$ itemKey ); //simulate item losing tags pair
221
+
222
+ $ this ->assertFalse ($ anotherPool ->hasItem ($ itemKey ));
223
+ }
224
+
225
+ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemTags ()
226
+ {
227
+ $ pool = $ this ->createCachePool ();
228
+
229
+ $ itemKey = 'foo ' ;
230
+ $ item = $ pool ->getItem ($ itemKey );
231
+ $ pool ->save ($ item );
232
+
233
+ $ anotherPool = $ this ->createCachePool ();
234
+
235
+ $ adapter = new FilesystemAdapter ();
236
+ $ adapter ->deleteItem (TagAwareAdapter::TAGS_PREFIX .$ itemKey ); //simulate item losing tags pair
237
+
238
+ $ item = $ anotherPool ->getItem ($ itemKey );
239
+ $ this ->assertFalse ($ item ->isHit ());
240
+ }
241
+
242
+ public function testHasItemReturnsFalseWhenPoolDoesNotHaveItemAndOnlyHasTags ()
243
+ {
244
+ $ pool = $ this ->createCachePool ();
245
+
246
+ $ itemKey = 'foo ' ;
247
+ $ item = $ pool ->getItem ($ itemKey );
248
+ $ pool ->save ($ item );
249
+
250
+ $ anotherPool = $ this ->createCachePool ();
251
+
252
+ $ adapter = new FilesystemAdapter ();
253
+ $ adapter ->deleteItem ($ itemKey ); //simulate losing item but keeping tags
254
+
255
+ $ this ->assertFalse ($ anotherPool ->hasItem ($ itemKey ));
256
+ }
257
+
258
+ public function testGetItemReturnsCacheMissWhenPoolDoesNotHaveItemAndOnlyHasTags ()
259
+ {
260
+ $ pool = $ this ->createCachePool ();
261
+
262
+ $ itemKey = 'foo ' ;
263
+ $ item = $ pool ->getItem ($ itemKey );
264
+ $ pool ->save ($ item );
265
+
266
+ $ anotherPool = $ this ->createCachePool ();
267
+
268
+ $ adapter = new FilesystemAdapter ();
269
+ $ adapter ->deleteItem ($ itemKey ); //simulate losing item but keeping tags
270
+
271
+ $ item = $ anotherPool ->getItem ($ itemKey );
272
+ $ this ->assertFalse ($ item ->isHit ());
273
+ }
274
+
197
275
/**
198
276
* @return MockObject|PruneableCacheInterface
199
277
*/
0 commit comments