9
9
use Illuminate \Http \Response ;
10
10
use Illuminate \Support \Facades \Facade ;
11
11
use PHPUnit \Framework \TestCase ;
12
+ use Symfony \Component \HttpFoundation \Response as SymfonyResponse ;
12
13
13
14
class VitePreloadingTest extends TestCase
14
15
{
@@ -20,7 +21,7 @@ protected function tearDown(): void
20
21
21
22
public function testItDoesNotSetLinkTagWhenNoTagsHaveBeenPreloaded ()
22
23
{
23
- $ app = new Container () ;
24
+ $ app = new Container ;
24
25
$ app ->instance (Vite::class, new class extends Vite
25
26
{
26
27
protected $ preloadedAssets = [];
@@ -36,7 +37,7 @@ public function testItDoesNotSetLinkTagWhenNoTagsHaveBeenPreloaded()
36
37
37
38
public function testItAddsPreloadLinkHeader ()
38
39
{
39
- $ app = new Container () ;
40
+ $ app = new Container ;
40
41
$ app ->instance (Vite::class, new class extends Vite
41
42
{
42
43
protected $ preloadedAssets = [
@@ -57,4 +58,25 @@ public function testItAddsPreloadLinkHeader()
57
58
'<https://laravel.com/app.js>; rel="modulepreload"; foo="bar" '
58
59
);
59
60
}
61
+
62
+ public function testItDoesNotAttachHeadersToNonIlluminateResponses ()
63
+ {
64
+ $ app = new Container ;
65
+ $ app ->instance (Vite::class, new class extends Vite
66
+ {
67
+ protected $ preloadedAssets = [
68
+ 'https://laravel.com/app.js ' => [
69
+ 'rel="modulepreload" ' ,
70
+ 'foo="bar" ' ,
71
+ ],
72
+ ];
73
+ });
74
+ Facade::setFacadeApplication ($ app );
75
+
76
+ $ response = (new AddLinkHeadersForPreloadedAssets )->handle (new Request , function () {
77
+ return new SymfonyResponse ('Hello Laravel ' );
78
+ });
79
+
80
+ $ this ->assertNull ($ response ->headers ->get ('Link ' ));
81
+ }
60
82
}
0 commit comments