@@ -20,21 +20,17 @@ public function testProcess(string $method, int $statusCode, string $expectedMet
20
20
{
21
21
$ client = $ this ->getMockBuilder (Client::class)
22
22
->onlyMethods (['sendRequest ' ])
23
- ->getMockForAbstractClass ();
23
+ ->getMock ();
24
24
25
25
$ client
26
26
->expects ($ this ->exactly (2 ))
27
27
->method ('sendRequest ' )
28
- ->will (
29
- $ this ->onConsecutiveCalls (
30
- new Response ($ statusCode , ['Location ' => 'https://new-location.org/path ' ]),
31
- $ this ->returnCallback (
32
- function (RequestInterface $ request ) {
33
- return new Response (200 , ['RequestMethod ' => $ request ->getMethod ()]);
34
- }
35
- )
36
- )
37
- );
28
+ ->willReturnCallback (function (RequestInterface $ request ) use ($ method , $ statusCode , &$ response ) {
29
+ if (!$ response ) {
30
+ return $ response = new Response ($ statusCode , ['Location ' => 'https://new-location.org/path ' ]);
31
+ }
32
+ return new Response (200 , ['RequestMethod ' => $ request ->getMethod ()]);
33
+ });
38
34
39
35
$ requestHandler = new RequestHandler ($ client , new FollowRedirectMiddleware (new HttpFactory ()));
40
36
$ response = $ requestHandler ->handle (new Request ($ method , 'https://some-location.org/path ' ));
@@ -43,7 +39,7 @@ function (RequestInterface $request) {
43
39
$ this ->assertSame ($ expectedMethod , $ response ->getHeaderLine ('requestMethod ' ));
44
40
}
45
41
46
- public function provideFollowRedirect (): iterable
42
+ public static function provideFollowRedirect (): iterable
47
43
{
48
44
return [
49
45
['POST ' , 301 , 'GET ' ],
@@ -62,7 +58,7 @@ public function testProcessNoFollow(string $method, int $statusCode, array $head
62
58
{
63
59
$ client = $ this ->getMockBuilder (Client::class)
64
60
->onlyMethods (['sendRequest ' ])
65
- ->getMockForAbstractClass ();
61
+ ->getMock ();
66
62
67
63
$ client
68
64
->expects ($ this ->exactly (1 ))
@@ -74,7 +70,7 @@ public function testProcessNoFollow(string $method, int $statusCode, array $head
74
70
$ this ->assertSame ($ response , $ requestHandler ->handle (new Request ($ method , 'https://some-location.org/path ' )));
75
71
}
76
72
77
- public function provideNoFollow (): iterable
73
+ public static function provideNoFollow (): iterable
78
74
{
79
75
return [
80
76
['PUT ' , 300 , ['Location ' => 'https://new-location.org/path ' ]],
0 commit comments