From 7b4c7285233983277a04b747a1d79fcfa0c841a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 4 Apr 2018 17:00:57 +0200 Subject: [PATCH] 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 --- Test/Export/AbstractAggregatorTest.php | 4 ++-- Test/Export/AbstractFilterTest.php | 30 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/Test/Export/AbstractAggregatorTest.php b/Test/Export/AbstractAggregatorTest.php index a1f0cf60a..d33a6f88d 100644 --- a/Test/Export/AbstractAggregatorTest.php +++ b/Test/Export/AbstractAggregatorTest.php @@ -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( diff --git a/Test/Export/AbstractFilterTest.php b/Test/Export/AbstractFilterTest.php index c16bfb8c0..dd8f5df04 100644 --- a/Test/Export/AbstractFilterTest.php +++ b/Test/Export/AbstractFilterTest.php @@ -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" + ); }