Update to doctrine ORM 3.0

This commit is contained in:
Alejandro Celaya
2024-02-17 10:21:36 +01:00
parent e919901487
commit e073b4331a
18 changed files with 56 additions and 55 deletions

View File

@@ -11,11 +11,11 @@ use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepositoryInterface;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepository;
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use Shlinkio\Shlink\Core\ShortUrl\Resolver\PersistenceShortUrlRelationResolver;
use Shlinkio\Shlink\Core\Tag\Entity\Tag;
use Shlinkio\Shlink\Core\Tag\Repository\TagRepositoryInterface;
use Shlinkio\Shlink\Core\Tag\Repository\TagRepository;
use function count;
@@ -50,7 +50,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
#[Test, DataProvider('provideFoundDomains')]
public function findsOrCreatesDomainWhenValueIsProvided(?Domain $foundDomain, string $authority): void
{
$repo = $this->createMock(DomainRepositoryInterface::class);
$repo = $this->createMock(DomainRepository::class);
$repo->expects($this->once())->method('findOneBy')->with(['authority' => $authority])->willReturn($foundDomain);
$this->em->expects($this->once())->method('getRepository')->with(Domain::class)->willReturn($repo);
@@ -78,7 +78,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
// One of the tags will already exist. The rest will be new
$expectedPersistedTags = $expectedLookedOutTags - 1;
$tagRepo = $this->createMock(TagRepositoryInterface::class);
$tagRepo = $this->createMock(TagRepository::class);
$tagRepo->expects($this->exactly($expectedLookedOutTags))->method('findOneBy')->with(
$this->isType('array'),
)->willReturnCallback(function (array $criteria): ?Tag {
@@ -116,7 +116,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
#[Test]
public function newDomainsAreMemoizedUntilStateIsCleared(): void
{
$repo = $this->createMock(DomainRepositoryInterface::class);
$repo = $this->createMock(DomainRepository::class);
$repo->expects($this->exactly(3))->method('findOneBy')->with($this->isType('array'))->willReturn(null);
$this->em->method('getRepository')->with(Domain::class)->willReturn($repo);
@@ -135,7 +135,7 @@ class PersistenceShortUrlRelationResolverTest extends TestCase
#[Test]
public function newTagsAreMemoizedUntilStateIsCleared(): void
{
$tagRepo = $this->createMock(TagRepositoryInterface::class);
$tagRepo = $this->createMock(TagRepository::class);
$tagRepo->expects($this->exactly(6))->method('findOneBy')->with($this->isType('array'))->willReturn(null);
$this->em->method('getRepository')->with(Tag::class)->willReturn($tagRepo);

View File

@@ -18,7 +18,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlCreation;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Core\ShortUrl\Model\ShortUrlMode;
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepository;
use Shlinkio\Shlink\Core\ShortUrl\ShortUrlResolver;
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
use Shlinkio\Shlink\Core\Visit\Model\Visitor;
@@ -32,12 +32,12 @@ class ShortUrlResolverTest extends TestCase
{
private ShortUrlResolver $urlResolver;
private MockObject & EntityManagerInterface $em;
private MockObject & ShortUrlRepositoryInterface $repo;
private MockObject & ShortUrlRepository $repo;
protected function setUp(): void
{
$this->em = $this->createMock(EntityManagerInterface::class);
$this->repo = $this->createMock(ShortUrlRepositoryInterface::class);
$this->repo = $this->createMock(ShortUrlRepository::class);
$this->urlResolver = new ShortUrlResolver($this->em, new UrlShortenerOptions());
}