3838#[CoversClass(DataHandler::class)]
3939class FlushViaDataHandlerChangesTest extends FunctionalTestCase
4040{
41+ protected array $ testExtensionsToLoad = [
42+ 'typo3conf/ext/variables ' ,
43+ ];
44+
45+ protected function setUp (): void
46+ {
47+ parent ::setUp ();
48+
49+ $ this ->importCSVDataSet (__DIR__ . '/../Fixtures/Frontend/Content.csv ' );
50+ }
51+
4152 /**
4253 * @param array<mixed> $params
4354 */
4455 #[DataProvider('possibleNoneTriggeringParams ' )]
4556 #[Test]
4657 public function doesNotInteractWithCacheManagerOnUnkownData (array $ params ): void
4758 {
48- $ connectionPool = self :: createMock (ConnectionPool::class);
59+ $ connectionPool = $ this -> get (ConnectionPool::class);
4960 $ cacheManager = self ::createMock (CacheManager::class);
5061 $ cacheManager
5162 ->expects (self ::never ())
@@ -81,7 +92,7 @@ public static function possibleNoneTriggeringParams(): \Generator
8192 #[Test]
8293 public function flushCachesByGroupForMarker (): void
8394 {
84- $ connectionPool = self :: createMock (ConnectionPool::class);
95+ $ connectionPool = $ this -> get (ConnectionPool::class);
8596 $ cacheManager = self ::createMock (CacheManager::class);
8697 $ cacheManager
8798 ->expects (self ::once ())
@@ -105,4 +116,83 @@ public function flushCachesByGroupForMarker(): void
105116 'marker ' => 'TEST '
106117 ], $ dataHandler );
107118 }
119+
120+ #[Test]
121+ public function flushCachesByGroupForHiddenMarker (): void
122+ {
123+ $ connectionPool = $ this ->get (ConnectionPool::class);
124+ $ connectionPool ->getConnectionForTable ('tx_variables_marker ' )
125+ ->insert ('tx_variables_marker ' ,[
126+ 'uid ' => '100 ' ,
127+ 'hidden ' => '1 ' ,
128+ 'marker ' => 'hidden_marker ' ,
129+ 'replacement ' => 'replacement ' ,
130+ ]);
131+
132+ $ cacheManager = self ::createMock (CacheManager::class);
133+ $ cacheManager
134+ ->expects (self ::once ())
135+ ->method ('flushCachesInGroupByTag ' )
136+ ->with ('pages ' , $ this ->stringStartsWith ('tx_variables_key_hash_ ' ))
137+ ;
138+
139+ $ dataHandler = self ::createStub (Typo3DataHandler::class);
140+
141+ $ subject = new DataHandler ($ connectionPool , $ cacheManager );
142+ $ subject ->clearCachePostProc ([
143+ 'table ' => 'tx_variables_marker ' ,
144+ 'uid ' => '100 ' ,
145+ 'marker ' => 'TEST '
146+ ], $ dataHandler );
147+ }
148+
149+ #[Test]
150+ public function flushCachesByGroupForDeletedMarker (): void
151+ {
152+ $ connectionPool = $ this ->get (ConnectionPool::class);
153+ $ connectionPool ->getConnectionForTable ('tx_variables_marker ' )
154+ ->insert ('tx_variables_marker ' ,[
155+ 'uid ' => '100 ' ,
156+ 'deleted ' => '1 ' ,
157+ 'marker ' => 'hidden_marker ' ,
158+ 'replacement ' => 'replacement ' ,
159+ ]);
160+
161+ $ cacheManager = self ::createMock (CacheManager::class);
162+ $ cacheManager
163+ ->expects (self ::once ())
164+ ->method ('flushCachesInGroupByTag ' )
165+ ->with ('pages ' , $ this ->stringStartsWith ('tx_variables_key_hash_ ' ))
166+ ;
167+
168+ $ dataHandler = self ::createStub (Typo3DataHandler::class);
169+
170+ $ subject = new DataHandler ($ connectionPool , $ cacheManager );
171+ $ subject ->clearCachePostProc ([
172+ 'table ' => 'tx_variables_marker ' ,
173+ 'uid ' => '100 ' ,
174+ 'marker ' => 'TEST '
175+ ], $ dataHandler );
176+ }
177+
178+ #[Test]
179+ public function doesNotFlushCachesByGroupForUnkownMarker (): void
180+ {
181+ $ connectionPool = $ this ->get (ConnectionPool::class);
182+
183+ $ cacheManager = self ::createMock (CacheManager::class);
184+ $ cacheManager
185+ ->expects (self ::never ())
186+ ->method ('flushCachesInGroupByTag ' )
187+ ;
188+
189+ $ dataHandler = self ::createStub (Typo3DataHandler::class);
190+
191+ $ subject = new DataHandler ($ connectionPool , $ cacheManager );
192+ $ subject ->clearCachePostProc ([
193+ 'table ' => 'tx_variables_marker ' ,
194+ 'uid ' => '100 ' ,
195+ 'marker ' => 'TEST '
196+ ], $ dataHandler );
197+ }
108198}
0 commit comments