@@ -307,7 +307,7 @@ public function testIcons(): void
307307 $ assets = new Assets ();
308308
309309 $ this ->assertSame (
310- '/media/ panel/ ' . $ this ->app ->versionHash () . '/img /icons.svg ' ,
310+ '/panel/assets/ ' . $ this ->app ->versionHash () . '/icons.svg ' ,
311311 $ assets ->icons ()
312312 );
313313 }
@@ -316,55 +316,49 @@ public function testIconsInDevMode(): void
316316 {
317317 $ this ->setDevMode ();
318318
319- $ assets = new Assets ();
320- $ target = $ this ->app ->root ('media ' ) . '/panel/ ' . $ this ->app ->versionHash () . '/img/icons.svg ' ;
321-
322- $ this ->assertFileDoesNotExist ($ target );
319+ $ assets = new Assets ();
320+ $ modified = F::modified ($ this ->app ->root ('panel ' ) . '/public/img/icons.svg ' );
323321
324- // the sprite is not served by Vite, but synced to the media folder
325322 $ this ->assertSame (
326- '/media/ panel/ ' . $ this -> app -> versionHash () . '/img /icons.svg ' ,
323+ '/panel/assets/ ' . $ modified . '/icons.svg ' ,
327324 $ assets ->icons ()
328325 );
329-
330- $ this ->assertFileEquals (
331- $ this ->app ->root ('panel ' ) . '/public/img/icons.svg ' ,
332- $ target
333- );
334326 }
335327
336- public function testIconsInDevModeWithCurrentCopy (): void
328+ public function testIconsWithCustomMediaUrl (): void
337329 {
338- $ this ->setDevMode ();
330+ $ this ->app = $ this ->app ->clone ([
331+ 'urls ' => [
332+ 'media ' => 'https://cdn.getkirby.com/media '
333+ ]
334+ ]);
339335
336+ // the sprite must stay on the Panel origin, even if
337+ // the media folder is served from a CDN
340338 $ assets = new Assets ();
341- $ source = $ this ->app ->root ('panel ' ) . '/public/img/icons.svg ' ;
342- $ target = $ this ->app ->root ('media ' ) . '/panel/ ' . $ this ->app ->versionHash () . '/img/icons.svg ' ;
343-
344- F::write ($ target , 'current ' );
345- touch ($ target , F::modified ($ source ));
346339
347- $ assets -> icons ();
348-
349- // the copy is up to date and does not get repeated
350- $ this -> assertSame ( ' current ' , F:: read ( $ target ) );
340+ $ this -> assertSame (
341+ ' /panel/assets/ ' . $ this -> app -> versionHash () . ' /icons.svg ' ,
342+ $ assets -> icons ()
343+ );
351344 }
352345
353- public function testIconsInDevModeWithOutdatedCopy (): void
346+ public function testIconsWithCustomPanelSlug (): void
354347 {
355- $ this ->setDevMode ();
348+ $ this ->app = $ this ->app ->clone ([
349+ 'options ' => [
350+ 'panel ' => [
351+ 'slug ' => 'admin '
352+ ]
353+ ]
354+ ]);
356355
357356 $ assets = new Assets ();
358- $ source = $ this ->app ->root ('panel ' ) . '/public/img/icons.svg ' ;
359- $ target = $ this ->app ->root ('media ' ) . '/panel/ ' . $ this ->app ->versionHash () . '/img/icons.svg ' ;
360-
361- F::write ($ target , 'outdated ' );
362- touch ($ target , 1 );
363-
364- $ assets ->icons ();
365357
366- $ this ->assertFileEquals ($ source , $ target );
367- $ this ->assertSame (F::modified ($ source ), F::modified ($ target ));
358+ $ this ->assertSame (
359+ '/admin/assets/ ' . $ this ->app ->versionHash () . '/icons.svg ' ,
360+ $ assets ->icons ()
361+ );
368362 }
369363
370364 public function testIconsRoot (): void
@@ -397,6 +391,13 @@ public function testImportMaps(): void
397391 $ this ->assertSame ('/media/panel/ ' . $ this ->app ->versionHash () . '/js/vue.esm-browser.prod.js ' , $ importMaps ['vue ' ]);
398392 }
399393
394+ public function testIsDev (): void
395+ {
396+ $ this ->assertFalse ((new Assets ())->isDev ());
397+ $ this ->setDevMode ();
398+ $ this ->assertTrue ((new Assets ())->isDev ());
399+ }
400+
400401 public function testJs (): void
401402 {
402403 // default asset setup
0 commit comments