mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
tests on new ActiveOnDate and ActiveOneDayBetweenDates filters
This commit is contained in:
parent
e3743d3593
commit
28599adf48
@ -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'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -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'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user