Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  fix compatibility with Twig 3.10
  [Strings][EnglishInflector] Fix incorrect pluralisation of 'Album'
  handle union and intersection types for cascaded validations
  move wiring of the property info extractor to the ObjectNormalizer
  move Process component dep to require-dev
  Remove calls to `onConsecutiveCalls()`
  fix: remove unwanted type cast
  accept AbstractAsset instances when filtering schemas
  better distinguish URL schemes and windows drive letters
  convert empty CSV header names into numeric keys
  • Loading branch information
derrabus committed May 2, 2024
2 parents cc08147 + bb4d7c2 commit f6e526e
Showing 1 changed file with 29 additions and 14 deletions.
43 changes: 29 additions & 14 deletions Tests/Transport/FailoverTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,17 @@ public function testSendAllDeadWithinRetryPeriod()
$t1->expects($this->once())->method('send');
$t2 = $this->createMock(TransportInterface::class);
$t2->method('supports')->with($message)->willReturn(true);
$t2->expects($this->exactly(3))

$matcher = $this->exactly(3);
$t2->expects($matcher)
->method('send')
->willReturnOnConsecutiveCalls(
new SentMessage($message, 't2'),
new SentMessage($message, 't2'),
$this->throwException($this->createMock(TransportExceptionInterface::class))
);
->willReturnCallback(function () use ($matcher, $message) {
if (3 === $matcher->getInvocationCount()) {
throw $this->createMock(TransportExceptionInterface::class);
}

return new SentMessage($message, 't2');
});
$t = new FailoverTransport([$t1, $t2], 40);
$t->send($message);
sleep(4);
Expand All @@ -146,16 +150,27 @@ public function testSendOneDeadButRecover()

$t1 = $this->createMock(TransportInterface::class);
$t1->method('supports')->with($message)->willReturn(true);
$t1->expects($this->exactly(2))->method('send')->willReturnOnConsecutiveCalls(
$this->throwException($this->createMock(TransportExceptionInterface::class)),
new SentMessage($message, 't1')
);

$t1Matcher = $this->exactly(2);
$t1->expects($t1Matcher)->method('send')
->willReturnCallback(function () use ($t1Matcher, $message) {
if (1 === $t1Matcher->getInvocationCount()) {
throw $this->createMock(TransportExceptionInterface::class);
}

return new SentMessage($message, 't1');
});
$t2 = $this->createMock(TransportInterface::class);
$t2->method('supports')->with($message)->willReturn(true);
$t2->expects($this->exactly(2))->method('send')->willReturnOnConsecutiveCalls(
new SentMessage($message, 't2'),
$this->throwException($this->createMock(TransportExceptionInterface::class))
);

$t2Matcher = $this->exactly(2);
$t2->expects($t2Matcher)->method('send')->willReturnCallback(function () use ($t2Matcher, $message) {
if (1 === $t2Matcher->getInvocationCount()) {
return new SentMessage($message, 't1');
}

throw $this->createMock(TransportExceptionInterface::class);
});

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

Expand Down

0 comments on commit f6e526e

Please sign in to comment.