Skip to content

Commit 140bc01

Browse files
committed
Fix at() warnings for non-logger mocks — don't test for method call order
1 parent 63aaebf commit 140bc01

17 files changed

+94
-93
lines changed

pkg/amqp-lib/Tests/AmqpContextTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,12 @@ public function testShouldSetQos()
322322
{
323323
$channel = $this->createChannelMock();
324324
$channel
325-
->expects($this->at(0))
325+
->expects(self::once())
326326
->method('basic_qos')
327327
->with($this->identicalTo(0), $this->identicalTo(1), $this->isFalse())
328328
;
329329
$channel
330-
->expects($this->at(1))
330+
->expects(self::once())
331331
->method('basic_qos')
332332
->with($this->identicalTo(123), $this->identicalTo(456), $this->isTrue())
333333
;

pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php

+12-11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Interop\Queue\Message as InteropMessage;
2323
use Interop\Queue\Producer as InteropProducer;
2424
use Interop\Queue\Queue as InteropQueue;
25+
use PHPUnit\Framework\MockObject\MockObject;
2526
use PHPUnit\Framework\TestCase;
2627

2728
class AmqpDriverTest extends TestCase
@@ -190,54 +191,54 @@ public function testShouldSetupBroker()
190191
$context = $this->createContextMock();
191192
// setup router
192193
$context
193-
->expects($this->at(0))
194+
->expects(self::once())
194195
->method('createTopic')
195196
->willReturn($routerTopic)
196197
;
197198
$context
198-
->expects($this->at(1))
199+
->expects(self::once())
199200
->method('declareTopic')
200201
->with($this->identicalTo($routerTopic))
201202
;
202203

203204
$context
204-
->expects($this->at(2))
205+
->expects(self::once())
205206
->method('createQueue')
206207
->willReturn($routerQueue)
207208
;
208209
$context
209-
->expects($this->at(3))
210+
->expects(self::once())
210211
->method('declareQueue')
211212
->with($this->identicalTo($routerQueue))
212213
;
213214

214215
$context
215-
->expects($this->at(4))
216+
->expects(self::once())
216217
->method('bind')
217218
->with($this->isInstanceOf(AmqpBind::class))
218219
;
219220

220221
// setup processor with default queue
221222
$context
222-
->expects($this->at(5))
223+
->expects(self::once())
223224
->method('createQueue')
224225
->with($this->getDefaultQueueTransportName())
225226
->willReturn($processorWithDefaultQueue)
226227
;
227228
$context
228-
->expects($this->at(6))
229+
->expects(self::once())
229230
->method('declareQueue')
230231
->with($this->identicalTo($processorWithDefaultQueue))
231232
;
232233

233234
$context
234-
->expects($this->at(7))
235+
->expects(self::once())
235236
->method('createQueue')
236237
->with($this->getCustomQueueTransportName())
237238
->willReturn($processorWithCustomQueue)
238239
;
239240
$context
240-
->expects($this->at(8))
241+
->expects(self::once())
241242
->method('declareQueue')
242243
->with($this->identicalTo($processorWithCustomQueue))
243244
;
@@ -290,15 +291,15 @@ protected function createDriver(...$args): DriverInterface
290291
}
291292

292293
/**
293-
* @return AmqpContext
294+
* @return AmqpContext|MockObject
294295
*/
295296
protected function createContextMock(): Context
296297
{
297298
return $this->createMock(AmqpContext::class);
298299
}
299300

300301
/**
301-
* @return AmqpProducer
302+
* @return AmqpProducer|MockObject
302303
*/
303304
protected function createProducerMock(): InteropProducer
304305
{

pkg/enqueue/Tests/Client/Driver/FsDriverTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,23 @@ public function testShouldSetupBroker()
4444
$context = $this->createContextMock();
4545
// setup router
4646
$context
47-
->expects($this->at(0))
47+
->expects(self::once())
4848
->method('createQueue')
4949
->willReturn($routerQueue)
5050
;
5151
$context
52-
->expects($this->at(1))
52+
->expects(self::once())
5353
->method('declareDestination')
5454
->with($this->identicalTo($routerQueue))
5555
;
5656
// setup processor queue
5757
$context
58-
->expects($this->at(2))
58+
->expects(self::once())
5959
->method('createQueue')
6060
->willReturn($processorQueue)
6161
;
6262
$context
63-
->expects($this->at(3))
63+
->expects(self::once())
6464
->method('declareDestination')
6565
->with($this->identicalTo($processorQueue))
6666
;

pkg/enqueue/Tests/Client/Driver/GpsDriverTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,35 +46,35 @@ public function testShouldSetupBroker()
4646
$context = $this->createContextMock();
4747
// setup router
4848
$context
49-
->expects($this->at(0))
49+
->expects(self::once())
5050
->method('createTopic')
5151
->willReturn($routerTopic)
5252
;
5353
$context
54-
->expects($this->at(1))
54+
->expects(self::once())
5555
->method('createQueue')
5656
->willReturn($routerQueue)
5757
;
5858
$context
59-
->expects($this->at(2))
59+
->expects(self::once())
6060
->method('subscribe')
6161
->with($this->identicalTo($routerTopic), $this->identicalTo($routerQueue))
6262
;
6363
$context
64-
->expects($this->at(3))
64+
->expects(self::once())
6565
->method('createQueue')
6666
->with($this->getDefaultQueueTransportName())
6767
->willReturn($processorQueue)
6868
;
6969
// setup processor queue
7070
$context
71-
->expects($this->at(4))
71+
->expects(self::once())
7272
->method('createTopic')
7373
->with($this->getDefaultQueueTransportName())
7474
->willReturn($processorTopic)
7575
;
7676
$context
77-
->expects($this->at(5))
77+
->expects(self::once())
7878
->method('subscribe')
7979
->with($this->identicalTo($processorTopic), $this->identicalTo($processorQueue))
8080
;

pkg/enqueue/Tests/Client/Driver/RabbitMqStompDriverTest.php

+8-8
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ public function shouldSendMessageToDelayExchangeIfDelaySet()
196196

197197
$producer = $this->createProducerMock();
198198
$producer
199-
->expects($this->at(0))
199+
->expects(self::once())
200200
->method('setDeliveryDelay')
201201
->with(10000)
202202
;
203203
$producer
204-
->expects($this->at(1))
204+
->expects(self::once())
205205
->method('setDeliveryDelay')
206206
->with(null)
207207
;
@@ -299,7 +299,7 @@ public function testShouldSetupBroker()
299299

300300
$managementClient = $this->createManagementClientMock();
301301
$managementClient
302-
->expects($this->at(0))
302+
->expects(self::once())
303303
->method('declareExchange')
304304
->with('aprefix.router', [
305305
'type' => 'fanout',
@@ -308,7 +308,7 @@ public function testShouldSetupBroker()
308308
])
309309
;
310310
$managementClient
311-
->expects($this->at(1))
311+
->expects(self::once())
312312
->method('declareQueue')
313313
->with('aprefix.default', [
314314
'durable' => true,
@@ -319,12 +319,12 @@ public function testShouldSetupBroker()
319319
])
320320
;
321321
$managementClient
322-
->expects($this->at(2))
322+
->expects(self::once())
323323
->method('bind')
324324
->with('aprefix.router', 'aprefix.default', 'aprefix.default')
325325
;
326326
$managementClient
327-
->expects($this->at(3))
327+
->expects(self::once())
328328
->method('declareQueue')
329329
->with('aprefix.default', [
330330
'durable' => true,
@@ -399,7 +399,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
399399

400400
$managementClient = $this->createManagementClientMock();
401401
$managementClient
402-
->expects($this->at(4))
402+
->expects(self::once())
403403
->method('declareExchange')
404404
->with('aprefix.default.delayed', [
405405
'type' => 'x-delayed-message',
@@ -411,7 +411,7 @@ public function testSetupBrokerShouldCreateDelayExchangeIfEnabled()
411411
])
412412
;
413413
$managementClient
414-
->expects($this->at(5))
414+
->expects(self::once())
415415
->method('bind')
416416
->with('aprefix.default.delayed', 'aprefix.default', 'aprefix.default')
417417
;

pkg/enqueue/Tests/Client/Driver/RdKafkaDriverTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public function testShouldSetupBroker()
4747
$context = $this->createContextMock();
4848

4949
$context
50-
->expects($this->at(0))
50+
->expects(self::once())
5151
->method('createQueue')
5252
->willReturn($routerTopic)
5353
;
5454
$context
55-
->expects($this->at(1))
55+
->expects(self::once())
5656
->method('createQueue')
5757
->willReturn($routerQueue)
5858
;
5959
$context
60-
->expects($this->at(2))
60+
->expects(self::once())
6161
->method('createQueue')
6262
->willReturn($processorTopic)
6363
;

pkg/enqueue/Tests/Client/Driver/SqsDriverTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ public function testShouldSetupBroker()
4242
$context = $this->createContextMock();
4343
// setup router
4444
$context
45-
->expects($this->at(0))
45+
->expects(self::once())
4646
->method('createQueue')
4747
->with('aprefix_dot_default')
4848
->willReturn($routerQueue)
4949
;
5050
$context
51-
->expects($this->at(1))
51+
->expects(self::once())
5252
->method('declareQueue')
5353
->with($this->identicalTo($routerQueue))
5454
;
5555
// setup processor queue
5656
$context
57-
->expects($this->at(2))
57+
->expects(self::once())
5858
->method('createQueue')
5959
->with('aprefix_dot_default')
6060
->willReturn($processorQueue)
6161
;
6262
$context
63-
->expects($this->at(3))
63+
->expects(self::once())
6464
->method('declareQueue')
6565
->with($this->identicalTo($processorQueue))
6666
;

pkg/enqueue/Tests/Client/ProducerSendCommandTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToBus()
370370
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
371371

372372
$extension
373-
->expects($this->at(0))
373+
->expects(self::once())
374374
->method('onPreSendCommand')
375375
->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) {
376376
$this->assertSame($message, $context->getMessage());
@@ -408,7 +408,7 @@ public function testShouldCallPreSendCommandExtensionMethodWhenSendToApplication
408408
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
409409

410410
$extension
411-
->expects($this->at(0))
411+
->expects(self::once())
412412
->method('onPreSendCommand')
413413
->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) {
414414
$this->assertSame($message, $context->getMessage());
@@ -446,7 +446,7 @@ public function testShouldCallPreDriverSendExtensionMethod()
446446
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
447447

448448
$extension
449-
->expects($this->at(0))
449+
->expects(self::once())
450450
->method('onDriverPreSend')
451451
->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) {
452452
$this->assertSame($message, $context->getMessage());
@@ -478,7 +478,7 @@ public function testShouldCallPostSendExtensionMethod()
478478
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
479479

480480
$extension
481-
->expects($this->at(0))
481+
->expects(self::once())
482482
->method('onDriverPreSend')
483483
->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) {
484484
$this->assertSame($message, $context->getMessage());

pkg/enqueue/Tests/Client/ProducerSendEventTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToBus()
326326
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
327327

328328
$extension
329-
->expects($this->at(0))
329+
->expects(self::once())
330330
->method('onPreSendEvent')
331331
->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) {
332332
$this->assertSame($message, $context->getMessage());
@@ -364,7 +364,7 @@ public function testShouldCallPreSendEventExtensionMethodWhenSendToApplicationRo
364364
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
365365

366366
$extension
367-
->expects($this->at(0))
367+
->expects(self::once())
368368
->method('onPreSendEvent')
369369
->willReturnCallback(function (PreSend $context) use ($message, $producer, $driver) {
370370
$this->assertSame($message, $context->getMessage());
@@ -402,7 +402,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToMessageBus()
402402
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
403403

404404
$extension
405-
->expects($this->at(0))
405+
->expects(self::once())
406406
->method('onDriverPreSend')
407407
->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) {
408408
$this->assertSame($message, $context->getMessage());
@@ -434,7 +434,7 @@ public function testShouldCallPreDriverSendExtensionMethodWhenSendToApplicationR
434434
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
435435

436436
$extension
437-
->expects($this->at(0))
437+
->expects(self::once())
438438
->method('onDriverPreSend')
439439
->willReturnCallback(function (DriverPreSend $context) use ($message, $producer, $driver) {
440440
$this->assertSame($message, $context->getMessage());
@@ -466,7 +466,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToMessageBus()
466466
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
467467

468468
$extension
469-
->expects($this->at(0))
469+
->expects(self::once())
470470
->method('onPostSend')
471471
->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) {
472472
$this->assertSame($message, $context->getMessage());
@@ -498,7 +498,7 @@ public function testShouldCallPostSendExtensionMethodWhenSendToApplicationRouter
498498
$producer = new Producer($driver, $this->createRpcFactoryMock(), $extension);
499499

500500
$extension
501-
->expects($this->at(0))
501+
->expects(self::once())
502502
->method('onDriverPreSend')
503503
->willReturnCallback(function (PostSend $context) use ($message, $producer, $driver) {
504504
$this->assertSame($message, $context->getMessage());

0 commit comments

Comments
 (0)