infinito/application/symfony/tests/Unit/Repository/Source/SourceRepositoryTest.php

51 lines
1.8 KiB
PHP
Raw Permalink Normal View History

2019-01-16 20:55:49 +01:00
<?php
namespace tests\Unit\Repository\Source;
2020-04-02 21:13:35 +02:00
use Infinito\Domain\Fixture\FixtureSource\ImpressumFixtureSource;
use Infinito\Domain\Request\Entity\RequestedEntityInterface;
2020-04-02 21:13:35 +02:00
use Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Source\SourceInterface;
2020-04-02 21:13:35 +02:00
use Infinito\Repository\Source\SourceRepositoryInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
2019-01-16 20:55:49 +01:00
/**
* @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(RequestedEntityInterface::class);
2019-01-16 20:55:49 +01:00
$requestedSource->method('hasSlug')->willReturn(true);
2019-03-29 23:21:52 +01:00
$requestedSource->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug());
2019-01-16 20:55:49 +01:00
$imprint = $this->sourceRepository->findOneByIdOrSlug($requestedSource);
$this->assertInstanceOf(SourceInterface::class, $imprint);
$requestedSource2 = $this->createMock(RequestedEntityInterface::class);
2019-01-16 20:55:49 +01:00
$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
{
2019-03-29 23:21:52 +01:00
$imprint = $this->sourceRepository->findOneBySlug(ImpressumFixtureSource::getSlug());
2019-01-16 20:55:49 +01:00
$this->assertInstanceOf(SourceInterface::class, $imprint);
}
}