@@ -28,12 +28,11 @@ final class ExecuteJavascriptMiddlewareTest extends IntegrationTestCase
2828
2929 public function testUpdateResponseBodyWithHtmlAfterExecutingJavascript (): void
3030 {
31- $ response = $ this ->makeResponse (
32- $ this ->makeRequest ('http://localhost:8000/javascript ' ),
33- );
31+ $ request = $ this ->makeRequest ('http://localhost:8000/javascript ' );
3432 $ middleware = new ExecuteJavascriptMiddleware (new FakeLogger ());
3533
36- $ processedResponse = $ middleware ->handleResponse ($ response );
34+ $ processedRequest = $ middleware ->handleRequest ($ request );
35+ $ processedResponse = $ processedRequest ->getResponse ();
3736
3837 self ::assertSame ('Headline ' , $ processedResponse ->filter ('#content h1 ' )->text ('' ));
3938 self ::assertSame ('I was loaded via Javascript! ' , $ processedResponse ->filter ('#content p ' )->text ('' ));
@@ -52,9 +51,9 @@ public function bodyHtml(): string
5251 static fn (string $ uri ): Browsershot => $ throwingBrowsershot ->setUrl ($ uri ),
5352 );
5453
55- $ processedResponse = $ middleware ->handleResponse ($ this ->makeResponse ( ));
54+ $ processedRequest = $ middleware ->handleRequest ($ this ->makeRequest ( ' http://fake-url.com ' ));
5655
57- self ::assertTrue ($ processedResponse ->wasDropped ());
56+ self ::assertTrue ($ processedRequest ->wasDropped ());
5857 }
5958
6059 public function testLogErrors (): void
@@ -71,7 +70,7 @@ public function bodyHtml(): string
7170 static fn (string $ uri ): Browsershot => $ throwingBrowsershot ->setUrl ($ uri ),
7271 );
7372
74- $ middleware ->handleResponse ($ this ->makeResponse ( ));
73+ $ middleware ->handleRequest ($ this ->makeRequest ( ' http://fake-url.com ' ));
7574
7675 self ::assertTrue (
7776 $ logger ->messageWasLogged (
@@ -84,19 +83,14 @@ public function bodyHtml(): string
8483 public function testUsesTheProvidedUserAgentOption (): void
8584 {
8685 $ mockBrowserShot = $ this ->createMock (Browsershot::class);
87- $ response = $ this ->makeResponse (
88- $ this ->makeRequest ('http://localhost:8000/javascript ' ),
89- );
90- $ middleware = new ExecuteJavascriptMiddleware (
91- new FakeLogger (),
92- static fn (string $ uri ): Browsershot => $ mockBrowserShot ,
93- );
86+ $ request = $ this ->makeRequest ('http://localhost:8000/javascript ' );
87+ $ middleware = new ExecuteJavascriptMiddleware (new FakeLogger (), static fn (string $ uri ): Browsershot => $ mockBrowserShot );
9488 $ middleware ->configure (['userAgent ' => 'custom ' ]);
9589
9690 $ mockBrowserShot ->expects (self ::once ())
9791 ->method ('userAgent ' )
9892 ->with (self ::equalTo ('custom ' ));
9993
100- $ middleware ->handleResponse ( $ response );
94+ $ middleware ->handleRequest ( $ request );
10195 }
10296}
0 commit comments