@@ -28,12 +28,11 @@ final class ExecuteJavascriptMiddlewareTest extends IntegrationTestCase
28
28
29
29
public function testUpdateResponseBodyWithHtmlAfterExecutingJavascript (): void
30
30
{
31
- $ response = $ this ->makeResponse (
32
- $ this ->makeRequest ('http://localhost:8000/javascript ' ),
33
- );
31
+ $ request = $ this ->makeRequest ('http://localhost:8000/javascript ' );
34
32
$ middleware = new ExecuteJavascriptMiddleware (new FakeLogger ());
35
33
36
- $ processedResponse = $ middleware ->handleResponse ($ response );
34
+ $ processedRequest = $ middleware ->handleRequest ($ request );
35
+ $ processedResponse = $ processedRequest ->getResponse ();
37
36
38
37
self ::assertSame ('Headline ' , $ processedResponse ->filter ('#content h1 ' )->text ('' ));
39
38
self ::assertSame ('I was loaded via Javascript! ' , $ processedResponse ->filter ('#content p ' )->text ('' ));
@@ -52,9 +51,9 @@ public function bodyHtml(): string
52
51
static fn (string $ uri ): Browsershot => $ throwingBrowsershot ->setUrl ($ uri ),
53
52
);
54
53
55
- $ processedResponse = $ middleware ->handleResponse ($ this ->makeResponse ( ));
54
+ $ processedRequest = $ middleware ->handleRequest ($ this ->makeRequest ( ' http://fake-url.com ' ));
56
55
57
- self ::assertTrue ($ processedResponse ->wasDropped ());
56
+ self ::assertTrue ($ processedRequest ->wasDropped ());
58
57
}
59
58
60
59
public function testLogErrors (): void
@@ -71,7 +70,7 @@ public function bodyHtml(): string
71
70
static fn (string $ uri ): Browsershot => $ throwingBrowsershot ->setUrl ($ uri ),
72
71
);
73
72
74
- $ middleware ->handleResponse ($ this ->makeResponse ( ));
73
+ $ middleware ->handleRequest ($ this ->makeRequest ( ' http://fake-url.com ' ));
75
74
76
75
self ::assertTrue (
77
76
$ logger ->messageWasLogged (
@@ -84,16 +83,14 @@ public function bodyHtml(): string
84
83
public function testUsesTheProvidedUserAgentOption (): void
85
84
{
86
85
$ mockBrowserShot = $ this ->createMock (Browsershot::class);
87
- $ response = $ this ->makeResponse (
88
- $ this ->makeRequest ('http://localhost:8000/javascript ' ),
89
- );
86
+ $ request = $ this ->makeRequest ('http://localhost:8000/javascript ' );
90
87
$ middleware = new ExecuteJavascriptMiddleware (new FakeLogger (), static fn (string $ uri ): Browsershot => $ mockBrowserShot );
91
88
$ middleware ->configure (['userAgent ' => 'custom ' ]);
92
89
93
90
$ mockBrowserShot ->expects (self ::once ())
94
91
->method ('userAgent ' )
95
92
->with (self ::equalTo ('custom ' ));
96
93
97
- $ middleware ->handleResponse ( $ response );
94
+ $ middleware ->handleRequest ( $ request );
98
95
}
99
96
}
0 commit comments