bootstrap generic doc manager and associated services

This commit is contained in:
2023-05-23 22:12:18 +02:00
parent 977299192f
commit afcd6e0605
10 changed files with 585 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\DocStoreBundle\Tests\GenericDoc;
use Chill\DocStoreBundle\GenericDoc\Manager;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
/**
* @internal
* @coversNothing
*/
class ManagerTest extends KernelTestCase
{
private Manager $manager;
private EntityManagerInterface $em;
protected function setUp(): void
{
self::bootKernel();
$this->em = self::$container->get(EntityManagerInterface::class);
if (null !== $manager = self::$container->get(Manager::class)) {
$this->manager = $manager;
} else {
throw new \UnexpectedValueException("the manager was not found in the kernel");
}
}
public function testCountByAccompanyingPeriod(): void
{
$period = $this->em->createQuery('SELECT a FROM '.AccompanyingPeriod::class.' a')
->setMaxResults(1)
->getSingleResult();
if (null === $period) {
throw new \UnexpectedValueException("period not found");
}
$nb = $this->manager->countDocForAccompanyingPeriod($period);
self::assertIsInt($nb);
}
}