From 0aab1bdc4e781f9f294ee2e8eff2d945da4282f7 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sun, 4 Dec 2022 20:42:28 +0100 Subject: [PATCH] Added test for findMostRecentOrphanVisit --- .../Visit/Repository/VisitRepositoryTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/module/Core/test-db/Visit/Repository/VisitRepositoryTest.php b/module/Core/test-db/Visit/Repository/VisitRepositoryTest.php index 25512f15..b69190e5 100644 --- a/module/Core/test-db/Visit/Repository/VisitRepositoryTest.php +++ b/module/Core/test-db/Visit/Repository/VisitRepositoryTest.php @@ -491,6 +491,24 @@ class VisitRepositoryTest extends DatabaseTestCase self::assertCount(5, $this->repo->findNonOrphanVisits(new VisitsListFiltering(null, false, null, 5, 5))); } + /** @test */ + public function findMostRecentOrphanVisitReturnsExpectedVisit(): void + { + $this->assertNull($this->repo->findMostRecentOrphanVisit()); + + $lastVisit = Visit::forBasePath(Visitor::emptyInstance()); + $this->getEntityManager()->persist($lastVisit); + $this->getEntityManager()->flush(); + + $this->assertSame($lastVisit, $this->repo->findMostRecentOrphanVisit()); + + $lastVisit2 = Visit::forRegularNotFound(Visitor::botInstance()); + $this->getEntityManager()->persist($lastVisit2); + $this->getEntityManager()->flush(); + + $this->assertSame($lastVisit2, $this->repo->findMostRecentOrphanVisit()); + } + /** * @return array{string, string, \Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl} */