Moved duplicated code in visit listeners to an abstract class

This commit is contained in:
Alejandro Celaya
2022-07-27 18:18:36 +02:00
parent 26037327f9
commit e36c4d397c
8 changed files with 133 additions and 155 deletions

View File

@@ -52,8 +52,8 @@ class NotifyVisitToMercureTest extends TestCase
$visitId = '123';
$findVisit = $this->em->find(Visit::class, $visitId)->willReturn(null);
$logWarning = $this->logger->warning(
'Tried to notify mercure for visit with id "{visitId}", but it does not exist.',
['visitId' => $visitId],
'Tried to notify {name} for visit with id "{visitId}", but it does not exist.',
['visitId' => $visitId, 'name' => 'Mercure'],
);
$logDebug = $this->logger->debug(Argument::cetera());
$buildNewShortUrlVisitUpdate = $this->updatesGenerator->newShortUrlVisitUpdate(
@@ -110,8 +110,9 @@ class NotifyVisitToMercureTest extends TestCase
$findVisit = $this->em->find(Visit::class, $visitId)->willReturn($visit);
$logWarning = $this->logger->warning(Argument::cetera());
$logDebug = $this->logger->debug('Error while trying to notify mercure hub with new visit. {e}', [
$logDebug = $this->logger->debug('Error while trying to notify {name} with new visit. {e}', [
'e' => $e,
'name' => 'Mercure',
]);
$buildNewShortUrlVisitUpdate = $this->updatesGenerator->newShortUrlVisitUpdate($visit)->willReturn($update);
$buildNewOrphanVisitUpdate = $this->updatesGenerator->newOrphanVisitUpdate($visit)->willReturn($update);

View File

@@ -79,8 +79,8 @@ class NotifyVisitToRabbitMqTest extends TestCase
$visitId = '123';
$findVisit = $this->em->find(Visit::class, $visitId)->willReturn(null);
$logWarning = $this->logger->warning(
'Tried to notify RabbitMQ for visit with id "{visitId}", but it does not exist.',
['visitId' => $visitId],
'Tried to notify {name} for visit with id "{visitId}", but it does not exist.',
['visitId' => $visitId, 'name' => 'RabbitMQ'],
);
($this->listener)(new VisitLocated($visitId));
@@ -147,8 +147,8 @@ class NotifyVisitToRabbitMqTest extends TestCase
($this->listener)(new VisitLocated($visitId));
$this->logger->debug(
'Error while trying to notify RabbitMQ with new visit. {e}',
['e' => $e],
'Error while trying to notify {name} with new visit. {e}',
['e' => $e, 'name' => 'RabbitMQ'],
)->shouldHaveBeenCalledOnce();
$findVisit->shouldHaveBeenCalledOnce();
$generateUpdate->shouldHaveBeenCalledOnce();