[Messenger] add redeliveredAt in RedeliveryStamp construct

This commit is contained in:
Quentin Dreyer 2020-07-02 13:00:38 +02:00 committed by Fabien Potencier
parent ad94b395d0
commit 64d26836da
2 changed files with 8 additions and 2 deletions

View File

@ -24,12 +24,12 @@ final class RedeliveryStamp implements StampInterface
private $exceptionMessage;
private $flattenException;
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null)
public function __construct(int $retryCount, string $exceptionMessage = null, FlattenException $flattenException = null, \DateTimeImmutable $redeliveredAt = null)
{
$this->retryCount = $retryCount;
$this->exceptionMessage = $exceptionMessage;
$this->flattenException = $flattenException;
$this->redeliveredAt = new \DateTimeImmutable();
$this->redeliveredAt = $redeliveredAt ?? new \DateTimeImmutable();
}
public static function getRetryCountFromEnvelope(Envelope $envelope): int

View File

@ -33,4 +33,10 @@ class RedeliveryStampTest extends TestCase
$this->assertSame('exception message', $stamp->getExceptionMessage());
$this->assertSame($flattenException, $stamp->getFlattenException());
}
public function testSerialization()
{
$stamp = new RedeliveryStamp(10, null, null, \DateTimeImmutable::createFromFormat(\DateTimeInterface::ISO8601, '2005-08-15T15:52:01+0000'));
$this->assertSame('2005-08-15T15:52:01+0000', $stamp->getRedeliveredAt()->format(\DateTimeInterface::ISO8601));
}
}