Added database test for Domainrepository

This commit is contained in:
Alejandro Celaya 2020-09-27 10:18:49 +02:00
parent 24aab5cc0e
commit 614e1c37f8
2 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace ShlinkioTest\Shlink\Core\Domain\Repository;
use Shlinkio\Shlink\Core\Domain\Repository\DomainRepository;
use Shlinkio\Shlink\Core\Entity\Domain;
use Shlinkio\Shlink\TestUtils\DbTest\DatabaseTestCase;
class DomainRepositoryTest extends DatabaseTestCase
{
protected const ENTITIES_TO_EMPTY = [Domain::class];
private DomainRepository $repo;
protected function setUp(): void
{
$this->repo = $this->getEntityManager()->getRepository(Domain::class);
}
/** @test */
public function findDomainsReturnsExpectedResult(): void
{
$fooDomain = new Domain('foo.com');
$barDomain = new Domain('bar.com');
$bazDomain = new Domain('baz.com');
$this->getEntityManager()->persist($fooDomain);
$this->getEntityManager()->persist($barDomain);
$this->getEntityManager()->persist($bazDomain);
$this->getEntityManager()->flush();
self::assertEquals([$barDomain, $bazDomain, $fooDomain], $this->repo->findDomainsWithout());
self::assertEquals([$barDomain, $bazDomain], $this->repo->findDomainsWithout('foo.com'));
self::assertEquals([$bazDomain, $fooDomain], $this->repo->findDomainsWithout('bar.com'));
self::assertEquals([$barDomain, $fooDomain], $this->repo->findDomainsWithout('baz.com'));
}
}

View file

@ -23,6 +23,8 @@
<exclude> <exclude>
<directory suffix=".php">./module/Core/src/Repository</directory> <directory suffix=".php">./module/Core/src/Repository</directory>
<directory suffix=".php">./module/Core/src/**/Repository</directory>
<directory suffix=".php">./module/Core/src/**/**/Repository</directory>
</exclude> </exclude>
</whitelist> </whitelist>
</filter> </filter>