mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Optimized repository tests
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace tests\Unit\Repository;
 | 
			
		||||
namespace tests\Unit\Repository\Meta;
 | 
			
		||||
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
namespace tests\Unit\Repository;
 | 
			
		||||
namespace tests\Unit\Repository\Source;
 | 
			
		||||
 | 
			
		||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
 | 
			
		||||
use Doctrine\ORM\EntityManager;
 | 
			
		||||
		Reference in New Issue
	
	Block a user