Skip to content

Commit 6343af9

Browse files
alexandre-dauboisnicolas-grekas
authored andcommitted
[Tests] Remove occurrences of withConsecutive()
1 parent 3525738 commit 6343af9

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

Tests/Transport/ConnectionTest.php

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,29 @@ public function testItSetupsTheConnection()
311311
$amqpExchange->expects($this->once())->method('declareExchange');
312312
$amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]);
313313
$amqpQueue0->expects($this->once())->method('declareQueue');
314-
$amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive(
315-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0'],
316-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key1']
317-
);
314+
$amqpQueue0->expects($this->exactly(2))->method('bind')
315+
->willReturnCallback(function (...$args) {
316+
static $series = [
317+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0', []],
318+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key1', []],
319+
];
320+
321+
$expectedArgs = array_shift($series);
322+
$this->assertSame($expectedArgs, $args);
323+
})
324+
;
318325
$amqpQueue1->expects($this->once())->method('declareQueue');
319-
$amqpQueue1->expects($this->exactly(2))->method('bind')->withConsecutive(
320-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key2'],
321-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key3']
322-
);
326+
$amqpQueue1->expects($this->exactly(2))->method('bind')
327+
->willReturnCallback(function (...$args) {
328+
static $series = [
329+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key2', []],
330+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key3', []],
331+
];
332+
333+
$expectedArgs = array_shift($series);
334+
$this->assertSame($expectedArgs, $args);
335+
})
336+
;
323337

324338
$dsn = 'amqp://localhost?'.
325339
'exchange[default_publish_routing_key]=routing_key&'.
@@ -349,15 +363,29 @@ public function testItSetupsTheTTLConnection()
349363
$amqpExchange->expects($this->once())->method('declareExchange');
350364
$amqpExchange->expects($this->once())->method('publish')->with('body', 'routing_key', \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]);
351365
$amqpQueue0->expects($this->once())->method('declareQueue');
352-
$amqpQueue0->expects($this->exactly(2))->method('bind')->withConsecutive(
353-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0'],
354-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key1']
355-
);
366+
$amqpQueue0->expects($this->exactly(2))->method('bind')
367+
->willReturnCallback(function (...$args) {
368+
static $series = [
369+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key0', []],
370+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key1', []],
371+
];
372+
373+
$expectedArgs = array_shift($series);
374+
$this->assertSame($expectedArgs, $args);
375+
})
376+
;
356377
$amqpQueue1->expects($this->once())->method('declareQueue');
357-
$amqpQueue1->expects($this->exactly(2))->method('bind')->withConsecutive(
358-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key2'],
359-
[self::DEFAULT_EXCHANGE_NAME, 'binding_key3']
360-
);
378+
$amqpQueue1->expects($this->exactly(2))->method('bind')
379+
->willReturnCallback(function (...$args) {
380+
static $series = [
381+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key2', []],
382+
[self::DEFAULT_EXCHANGE_NAME, 'binding_key3', []],
383+
];
384+
385+
$expectedArgs = array_shift($series);
386+
$this->assertSame($expectedArgs, $args);
387+
})
388+
;
361389

362390
$dsn = 'amqps://localhost?'.
363391
'cacert=/etc/ssl/certs&'.
@@ -387,9 +415,7 @@ public function testBindingArguments()
387415
$amqpExchange->expects($this->once())->method('declareExchange');
388416
$amqpExchange->expects($this->once())->method('publish')->with('body', null, \AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2, 'timestamp' => time()]);
389417
$amqpQueue->expects($this->once())->method('declareQueue');
390-
$amqpQueue->expects($this->exactly(1))->method('bind')->withConsecutive(
391-
[self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']]
392-
);
418+
$amqpQueue->expects($this->exactly(1))->method('bind')->with(self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']);
393419

394420
$dsn = 'amqp://localhost?exchange[type]=headers'.
395421
'&queues[queue0][binding_arguments][x-match]=all';

0 commit comments

Comments
 (0)