From c03eea789c76cf4d7c11b11137d1068cb386616b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 21 Nov 2023 08:25:58 +0100 Subject: [PATCH] Fix LocateVisitTest --- module/Core/test/EventDispatcher/LocateVisitTest.php | 4 +++- .../test/EventDispatcher/Matomo/SendVisitToMatomoTest.php | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/module/Core/test/EventDispatcher/LocateVisitTest.php b/module/Core/test/EventDispatcher/LocateVisitTest.php index 21c3bf1d..ddadde84 100644 --- a/module/Core/test/EventDispatcher/LocateVisitTest.php +++ b/module/Core/test/EventDispatcher/LocateVisitTest.php @@ -168,7 +168,9 @@ class LocateVisitTest extends TestCase $location, ); - $this->eventDispatcher->expects($this->once())->method('dispatch')->with(new VisitLocated('123')); + $this->eventDispatcher->expects($this->once())->method('dispatch')->with( + new VisitLocated('123', $originalIpAddress), + ); $this->logger->expects($this->never())->method('warning'); ($this->locateVisit)($event); diff --git a/module/Core/test/EventDispatcher/Matomo/SendVisitToMatomoTest.php b/module/Core/test/EventDispatcher/Matomo/SendVisitToMatomoTest.php index 154c7943..b76a1d31 100644 --- a/module/Core/test/EventDispatcher/Matomo/SendVisitToMatomoTest.php +++ b/module/Core/test/EventDispatcher/Matomo/SendVisitToMatomoTest.php @@ -160,13 +160,10 @@ class SendVisitToMatomoTest extends TestCase $visitId = '123'; $e = new Exception('Error!'); - $tracker = $this->createMock(MatomoTracker::class); - $tracker->expects($this->once())->method('setUrl')->willThrowException($e); - $this->em->expects($this->once())->method('find')->with(Visit::class, $visitId)->willReturn( $this->createMock(Visit::class), ); - $this->trackerBuilder->expects($this->once())->method('buildMatomoTracker')->willReturn($tracker); + $this->trackerBuilder->expects($this->once())->method('buildMatomoTracker')->willThrowException($e); $this->logger->expects($this->never())->method('warning'); $this->logger->expects($this->once())->method('error')->with( 'An error occurred while trying to send visit to Matomo. {e}',