Skip to content

Commit c0789c3

Browse files
lernhart84m
authored andcommitted
Fixed for PHP 8 Compatibility
1 parent 95e06d5 commit c0789c3

12 files changed

+12
-17
lines changed

.github/workflows/phpunit.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
discovery.type: single-node
1717
strategy:
1818
matrix:
19-
php: ['7.3', '7.4']
19+
php: ['7.4', '8.0']
2020
steps:
2121
- uses: actions/checkout@v2
2222

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.3",
14+
"php": "^7.4 || ^8.0",
1515
"symfony/serializer": "^5.0",
1616
"elasticsearch/elasticsearch": "^7.0"
1717
},

src/Serializer/OrderedSerializer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ private function order(array $data)
5959
uasort(
6060
$filteredData,
6161
function (OrderedNormalizerInterface $a, OrderedNormalizerInterface $b) {
62-
return $a->getOrder() > $b->getOrder();
62+
return $a->getOrder() <=> $b->getOrder();
6363
}
6464
);
6565

tests/Unit/Aggregation/Bucketing/AdjacencyMatrixAggregationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testToArray()
6060
{
6161
$aggregation = new AdjacencyMatrixAggregation('test_agg');
6262
$filter = $this->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')
63-
->setMethods(['toArray', 'getType'])
63+
->onlyMethods(['toArray', 'getType'])
6464
->getMockForAbstractClass();
6565
$filter->expects($this->any())
6666
->method('toArray')

tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function getDateRangeAggregationConstructorProvider()
115115
public function testDateRangeAggregationConstructor($field = null, $format = null, array $ranges = null)
116116
{
117117
$aggregation = $this->getMockBuilder('ONGR\ElasticsearchDSL\Aggregation\Bucketing\DateRangeAggregation')
118-
->setMethods(['setField', 'setFormat', 'addRange'])
118+
->onlyMethods(['setField', 'setFormat', 'addRange'])
119119
->disableOriginalConstructor()
120120
->getMock();
121121
$aggregation->expects($this->once())->method('setField')->with($field);

tests/Unit/Aggregation/Bucketing/FiltersAggregationTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testToArray()
6060
{
6161
$aggregation = new FiltersAggregation('test_agg');
6262
$filter = $this->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')
63-
->setMethods(['toArray', 'getType'])
63+
->onlyMethods(['toArray', 'getType'])
6464
->getMockForAbstractClass();
6565
$filter->expects($this->any())
6666
->method('toArray')

tests/Unit/BuilderBagTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public function testGet()
8585
private function getBuilder($name)
8686
{
8787
$friendlyBuilderMock = $this->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')
88-
->setMethods(['getName', 'toArray', 'getType'])
88+
->onlyMethods(['toArray', 'getType'])
89+
->addMethods(['getName'])
8990
->disableOriginalConstructor()
9091
->getMock();
9192

tests/Unit/SearchEndpoint/InnerHitsEndpointTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public function testNormalization()
5454
->getMock();
5555
$innerHit = $this
5656
->getMockBuilder('ONGR\ElasticsearchDSL\BuilderInterface')
57-
->setMethods(['getName', 'toArray', 'getType'])
57+
->onlyMethods(['toArray', 'getType'])
58+
->addMethods(['getName'])
5859
->getMock();
5960
$innerHit->expects($this->any())->method('getName')->willReturn('foo');
6061
$innerHit->expects($this->any())->method('toArray')->willReturn(['foo' => 'bar']);

tests/Unit/SearchEndpoint/SearchEndpointFactoryTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ public function testGet()
3434
*/
3535
public function testFactory()
3636
{
37-
$endpoinnt = SearchEndpointFactory::get(AggregationsEndpoint::NAME);
38-
39-
$this->assertInstanceOf(SearchEndpointInterface::class, $endpoinnt);
37+
$endpoint = SearchEndpointFactory::get(AggregationsEndpoint::NAME);
38+
$this->assertInstanceOf(SearchEndpointInterface::class, $endpoint);
4039
}
4140
}

tests/Unit/Sort/FieldSortTest.php

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class FieldSortTest extends \PHPUnit\Framework\TestCase
1919
{
2020
/**
2121
* Test for toArray() method.
22-
*
2322
*/
2423
public function testToArray()
2524
{

tests/Unit/Sort/NestedSortTest.php

-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class NestedSortTest extends \PHPUnit\Framework\TestCase
1818
{
1919
/**
2020
* Test for single nested.
21-
*
2221
*/
2322
public function testSingle()
2423
{
@@ -37,7 +36,6 @@ public function testSingle()
3736

3837
/**
3938
* Test for single nested, no filter.
40-
*
4139
*/
4240
public function testNoFilter()
4341
{
@@ -51,7 +49,6 @@ public function testNoFilter()
5149

5250
/**
5351
* Test for single nested.
54-
*
5552
*/
5653
public function testMultipleNesting()
5754
{

tests/Unit/Suggest/SuggestTest.php

-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ public function testSuggestGetType()
2626

2727
/**
2828
* Data provider for testToArray()
29-
*
30-
* @return array[]
3129
*/
3230
public function getTestToArrayData()
3331
{

0 commit comments

Comments
 (0)