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

This commit is contained in:
Valery Petrov
2026-06-04 13:19:02 +03:00
parent 77267619ad
commit b03199f024
2 changed files with 81 additions and 0 deletions
@@ -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());
}
}