@@ -86,23 +86,25 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
86
86
{
87
87
$ t1 = $ this ->createMock (TransportInterface::class);
88
88
89
- $ t1Matcher = $ this ->any ();
90
- $ t1 ->expects ($ t1Matcher )
89
+ $ t1 ->expects ($ this ->any ())
91
90
->method ('send ' )
92
- ->willReturnCallback (function () use ($ t1Matcher ) {
93
- if (1 === $ t1Matcher ->getInvocationCount ()) {
91
+ ->willReturnCallback (function () {
92
+ static $ call = 0 ;
93
+
94
+ if (1 === ++$ call ) {
94
95
throw new TransportException ();
95
96
}
96
97
97
98
return null ;
98
99
});
99
100
100
101
$ t2 = $ this ->createMock (TransportInterface::class);
101
- $ t2Matcher = $ this ->exactly (4 );
102
- $ t2 ->expects ($ t2Matcher )
102
+ $ t2 ->expects ($ this ->exactly (4 ))
103
103
->method ('send ' )
104
- ->willReturnCallback (function () use ($ t2Matcher ) {
105
- if (4 === $ t2Matcher ->getInvocationCount ()) {
104
+ ->willReturnCallback (function () {
105
+ static $ call = 0 ;
106
+
107
+ if (4 === ++$ call ) {
106
108
throw new TransportException ();
107
109
}
108
110
@@ -132,11 +134,12 @@ public function testSendAllDeadWithinRetryPeriod()
132
134
$ t1 ->method ('send ' )->willThrowException (new TransportException ());
133
135
$ t1 ->expects ($ this ->once ())->method ('send ' );
134
136
$ t2 = $ this ->createMock (TransportInterface::class);
135
- $ matcher = $ this ->exactly (3 );
136
- $ t2 ->expects ($ matcher )
137
+ $ t2 ->expects ($ this ->exactly (3 ))
137
138
->method ('send ' )
138
- ->willReturnCallback (function () use ($ matcher ) {
139
- if (3 === $ matcher ->getInvocationCount ()) {
139
+ ->willReturnCallback (function () {
140
+ static $ call = 0 ;
141
+
142
+ if (3 === ++$ call ) {
140
143
throw new TransportException ();
141
144
}
142
145
@@ -154,22 +157,24 @@ public function testSendAllDeadWithinRetryPeriod()
154
157
155
158
public function testSendOneDeadButRecover ()
156
159
{
157
- $ t1Matcher = $ this ->any ();
158
160
$ t1 = $ this ->createMock (TransportInterface::class);
159
- $ t1 ->expects ($ t1Matcher )->method ('send ' )->willReturnCallback (function () use ($ t1Matcher ) {
160
- if (1 === $ t1Matcher ->getInvocationCount ()) {
161
+ $ t1 ->expects ($ this ->any ())->method ('send ' )->willReturnCallback (function () {
162
+ static $ call = 0 ;
163
+
164
+ if (1 === ++$ call ) {
161
165
throw new TransportException ();
162
166
}
163
167
164
168
return null ;
165
169
});
166
170
167
171
$ t2 = $ this ->createMock (TransportInterface::class);
168
- $ matcher = $ this ->exactly (3 );
169
- $ t2 ->expects ($ matcher )
172
+ $ t2 ->expects ($ this ->exactly (3 ))
170
173
->method ('send ' )
171
- ->willReturnCallback (function () use ($ matcher ) {
172
- if (3 === $ matcher ->getInvocationCount ()) {
174
+ ->willReturnCallback (function () {
175
+ static $ call = 0 ;
176
+
177
+ if (3 === ++$ call ) {
173
178
throw new TransportException ();
174
179
}
175
180
0 commit comments