mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Optimized repository tests
This commit is contained in:
parent
3ca5f3dc36
commit
665f0044cc
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\Unit\Repository;
|
namespace tests\Unit\Repository\Meta;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
use Doctrine\ORM\EntityRepository;
|
use Doctrine\ORM\EntityRepository;
|
@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace tests\Unit\Repository\Source;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
use App\Repository\Source\SourceRepositoryInterface;
|
||||||
|
use App\Entity\Source\AbstractSource;
|
||||||
|
use App\Domain\RequestManagement\RequestedSourceInterface;
|
||||||
|
use App\DBAL\Types\SystemSlugType;
|
||||||
|
use App\Entity\Source\SourceInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class SourceRepositoryTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var SourceRepositoryInterface
|
||||||
|
*/
|
||||||
|
protected $sourceRepository;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$kernel = self::bootKernel();
|
||||||
|
$entityManager = $kernel->getContainer()
|
||||||
|
->get('doctrine')
|
||||||
|
->getManager();
|
||||||
|
$this->sourceRepository = $entityManager->getRepository(AbstractSource::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLoadBySlugOrId(): void
|
||||||
|
{
|
||||||
|
$requestedSource = $this->createMock(RequestedSourceInterface::class);
|
||||||
|
$requestedSource->method('hasSlug')->willReturn(true);
|
||||||
|
$requestedSource->method('getSlug')->willReturn(SystemSlugType::IMPRINT);
|
||||||
|
$imprint = $this->sourceRepository->findOneByIdOrSlug($requestedSource);
|
||||||
|
$this->assertInstanceOf(SourceInterface::class, $imprint);
|
||||||
|
$requestedSource2 = $this->createMock(RequestedSourceInterface::class);
|
||||||
|
$requestedSource2->method('hasId')->willReturn(true);
|
||||||
|
$requestedSource2->method('getId')->willReturn($imprint->getId());
|
||||||
|
$imprint2 = $this->sourceRepository->findOneByIdOrSlug($requestedSource2);
|
||||||
|
$this->assertInstanceOf(SourceInterface::class, $imprint2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLoadBySlug(): void
|
||||||
|
{
|
||||||
|
$imprint = $this->sourceRepository->findOneBySlug(SystemSlugType::IMPRINT);
|
||||||
|
$this->assertInstanceOf(SourceInterface::class, $imprint);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\Unit\Repository;
|
namespace tests\Unit\Repository\Source;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
use Doctrine\ORM\EntityManager;
|
use Doctrine\ORM\EntityManager;
|
Loading…
Reference in New Issue
Block a user