Split some logic from VisitRepository into its own injectable repository

This commit is contained in:
Alejandro Celaya
2022-12-14 12:28:23 +01:00
parent 425d8f0a3f
commit 73c8b53882
11 changed files with 182 additions and 144 deletions

View File

@@ -15,7 +15,7 @@ use Shlinkio\Shlink\Core\Visit\Entity\VisitLocation;
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitGeolocationHelperInterface;
use Shlinkio\Shlink\Core\Visit\Geolocation\VisitLocator;
use Shlinkio\Shlink\Core\Visit\Model\Visitor;
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepositoryInterface;
use Shlinkio\Shlink\Core\Visit\Repository\VisitLocationRepositoryInterface;
use Shlinkio\Shlink\IpGeolocation\Model\Location;
use function count;
@@ -28,15 +28,14 @@ class VisitLocatorTest extends TestCase
{
private VisitLocator $visitService;
private MockObject & EntityManager $em;
private MockObject & VisitRepositoryInterface $repo;
private MockObject & VisitLocationRepositoryInterface $repo;
protected function setUp(): void
{
$this->em = $this->createMock(EntityManager::class);
$this->repo = $this->createMock(VisitRepositoryInterface::class);
$this->em->method('getRepository')->with(Visit::class)->willReturn($this->repo);
$this->repo = $this->createMock(VisitLocationRepositoryInterface::class);
$this->visitService = new VisitLocator($this->em);
$this->visitService = new VisitLocator($this->em, $this->repo);
}
/**
@@ -103,7 +102,7 @@ class VisitLocatorTest extends TestCase
$this->visitService->{$serviceMethodName}(
new class ($isNonLocatableAddress) implements VisitGeolocationHelperInterface {
public function __construct(private bool $isNonLocatableAddress)
public function __construct(private readonly bool $isNonLocatableAddress)
{
}