report export test

This commit is contained in:
Mathieu Jaumotte 2022-09-21 10:50:12 +02:00
parent eb112b8a85
commit 5b3cd9eb20
2 changed files with 72 additions and 2 deletions

View File

@ -0,0 +1,69 @@
<?php
/**
* 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.
*/
declare(strict_types=1);
namespace Chill\ReportBundle\Tests\Export\Filter;
use Chill\MainBundle\Test\Export\AbstractFilterTest;
use Chill\ReportBundle\Entity\Report;
use Chill\ReportBundle\Export\Filter\ReportDateFilter;
use Doctrine\ORM\EntityManagerInterface;
/**
* @internal
* @coversNothing
*/
final class ReportDateFilterTest extends AbstractFilterTest
{
private ReportDateFilter $filter;
protected function setUp(): void
{
self::bootKernel();
// add a fake request with a default locale (used in translatable string)
$request = $this->prophesize();
$request->willExtend(\Symfony\Component\HttpFoundation\Request::class);
$request->getLocale()->willReturn('fr');
$this->filter = self::$container->get('chill.report.export.filter_date');
}
public function getFilter()
{
return $this->filter;
}
public function getFormData(): array
{
return [
[
'date_from' => \DateTime::createFromFormat('Y-m-d', '2021-07-01'),
'date_to' => \DateTime::createFromFormat('Y-m-d', '2022-07-01'),
]
];
}
public function getQueryBuilders(): array
{
if (null === self::$kernel) {
self::bootKernel();
}
$em = self::$container->get(EntityManagerInterface::class);
return [
$em->createQueryBuilder()
->select('r.id')
->from(Report::class, 'r')
];
}
}

View File

@ -8,6 +8,7 @@ services:
tags:
- { name: chill.export_elements_provider, prefix: 'report' }
Chill\ReportBundle\Export\Filter\ReportDateFilter:
chill.report.export.filter_date:
class: Chill\ReportBundle\Export\Filter\ReportDateFilter
tags:
- { name: chill.export_filter, alias: 'report_date' }
- { name: chill.export_filter, alias: 'report_date_filter' }