mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
Add new Abstract Filter Test to check qb aliases (for join clauses)
This commit is contained in:
parent
eb6efcefd8
commit
ccedebda90
@ -55,6 +55,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.
|
||||
*
|
||||
@ -198,4 +210,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user