@@ -131,49 +131,18 @@ public function testPersistsAndRecallsPaths(): void
131
131
132
132
public function testGetCacheKey (): void
133
133
{
134
- $ loader = $ this ->getContaoFilesystemLoader ();
134
+ $ loader = $ this ->getContaoFilesystemLoader (null , new TemplateLocator ( ' / ' , [], []) );
135
135
136
136
$ path = Path::canonicalize (__DIR__ .'/../../Fixtures/Twig/paths/1 ' );
137
137
138
- $ loader ->addPath ($ path );
138
+ $ loader ->addPath ($ path, ' Contao ' , true );
139
139
140
140
$ this ->assertSame (
141
- " $ path/ 1.html.twig_d75171 " ,
142
- $ loader ->getCacheKey ('@Contao/1.html.twig ' )
141
+ Path:: join ( $ path, ' 1.html.twig ' ) ,
142
+ Path:: normalize ( $ loader ->getCacheKey ('@Contao/1.html.twig ' ) )
143
143
);
144
144
}
145
145
146
- public function testCacheKeyChangesWhenHierarchyChanges (): void
147
- {
148
- $ filesystem = new Filesystem ();
149
- $ tempDir = $ this ->getTempDir ();
150
-
151
- $ addFile = static function (string $ filename ) use ($ tempDir , $ filesystem ): void {
152
- $ filesystem ->copy (
153
- __DIR__ .'/../../Fixtures/Twig/paths/1/1.html.twig ' ,
154
- Path::join ($ tempDir , $ filename )
155
- );
156
- };
157
-
158
- $ loader = $ this ->getContaoFilesystemLoader (null , new TemplateLocator ('' , [], []));
159
- $ loader ->addPath ($ tempDir , 'Contao_Test ' , true );
160
- $ addFile ('1.html.twig ' );
161
-
162
- $ cacheKey = $ loader ->getCacheKey ('@Contao_Test/1.html.twig ' );
163
-
164
- // Hierarchy should have been built automatically: expect no change
165
- $ loader ->buildHierarchy ();
166
- $ this ->assertSame ($ cacheKey , $ loader ->getCacheKey ('@Contao_Test/1.html.twig ' ));
167
-
168
- // Add a template in the tracked path and refresh: expect change
169
- $ addFile ('2.html.twig ' );
170
- $ loader ->buildHierarchy ();
171
-
172
- $ this ->assertNotSame ($ cacheKey , $ loader ->getCacheKey ('@Contao_Test/1.html.twig ' ));
173
-
174
- $ filesystem ->remove ($ tempDir );
175
- }
176
-
177
146
public function testGetCacheKeyDelegatesToThemeTemplate (): void
178
147
{
179
148
$ basePath = Path::canonicalize (__DIR__ .'/../../Fixtures/Twig/inheritance ' );
@@ -184,8 +153,8 @@ public function testGetCacheKeyDelegatesToThemeTemplate(): void
184
153
$ loader ->addPath (Path::join ($ basePath , 'templates/my/theme ' ), 'Contao_Theme_my_theme ' );
185
154
186
155
$ this ->assertSame (
187
- Path::join ($ basePath , 'templates/text.html.twig_d75171 ' ),
188
- $ loader ->getCacheKey ('@Contao/text.html.twig ' )
156
+ Path::join ($ basePath , 'templates/text.html.twig ' ),
157
+ Path:: normalize ( $ loader ->getCacheKey ('@Contao/text.html.twig ' ) )
189
158
);
190
159
191
160
// Reset and switch context
@@ -197,8 +166,8 @@ public function testGetCacheKeyDelegatesToThemeTemplate(): void
197
166
$ GLOBALS ['objPage ' ] = $ page ;
198
167
199
168
$ this ->assertSame (
200
- Path::join ($ basePath , 'templates/my/theme/text.html.twig_d75171 ' ),
201
- $ loader ->getCacheKey ('@Contao/text.html.twig ' )
169
+ Path::join ($ basePath , 'templates/my/theme/text.html.twig ' ),
170
+ Path:: normalize ( $ loader ->getCacheKey ('@Contao/text.html.twig ' ) )
202
171
);
203
172
204
173
unset($ GLOBALS ['objPage ' ]);
@@ -215,7 +184,7 @@ public function testGetSourceContext(): void
215
184
$ source = $ loader ->getSourceContext ('@Contao/1.html.twig ' );
216
185
217
186
$ this ->assertSame ('@Contao/1.html.twig ' , $ source ->getName ());
218
- $ this ->assertSame (Path::join ($ path , '1.html.twig ' ), $ source ->getPath ());
187
+ $ this ->assertSame (Path::join ($ path , '1.html.twig ' ), Path:: normalize ( $ source ->getPath () ));
219
188
}
220
189
221
190
public function testGetSourceContextDelegatesToThemeTemplate (): void
@@ -230,7 +199,7 @@ public function testGetSourceContextDelegatesToThemeTemplate(): void
230
199
$ source = $ loader ->getSourceContext ('@Contao/text.html.twig ' );
231
200
232
201
$ this ->assertSame ('@Contao/text.html.twig ' , $ source ->getName ());
233
- $ this ->assertSame (Path::join ($ basePath , 'templates/text.html.twig ' ), $ source ->getPath ());
202
+ $ this ->assertSame (Path::join ($ basePath , 'templates/text.html.twig ' ), Path:: normalize ( $ source ->getPath () ));
234
203
235
204
// Reset and switch context
236
205
$ loader ->reset ();
@@ -243,7 +212,7 @@ public function testGetSourceContextDelegatesToThemeTemplate(): void
243
212
$ source = $ loader ->getSourceContext ('@Contao/text.html.twig ' );
244
213
245
214
$ this ->assertSame ('@Contao_Theme_my_theme/text.html.twig ' , $ source ->getName ());
246
- $ this ->assertSame (Path::join ($ basePath , 'templates/my/theme/text.html.twig ' ), $ source ->getPath ());
215
+ $ this ->assertSame (Path::join ($ basePath , 'templates/my/theme/text.html.twig ' ), Path:: normalize ( $ source ->getPath () ));
247
216
248
217
unset($ GLOBALS ['objPage ' ]);
249
218
}
0 commit comments