Tests: Add phpunit tests

pull/3965/head
Julio 4 years ago
parent f535685d1a
commit e2e78df38d
  1. 2
      src/CoreBundle/Repository/BranchSyncRepository.php
  2. 18
      tests/CoreBundle/Repository/BranchSyncRepositoryTest.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();

@ -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));
}
}

Loading…
Cancel
Save