tests on new ActiveOnDate and ActiveOneDayBetweenDates filters

This commit is contained in:
Mathieu Jaumotte 2022-08-01 11:37:41 +02:00
parent e3743d3593
commit 28599adf48
2 changed files with 131 additions and 0 deletions

View File

@ -0,0 +1,65 @@
<?php
namespace Chill\PersonBundle\Tests\Export\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\ActiveOnDateFilter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
class ActiveOnDateFilterTest extends AbstractFilterTest
{
private ActiveOnDateFilter $filter;
protected function setUp(): void
{
//parent::setUp();
self::bootKernel();
// add a fake request with a default locale (used in translatable string)
$request = $this->prophesize();
$request->willExtend(Request::class);
$request->getLocale()->willReturn('fr');
$this->filter = self::$container->get('chill.person.export.filter_activeondate');
}
/**
* @inheritDoc
*/
public function getFilter()
{
return $this->filter;
}
/**
* @inheritDoc
*/
public function getFormData(): array
{
return [
[
'on_date' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
],
];
}
/**
* @inheritDoc
*/
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
->select('acp.id'),
];
}
}

View File

@ -0,0 +1,66 @@
<?php
namespace Chill\PersonBundle\Tests\Export\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\PersonBundle\Export\Filter\ActiveOneDayBetweenDatesFilter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\Request;
class ActiveOneDayBetweenDatesFilterTest extends AbstractFilterTest
{
private ActiveOneDayBetweenDatesFilter $filter;
protected function setUp(): void
{
//parent::setUp();
self::bootKernel();
// add a fake request with a default locale (used in translatable string)
$request = $this->prophesize();
$request->willExtend(Request::class);
$request->getLocale()->willReturn('fr');
$this->filter = self::$container->get('chill.person.export.filter_activeonedaybetweendates');
}
/**
* @inheritDoc
*/
public function getFilter()
{
return $this->filter;
}
/**
* @inheritDoc
*/
public function getFormData(): array
{
return [
[
'date_from' => \DateTime::createFromFormat('Y-m-d', '2022-05-01'),
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-06-01'),
],
];
}
/**
* @inheritDoc
*/
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->from('ChillPersonBundle:AccompanyingPeriod', 'acp')
->select('acp.id'),
];
}
}