Skip to content

Commit d4a05b5

Browse files
committed
phpunit 10 deprecations fix
1 parent 1b4481f commit d4a05b5

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

tests/Middleware/FollowRedirectMiddlewareTest.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,17 @@ public function testProcess(string $method, int $statusCode, string $expectedMet
2020
{
2121
$client = $this->getMockBuilder(Client::class)
2222
->onlyMethods(['sendRequest'])
23-
->getMockForAbstractClass();
23+
->getMock();
2424

2525
$client
2626
->expects($this->exactly(2))
2727
->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+
});
3834

3935
$requestHandler = new RequestHandler($client, new FollowRedirectMiddleware(new HttpFactory()));
4036
$response = $requestHandler->handle(new Request($method, 'https://some-location.org/path'));
@@ -43,7 +39,7 @@ function (RequestInterface $request) {
4339
$this->assertSame($expectedMethod, $response->getHeaderLine('requestMethod'));
4440
}
4541

46-
public function provideFollowRedirect(): iterable
42+
public static function provideFollowRedirect(): iterable
4743
{
4844
return [
4945
['POST', 301, 'GET'],
@@ -62,7 +58,7 @@ public function testProcessNoFollow(string $method, int $statusCode, array $head
6258
{
6359
$client = $this->getMockBuilder(Client::class)
6460
->onlyMethods(['sendRequest'])
65-
->getMockForAbstractClass();
61+
->getMock();
6662

6763
$client
6864
->expects($this->exactly(1))
@@ -74,7 +70,7 @@ public function testProcessNoFollow(string $method, int $statusCode, array $head
7470
$this->assertSame($response, $requestHandler->handle(new Request($method, 'https://some-location.org/path')));
7571
}
7672

77-
public function provideNoFollow(): iterable
73+
public static function provideNoFollow(): iterable
7874
{
7975
return [
8076
['PUT', 300, ['Location' => 'https://new-location.org/path']],

0 commit comments

Comments
 (0)