33namespace Neusta \Pimcore \HttpCacheBundle \Tests \Integration \Invalidation ;
44
55use FOS \HttpCacheBundle \CacheManager ;
6+ use Neusta \Pimcore \HttpCacheBundle \Cache \CacheTag ;
67use Neusta \Pimcore \HttpCacheBundle \Tests \Integration \Helpers \ArrangeCacheTest ;
78use Neusta \Pimcore \HttpCacheBundle \Tests \Integration \Helpers \TestDocumentFactory ;
9+ use Neusta \Pimcore \HttpCacheBundle \Tests \Integration \Helpers \TestObjectFactory ;
810use Neusta \Pimcore \TestingFramework \Database \ResetDatabase ;
911use Neusta \Pimcore \TestingFramework \Test \Attribute \ConfigureExtension ;
1012use Neusta \Pimcore \TestingFramework \Test \ConfigurableKernelTestCase ;
@@ -57,6 +59,30 @@ public function response_is_invalidated_when_document_is_updated(): void
5759 $ this ->cacheManager ->invalidateTags (['d5 ' ])->shouldHaveBeenCalledTimes (1 );
5860 }
5961
62+ /**
63+ * @test
64+ */
65+ #[ConfigureExtension('neusta_pimcore_http_cache ' , [
66+ 'elements ' => [
67+ 'objects ' => true ,
68+ 'documents ' => true ,
69+ ],
70+ ])]
71+ public function dependent_document_is_invalidated_on_object_update (): void
72+ {
73+ $ dependent = self ::arrange (
74+ fn () => TestObjectFactory::simpleObject (12 )->save (),
75+ );
76+ $ document = self ::arrange (
77+ fn () => TestDocumentFactory::simplePage (96 , 'other_test_document_page ' , $ dependent )->save (),
78+ );
79+
80+ $ dependent ->setContent ('Updated test content ' )->save ();
81+
82+ $ this ->cacheManager ->invalidateTags ([CacheTag::fromElement ($ document )->toString ()])
83+ ->shouldHaveBeenCalledTimes (1 );
84+ }
85+
6086 /**
6187 * @test
6288 */
@@ -72,6 +98,30 @@ public function response_is_invalidated_when_document_is_deleted(): void
7298 $ this ->cacheManager ->invalidateTags (['d5 ' ])->shouldHaveBeenCalledTimes (1 );
7399 }
74100
101+ /**
102+ * @test
103+ */
104+ #[ConfigureExtension('neusta_pimcore_http_cache ' , [
105+ 'elements ' => [
106+ 'objects ' => true ,
107+ 'documents ' => true ,
108+ ],
109+ ])]
110+ public function dependent_document_is_invalidated_on_object_deletion (): void
111+ {
112+ $ dependent = self ::arrange (
113+ fn () => TestObjectFactory::simpleObject (12 )->save (),
114+ );
115+ $ document = self ::arrange (
116+ fn () => TestDocumentFactory::simplePage (96 , 'other_test_document_page ' , $ dependent )->save (),
117+ );
118+
119+ $ dependent ->delete ();
120+
121+ $ this ->cacheManager ->invalidateTags ([CacheTag::fromElement ($ document )->toString ()])
122+ ->shouldHaveBeenCalledTimes (1 );
123+ }
124+
75125 /**
76126 * @test
77127 */
0 commit comments