mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix countable in php 7.2
in PHP 7.2, count does not allow null value or not countable object. This commit adapt the use of count to the nature of the object
This commit is contained in:
parent
c593c153a1
commit
7b4c728523
@ -213,7 +213,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||
count($query->getDQLPart('from')) : 0;
|
||||
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
||||
count($query->getDQLPart('where')) : 0;
|
||||
$query->getDQLPart('where')->count() : 0;
|
||||
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
||||
count($query->getDQLPart('select')) : 0;
|
||||
|
||||
@ -226,7 +226,7 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
altered the query");
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfWhere,
|
||||
$query->getDQLPart('where') !== null ? count($query->getDQLPart('where')) : 0,
|
||||
$query->getDQLPart('where') !== null ? $query->getDQLPart('where')->count() : 0,
|
||||
"Test that there are equal or more 'where' clause after that the filter has"
|
||||
. "altered the query");
|
||||
$this->assertGreaterThanOrEqual(
|
||||
|
@ -104,20 +104,32 @@ abstract class AbstractFilterTest extends KernelTestCase
|
||||
public function testAlterQuery(QueryBuilder $query, $data)
|
||||
{
|
||||
// retains informations about query
|
||||
$nbOfFrom = count($query->getDQLPart('from'));
|
||||
$nbOfWhere = count($query->getDQLPart('where'));
|
||||
$nbOfSelect = count($query->getDQLPart('select'));
|
||||
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||
count($query->getDQLPart('from')) : 0;
|
||||
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
||||
$query->getDQLPart('where')->count() : 0;
|
||||
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
||||
count($query->getDQLPart('select')) : 0;
|
||||
|
||||
$this->getFilter()->alterQuery($query, $data);
|
||||
|
||||
$this->assertGreaterThanOrEqual($nbOfFrom, count($query->getDQLPart('from')),
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfFrom,
|
||||
$query->getDQLPart('from') !== null ? count($query->getDQLPart('from')) : 0,
|
||||
"Test that there are equal or more 'from' clause after that the filter has
|
||||
altered the query");
|
||||
$this->assertGreaterThanOrEqual($nbOfWhere, count($query->getDQLPart('where')),
|
||||
altered the query"
|
||||
);
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfWhere,
|
||||
$query->getDQLPart('where') !== null ? count($query->getDQLPart('where')) : 0,
|
||||
"Test that there are equal or more 'where' clause after that the filter has"
|
||||
. "altered the query");
|
||||
$this->assertEquals($nbOfSelect, count($query->getDQLPart('select')),
|
||||
"Test that the filter has no altered the 'select' part of the query");
|
||||
. "altered the query"
|
||||
);
|
||||
$this->assertEquals(
|
||||
$nbOfSelect,
|
||||
$query->getDQLPart('select') !== null ? count($query->getDQLPart('select')) : 0,
|
||||
"Test that the filter has no altered the 'select' part of the query"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user