Skip to content

Commit e1d4295

Browse files
committed
Merge branch '5.4' into 6.4
* 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
2 parents 2c446d4 + 85ba4ca commit e1d4295

File tree

2 files changed

+61
-24
lines changed

2 files changed

+61
-24
lines changed

Tests/Transport/FailoverTransportTest.php

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,30 @@ public function testSendOneDead()
8585
public function testSendOneDeadAndRecoveryWithinRetryPeriod()
8686
{
8787
$t1 = $this->createMock(TransportInterface::class);
88-
$t1->method('send')->willReturnOnConsecutiveCalls($this->throwException(new TransportException()));
88+
89+
$t1Matcher = $this->any();
90+
$t1->expects($t1Matcher)
91+
->method('send')
92+
->willReturnCallback(function () use ($t1Matcher) {
93+
if (1 === $t1Matcher->getInvocationCount()) {
94+
throw new TransportException();
95+
}
96+
97+
return null;
98+
});
99+
89100
$t2 = $this->createMock(TransportInterface::class);
90-
$t2->expects($this->exactly(4))
101+
$t2Matcher = $this->exactly(4);
102+
$t2->expects($t2Matcher)
91103
->method('send')
92-
->willReturnOnConsecutiveCalls(
93-
null,
94-
null,
95-
null,
96-
$this->throwException(new TransportException())
97-
);
104+
->willReturnCallback(function () use ($t2Matcher) {
105+
if (4 === $t2Matcher->getInvocationCount()) {
106+
throw new TransportException();
107+
}
108+
109+
return null;
110+
});
111+
98112
$t = new FailoverTransport([$t1, $t2], 6);
99113
$t->send(new RawMessage('')); // t1>fail - t2>sent
100114
$this->assertTransports($t, 0, [$t1]);
@@ -115,16 +129,19 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
115129
public function testSendAllDeadWithinRetryPeriod()
116130
{
117131
$t1 = $this->createMock(TransportInterface::class);
118-
$t1->method('send')->will($this->throwException(new TransportException()));
132+
$t1->method('send')->willThrowException(new TransportException());
119133
$t1->expects($this->once())->method('send');
120134
$t2 = $this->createMock(TransportInterface::class);
121-
$t2->expects($this->exactly(3))
135+
$matcher = $this->exactly(3);
136+
$t2->expects($matcher)
122137
->method('send')
123-
->willReturnOnConsecutiveCalls(
124-
null,
125-
null,
126-
$this->throwException(new TransportException())
127-
);
138+
->willReturnCallback(function () use ($matcher) {
139+
if (3 === $matcher->getInvocationCount()) {
140+
throw new TransportException();
141+
}
142+
143+
return null;
144+
});
128145
$t = new FailoverTransport([$t1, $t2], 40);
129146
$t->send(new RawMessage(''));
130147
sleep(4);
@@ -137,15 +154,27 @@ public function testSendAllDeadWithinRetryPeriod()
137154

138155
public function testSendOneDeadButRecover()
139156
{
157+
$t1Matcher = $this->any();
140158
$t1 = $this->createMock(TransportInterface::class);
141-
$t1->method('send')->willReturnOnConsecutiveCalls($this->throwException(new TransportException()));
159+
$t1->expects($t1Matcher)->method('send')->willReturnCallback(function () use ($t1Matcher) {
160+
if (1 === $t1Matcher->getInvocationCount()) {
161+
throw new TransportException();
162+
}
163+
164+
return null;
165+
});
166+
142167
$t2 = $this->createMock(TransportInterface::class);
143-
$t2->expects($this->exactly(3))
144-
->method('send')->willReturnOnConsecutiveCalls(
145-
null,
146-
null,
147-
$this->throwException(new TransportException())
148-
);
168+
$matcher = $this->exactly(3);
169+
$t2->expects($matcher)
170+
->method('send')
171+
->willReturnCallback(function () use ($matcher) {
172+
if (3 === $matcher->getInvocationCount()) {
173+
throw new TransportException();
174+
}
175+
176+
return null;
177+
});
149178
$t = new FailoverTransport([$t1, $t2], 1);
150179
$t->send(new RawMessage(''));
151180
sleep(1);

Tests/Transport/RoundRobinTransportTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,18 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
117117
{
118118
$t1 = $this->createMock(TransportInterface::class);
119119
$t1->expects($this->exactly(3))->method('send');
120+
121+
$matcher = $this->exactly(2);
120122
$t2 = $this->createMock(TransportInterface::class);
121-
$t2->expects($this->exactly(2))
123+
$t2->expects($matcher)
122124
->method('send')
123-
->willReturnOnConsecutiveCalls($this->throwException(new TransportException()));
125+
->willReturnCallback(function () use ($matcher) {
126+
if (1 === $matcher->getInvocationCount()) {
127+
throw new TransportException();
128+
}
129+
130+
return null;
131+
});
124132
$t = new RoundRobinTransport([$t1, $t2], 3);
125133
$p = new \ReflectionProperty($t, 'cursor');
126134
$p->setValue($t, 0);

0 commit comments

Comments
 (0)