Merge branch '111_exports_suite' of gitlab.com:Chill-Projet/chill-bundles into 111_exports_suite

This commit is contained in:
Mathieu Jaumotte 2022-10-10 18:27:02 +02:00
commit fd24ba618d
2 changed files with 73 additions and 0 deletions

View File

@ -63,6 +63,18 @@ abstract class AbstractAggregatorTest extends KernelTestCase
}
}
/**
* provide data for `testAliasDidNotDisappears`.
*/
public function dataProviderAliasDidNotDisappears()
{
foreach ($this->getQueryBuilders() as $qb) {
foreach ($this->getFormData() as $data) {
yield [clone $qb, $data];
}
}
}
/**
* Create an aggregator instance which will be used in tests.
*
@ -257,4 +269,29 @@ abstract class AbstractAggregatorTest extends KernelTestCase
'test that the title is not empty'
);
}
/**
* Compare aliases array before and after that aggregator alter query
*
* @dataProvider dataProviderAliasDidNotDisappears
*
* @param QueryBuilder $qb
* @param array $data
* @return void
*/
public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
{
$aliases = $qb->getAllAliases();
$this->getAggregator()->alterQuery($qb, $data);
$alteredQuery = $qb->getAllAliases();
$this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
foreach ($aliases as $alias) {
$this->assertContains($alias, $alteredQuery);
}
}
}

View File

@ -56,6 +56,18 @@ abstract class AbstractFilterTest extends KernelTestCase
}
}
/**
* provide data for `testAliasDidNotDisappears`.
*/
public function dataProviderAliasDidNotDisappears()
{
foreach ($this->getQueryBuilders() as $qb) {
foreach ($this->getFormData() as $data) {
yield [clone $qb, $data];
}
}
}
/**
* Create a filter which will be used in tests.
*
@ -199,4 +211,28 @@ abstract class AbstractFilterTest extends KernelTestCase
'test that the title is not empty'
);
}
/**
* Compare aliases array before and after that filter alter query
*
* @dataProvider dataProviderAliasDidNotDisappears
*
* @param QueryBuilder $qb
* @param array $data
* @return void
*/
public function testAliasDidNotDisappears(QueryBuilder $qb, array $data)
{
$aliases = $qb->getAllAliases();
$this->getFilter()->alterQuery($qb, $data);
$alteredQuery = $qb->getAllAliases();
$this->assertGreaterThanOrEqual(count($aliases), count($alteredQuery));
foreach ($aliases as $alias) {
$this->assertContains($alias, $alteredQuery);
}
}
}