issues/27: add PriceList repository unit tests and integration stub
backend-ci-cd / parse-tag (push) Has been cancelled
backend-ci-cd / test (push) Has been cancelled
backend-ci-cd / test-prod-skip (push) Has been cancelled
backend-ci-cd / build-and-push (push) Has been cancelled
backend-ci-cd / deploy-gitops (push) Has been cancelled
backend-ci-cd / parse-tag (push) Has been cancelled
backend-ci-cd / test (push) Has been cancelled
backend-ci-cd / test-prod-skip (push) Has been cancelled
backend-ci-cd / build-and-push (push) Has been cancelled
backend-ci-cd / deploy-gitops (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Integration\Repository;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Integration tests for specialist filters (PostgreSQL in CI on *-test tags).
|
||||||
|
*/
|
||||||
|
final class SpecialistRepositoryTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
public function testPlaceholderUntilMigrationsInCi(): void
|
||||||
|
{
|
||||||
|
self::markTestSkipped('Month 2: enable after doctrine migrations in Gitea runner PostgreSQL service.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Tests\Unit\Repository;
|
||||||
|
|
||||||
|
use App\Entity\PriceList;
|
||||||
|
use App\Repository\PriceListRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||||
|
use Doctrine\Persistence\ManagerRegistry;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit-level checks for PriceListRepository filter DQL (no DB execution).
|
||||||
|
*/
|
||||||
|
final class PriceListRepositoryFilterTest extends TestCase
|
||||||
|
{
|
||||||
|
private PriceListRepository $repository;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$em = $this->createMock(EntityManagerInterface::class);
|
||||||
|
$em->method('getClassMetadata')
|
||||||
|
->with(PriceList::class)
|
||||||
|
->willReturn(new ClassMetadata(PriceList::class));
|
||||||
|
|
||||||
|
$registry = $this->createMock(ManagerRegistry::class);
|
||||||
|
$registry->method('getManagerForClass')
|
||||||
|
->with(PriceList::class)
|
||||||
|
->willReturn($em);
|
||||||
|
|
||||||
|
$this->repository = new PriceListRepository($registry);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFilialFilterInDql(): void
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createFilteredQueryBuilder(['filial' => 12]);
|
||||||
|
self::assertStringContainsString('filial', $qb->getDQL());
|
||||||
|
self::assertStringContainsString(':filial', $qb->getDQL());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSearchFilterInDql(): void
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createFilteredQueryBuilder(['search' => 'therapy']);
|
||||||
|
self::assertStringContainsString('schname', $qb->getDQL());
|
||||||
|
self::assertStringContainsString(':search', $qb->getDQL());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testKodoperArrayFilterInDql(): void
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createFilteredQueryBuilder(['kodoper' => ['A01', 'B02']]);
|
||||||
|
self::assertStringContainsString('kodoper', $qb->getDQL());
|
||||||
|
self::assertStringContainsString(':codes', $qb->getDQL());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIgnoresEmptyFilters(): void
|
||||||
|
{
|
||||||
|
$qb = $this->repository->createFilteredQueryBuilder(['search' => '', 'filial' => '']);
|
||||||
|
self::assertStringNotContainsString(':search', $qb->getDQL());
|
||||||
|
self::assertStringNotContainsString(':filial', $qb->getDQL());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user