mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
report export test
This commit is contained in:
parent
eb112b8a85
commit
5b3cd9eb20
@ -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')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: chill.export_elements_provider, prefix: 'report' }
|
- { name: chill.export_elements_provider, prefix: 'report' }
|
||||||
|
|
||||||
Chill\ReportBundle\Export\Filter\ReportDateFilter:
|
chill.report.export.filter_date:
|
||||||
|
class: Chill\ReportBundle\Export\Filter\ReportDateFilter
|
||||||
tags:
|
tags:
|
||||||
- { name: chill.export_filter, alias: 'report_date' }
|
- { name: chill.export_filter, alias: 'report_date_filter' }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user