From e2e78df38dcac3c9579ec24e340df6d41f047c0b Mon Sep 17 00:00:00 2001 From: Julio Date: Tue, 7 Sep 2021 15:40:26 +0200 Subject: [PATCH] Tests: Add phpunit tests --- .../Repository/BranchSyncRepository.php | 2 +- .../Repository/BranchSyncRepositoryTest.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/CoreBundle/Repository/BranchSyncRepository.php b/src/CoreBundle/Repository/BranchSyncRepository.php index 3201df1354..3128dde392 100644 --- a/src/CoreBundle/Repository/BranchSyncRepository.php +++ b/src/CoreBundle/Repository/BranchSyncRepository.php @@ -40,7 +40,7 @@ class BranchSyncRepository extends ServiceEntityRepository //$qb->innerJoin('u.courses', 'c'); //@todo check app settings - $qb->addOrderBy('b.branchName ASC'); + $qb->addOrderBy('b.branchName', 'ASC'); $qb->where('b.branchName LIKE :keyword'); $qb->setParameter('keyword', "%$keyword%", Types::STRING); $q = $qb->getQuery(); diff --git a/tests/CoreBundle/Repository/BranchSyncRepositoryTest.php b/tests/CoreBundle/Repository/BranchSyncRepositoryTest.php index 1de687cd66..76aebbd49b 100644 --- a/tests/CoreBundle/Repository/BranchSyncRepositoryTest.php +++ b/tests/CoreBundle/Repository/BranchSyncRepositoryTest.php @@ -33,4 +33,22 @@ class BranchSyncRepositoryTest extends AbstractApiTest // By default there's a root branch. $this->assertSame(2, $repo->count([])); } + + public function testSearchByKeyword(): void + { + $repo = self::getContainer()->get(BranchSyncRepository::class); + + $em = $this->getManager(); + $item = (new BranchSync()) + ->setBranchName('Branch') + ->setAdminName('Julio') + ; + $this->assertHasNoEntityViolations($item); + $em->persist($item); + $em->flush(); + + $items = $repo->searchByKeyword('Branch'); + + $this->assertSame(1, \count($items)); + } }