Skip to content

Commit 99aae50

Browse files
plantasfabpot
authored andcommitted
[BeanstalkMessenger] Round delay to an integer to avoid deprecation warning
1 parent c439a58 commit 99aae50

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Tests/Transport/ConnectionTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,25 @@ public function testSendWhenABeanstalkdExceptionOccurs()
330330

331331
$connection->send($body, $headers, $delay);
332332
}
333+
334+
public function testSendWithRoundedDelay()
335+
{
336+
$tube = 'xyz';
337+
$body = 'foo';
338+
$headers = ['test' => 'bar'];
339+
$delay = 920;
340+
$expectedDelay = 0;
341+
342+
$client = $this->createMock(PheanstalkInterface::class);
343+
$client->expects($this->once())->method('useTube')->with($tube)->willReturn($client);
344+
$client->expects($this->once())->method('put')->with(
345+
$this->anything(),
346+
$this->anything(),
347+
$expectedDelay,
348+
$this->anything(),
349+
);
350+
351+
$connection = new Connection(['tube_name' => $tube], $client);
352+
$connection->send($body, $headers, $delay);
353+
}
333354
}

src/Symfony/Component/Messenger/Bridge/Beanstalkd/Transport/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function send(string $body, array $headers, int $delay = 0): string
123123
$job = $this->client->useTube($this->tube)->put(
124124
$message,
125125
PheanstalkInterface::DEFAULT_PRIORITY,
126-
$delay / 1000,
126+
(int) ($delay / 1000),
127127
$this->ttr
128128
);
129129
} catch (Exception $exception) {

0 commit comments

Comments
 (0)