mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-22 15:43:51 +00:00
fix tests implementing AbstractAggregatorTest
This commit is contained in:
@@ -24,8 +24,6 @@ use function is_string;
|
||||
|
||||
/**
|
||||
* Helper which creates a set of test for aggregators.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
{
|
||||
@@ -34,9 +32,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
*/
|
||||
public function dataProviderAliasDidNotDisappears()
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
if (!is_array($datas)) {
|
||||
$datas = iterator_to_array($datas);
|
||||
}
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,9 +54,38 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
*/
|
||||
public function dataProviderAlterQuery()
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
if (!is_array($datas)) {
|
||||
$datas = iterator_to_array($datas);
|
||||
}
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function dataProviderQueryExecution(): iterable
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
if (!is_array($datas)) {
|
||||
$datas = iterator_to_array($datas);
|
||||
}
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +95,13 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
*/
|
||||
public function dataProviderGetQueryKeys()
|
||||
{
|
||||
foreach ($this->getFormData() as $data) {
|
||||
$datas = $this->getFormData();
|
||||
|
||||
if (!is_array($datas)) {
|
||||
$datas = iterator_to_array($datas);
|
||||
}
|
||||
|
||||
foreach ($datas as $data) {
|
||||
yield [$data];
|
||||
}
|
||||
}
|
||||
@@ -68,9 +111,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
*/
|
||||
public function dataProviderGetResultsAndLabels()
|
||||
{
|
||||
$datas = $this->getFormData();
|
||||
|
||||
if (!is_array($datas)) {
|
||||
$datas = iterator_to_array($datas);
|
||||
}
|
||||
|
||||
foreach ($this->getQueryBuilders() as $qb) {
|
||||
foreach ($this->getFormData() as $data) {
|
||||
yield [clone $qb, $data];
|
||||
if ([] === $datas) {
|
||||
yield [clone $qb, []];
|
||||
} else {
|
||||
foreach ($datas as $data) {
|
||||
yield [clone $qb, $data];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,6 +182,19 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @dataProvider dataProviderQueryExecution
|
||||
*/
|
||||
public function testQueryExecution(QueryBuilder $qb, array $data): void
|
||||
{
|
||||
$this->getAggregator()->alterQuery($qb, $data);
|
||||
|
||||
$actual = $qb->getQuery()->getResult();
|
||||
|
||||
self::assertIsArray($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* test the alteration of query by the filter.
|
||||
*
|
||||
|
Reference in New Issue
Block a user