diff --git a/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php b/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php index c3858d0506f45144fc0d1d8e6f01d5ef00375463..13b0c8fc90363abb0a238172ba2adc097774515f 100644 --- a/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php +++ b/tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php @@ -121,7 +121,13 @@ class DateRangeAggregationTest extends \PHPUnit_Framework_TestCase ->getMock(); $aggregation->expects($this->once())->method('setField')->with($field); $aggregation->expects($this->once())->method('setFormat')->with($format); - $aggregation->expects($this->exactly(count($ranges ?? [])))->method('addRange'); + + if ($ranges) { + $rangesCount = count($ranges); + } else { + $rangesCount = 0; + } + $aggregation->expects($this->exactly($rangesCount))->method('addRange'); if ($field !== null) { if ($format !== null) {