8000 minor #58190 Mitigate PHPUnit deprecations (5.4) (alexandre-daubois) · symfony/symfony@7518cc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7518cc7

Browse files
committed
minor #58190 Mitigate PHPUnit deprecations (5.4) (alexandre-daubois)
This PR was merged into the 5.4 branch. Discussion ---------- Mitigate PHPUnit deprecations (5.4) | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Calling `->will(...)` is deprecated in many cases: https://github.com/sebastianbergmann/phpunit/blob/main/DEPRECATIONS.md. Commits ------- e3db889 Mitigate PHPUnit deprecations
2 parents 86805e0 + e3db889 commit 7518cc7

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineCloseConnectionMiddlewareTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function testInvalidEntityManagerThrowsException()
6262
$managerRegistry
6363
->method('getManager')
6464
->with('unknown_manager')
65-
->will($this->throwException(new \InvalidArgumentException()));
65+
->willThrowException(new \InvalidArgumentException());
6666

6767
$middleware = new DoctrineCloseConnectionMiddleware($managerRegistry, 'unknown_manager');
6868

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrinePingConnectionMiddlewareTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testInvalidEntityManagerThrowsException()
101101
$managerRegistry
102102
->method('getManager')
103103
->with('unknown_manager')
104-
->will($this->throwException(new \InvalidArgumentException()));
104+
->willThrowException(new \InvalidArgumentException());
105105

106106
$middleware = new DoctrinePingConnectionMiddleware($managerRegistry, 'unknown_manager');
107107

src/Symfony/Bridge/Doctrine/Tests/Messenger/DoctrineTransactionMiddlewareTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testInvalidEntityManagerThrowsException()
7373
$managerRegistry
7474
->method('getManager')
7575
->with('unknown_manager')
76-
->will($this->throwException(new \InvalidArgumentException()));
76+
->willThrowException(new \InvalidArgumentException());
7777

7878
$middleware = new DoctrineTransactionMiddleware($managerRegistry, 'unknown_manager');
7979

src/Symfony/Component/Mailer/Tests/Transport/FailoverTransportTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function testSendFirstWork()
5757
public function testSendAllDead()
5858
{
5959
$t1 = $this->createMock(TransportInterface::class);
60-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
60+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
6161
$t2 = $this->createMock(TransportInterface::class);
62-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
62+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
6363
$t = new FailoverTransport([$t1, $t2]);
6464
$this->expectException(TransportException::class);
6565
$this->expectExceptionMessage('All transports failed.');
@@ -70,7 +70,7 @@ public function testSendAllDead()
7070
public function testSendOneDead()
7171
{
7272
$t1 = $this->createMock(TransportInterface::class);
73-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
73+
$t1->expects($this->once())->method(' A93C send')->willThrowException(new TransportException());
7474
$t2 = $this->createMock(TransportInterface::class);
7575
$t2->expects($this->exactly(3))->method('send');
7676
$t = new FailoverTransport([$t1, $t2]);

src/Symfony/Component/Mailer/Tests/Transport/RoundRobinTransportTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function testSendAlternate()
5757
public function testSendAllDead()
5858
{
5959
$t1 = $this->createMock(TransportInterface::class);
60-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
60+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
6161
$t2 = $this->createMock(TransportInterface::class);
62-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
62+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
6363
$t = new RoundRobinTransport([$t1, $t2]);
6464
$p = new \ReflectionProperty($t, 'cursor');
6565
$p->setAccessible(true);
@@ -81,7 +81,7 @@ public function testSendAllDead()
8181
public function testSendOneDead()
8282
{
8383
$t1 = $this->createMock(TransportInterface::class);
84-
$t1->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
84+
$t1->expects($this->once())->method('send')->willThrowException(new TransportException());
8585
$t2 = $this->createMock(TransportInterface::class);
8686
$t2->expects($this->exactly(3))->method('send');
8787
$t = new RoundRobinTransport([$t1, $t2]);
@@ -101,7 +101,7 @@ public function testSendOneDeadAndRecoveryNotWithinRetryPeriod()
101101
$t1 = $this->createMock(TransportInterface::class);
102102
$t1->expects($this->exactly(4))->method('send');
103103
$t2 = $this->createMock(TransportInterface::class);
104-
$t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
104+
$t2->expects($this->once())->method('send')->willThrowException(new TransportException());
105105
$t = new RoundRobinTransport([$t1, $t2], 60);
106106
$p = new \ReflectionProperty($t, 'cursor');
107107
$p->setAccessible(true);
@@ -152,13 +152,13 @@ public function testFailureDebugInformation()
152152
$t1 = $this->createMock(TransportInterface::class);
153153
$e1 = new TransportException();
154154
$e1->appendDebug('Debug message 1');
155-
$t1->expects($this->once())->method('send')->will($this->throwException($e1));
155+
$t1->expects($this->once())->method('send')->willThrowException($e1);
156156
$t1->expects($this->once())->method('__toString')->willReturn('t1');
157157

158158
$t2 = $this->createMock(TransportInterface::class);
159159
$e2 = new TransportException();
160160
$e2->appendDebug('Debug message 2');
161-
$t2->expects($this->once())->method('send')->will($this->throwException($e2));
161+
$t2->expects($this->once())->method('send')->willThrowException($e2);
162162
$t2->expects($this->once())->method('__toString')->willReturn('t2');
163163

164164
$t = new RoundRobinTransport([$t1, $t2]);

src/Symfony/Component/Messenger/Tests/Middleware/DispatchAfterCurrentBusMiddlewareTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testEventsInNewTransactionAreHandledAfterMainMessage()
6868
->with($this->callback(function (Envelope $envelope) use (&$series) {
6969
return $envelope->getMessage() === array_shift($series);
7070
}))
71-
->will($this->willHandleMessage());
71+
->willReturnCallback($this->handleMessageCallback());
7272

7373
$messageBus->dispatch($message);
7474
}
@@ -282,7 +282,7 @@ public function testDispatchOutOfAnotherHandlerDispatchesAndRemoveStamp()
282282
$handlingMiddleware
283283
->method('handle')
284284
->with($this->expectHandledMessage($event))
285-
->will($this->willHandleMessage());
285+
->willReturnCallback($this->handleMessageCallback());
286286

287287
$eventBus = new MessageBus([
288288
$middleware,
@@ -301,11 +301,11 @@ private function expectHandledMessage($message): Callback
301301
});
302302
}
303303

304-
private function willHandleMessage(): ReturnCallback
304+
private function handleMessageCallback(): \Closure
305305
{
306-
return $this->returnCallback(function ($envelope, StackInterface $stack) {
306+
return function ($envelope, StackInterface $stack) {
307307
return $stack->next()->handle($envelope, $stack);
308-
});
308+
};
309309
}
310310
}
311311

src/Symfony/Co 111C mponent/Notifier/Tests/Transport/FailoverTransportTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public function testSendAllDead()
8080

8181
$t1 = $this->createMock(TransportInterface::class);
8282
$t1->method('supports')->with($message)->willReturn(true);
83-
$t1->expects($this->once())->method('send')->with($message)->will($this->throwException($this->createMock(TransportExceptionInterface::class)));
83+
$t1->expects($this->once())->method('send')->with($message)->willThrowException($this->createMock(TransportExceptionInterface::class));
8484

8585
$t2 = $this->createMock(TransportInterface::class);
8686
$t2->method('supports')->with($message)->willReturn(true);
87-
$t2->expects($this->once())->method('send')->with($message)->will($this->throwException($this->createMock(TransportExceptionInterface::class)));
87+
$t2->expects($this->once())->method('send')->with($message)->willThrowException($this->createMock(TransportExceptionInterface::class));
8888

8989
$t = new FailoverTransport([$t1, $t2]);
9090

@@ -100,7 +100,7 @@ public function testSendOneDead()
100100

101101
$t1 = $this->createMock(TransportInterface::class);
102102
$t1->method('supports')->with($message)->willReturn(true);
103-
$t1->expects($this->once())->method('send')->will($this->throwException($this->createMock(TransportExceptionInterface::class)));
103+
$t1->expects($this->once())->method('send')->willThrowException($this->createMock(TransportExceptionInterface::class));
104104

105105
$t2 = $this->createMock(TransportInterface::class);
106106
$t2->method('supports')->with($message)->willReturn(true);
@@ -117,7 +117,7 @@ public function testSendAllDeadWithinRetryPeriod()
117117

118118
$t1 = $this->createMock(TransportInterface::class);
119119
$t1->method('supports')->with($message)->willReturn(true);
120-
$t1->method('send')->will($this->throwException($this->createMock(TransportExceptionInterface::class)));
120+
$t1->method('send')->willThrowException($this->createMock(TransportExceptionInterface::class));
121121
$t1->expects($this->once())->method('send');
122122
$t2 = $this->createMock(TransportInterface::class);
123123
$t2->method('supports')->with($message)->willReturn(true);

0 commit comments

Comments
 (0)
0