Skip to content

Commit 057642e

Browse files
committed
update to support the symfony serializer 5.0
1 parent 97136d3 commit 057642e

21 files changed

+56
-32
lines changed

.phpunit.result.cache

+1
Large diffs are not rendered by default.

.travis.yml

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
sudo: false
22
language: php
33
php:
4+
- 7.0
45
- 7.1
56
- 7.2
67
- 7.3
7-
- 7.4snapshot
8-
matrix:
9-
allow_failures:
10-
- php: 7.4snapshot
8+
- 7.4
119
env:
1210
global:
13-
- ES_VERSION=7.4.0 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
11+
- ES_VERSION=6.7.1 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
1412
install:
1513
- wget ${ES_DOWNLOAD_URL}
16-
- tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
14+
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
1715
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
1816
before_script:
1917
- if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require-dev": {
1919
"elasticsearch/elasticsearch": "^6.0",
20-
"phpunit/phpunit": "~6.0",
20+
"phpunit/phpunit": "^7.0",
2121
"squizlabs/php_codesniffer": "^3.0"
2222
},
2323
"suggest": {

src/SearchEndpoint/AggregationsEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class AggregationsEndpoint extends AbstractSearchEndpoint
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
30+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
3131
{
3232
$output = [];
3333
if (count($this->getAll()) > 0) {

src/SearchEndpoint/HighlightEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class HighlightEndpoint extends AbstractSearchEndpoint
3737
/**
3838
* {@inheritdoc}
3939
*/
40-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
40+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
4141
{
4242
if ($this->highlight) {
4343
return $this->highlight->toArray();

src/SearchEndpoint/InnerHitsEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class InnerHitsEndpoint extends AbstractSearchEndpoint
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
30+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
3131
{
3232
$output = [];
3333
if (count($this->getAll()) > 0) {

src/SearchEndpoint/PostFilterEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PostFilterEndpoint extends QueryEndpoint
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
29+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
3030
{
3131
if (!$this->getBool()) {
3232
return null;

src/SearchEndpoint/QueryEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI
3939
/**
4040
* {@inheritdoc}
4141
*/
42-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
42+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
4343
{
4444
if (!$this->filtersSet && $this->hasReference('filter_query')) {
4545
/** @var BuilderInterface $filter */

src/SearchEndpoint/SortEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SortEndpoint extends AbstractSearchEndpoint
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
29+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
3030
{
3131
$output = [];
3232

src/SearchEndpoint/SuggestEndpoint.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class SuggestEndpoint extends AbstractSearchEndpoint
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
30+
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
3131
{
3232
$output = [];
3333
if (count($this->getAll()) > 0) {

src/Serializer/Normalizer/CustomReferencedNormalizer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CustomReferencedNormalizer extends CustomNormalizer
2626
/**
2727
* {@inheritdoc}
2828
*/
29-
public function normalize($object, $format = null, array $context = [])
29+
public function normalize($object, string $format = null, array $context = [])
3030
{
3131
$object->setReferences($this->references);
3232
$data = parent::normalize($object, $format, $context);
@@ -38,7 +38,7 @@ public function normalize($object, $format = null, array $context = [])
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function supportsNormalization($data, $format = null)
41+
public function supportsNormalization($data, string $format = null)
4242
{
4343
return $data instanceof AbstractNormalizable;
4444
}

src/Serializer/OrderedSerializer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class OrderedSerializer extends Serializer
2222
/**
2323
* {@inheritdoc}
2424
*/
25-
public function normalize($data, $format = null, array $context = [])
25+
public function normalize($data, string $format = null, array $context = [])
2626
{
2727
return parent::normalize(
2828
is_array($data) ? $this->order($data) : $data,

tests/Functional/AbstractElasticsearchTestCase.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ abstract class AbstractElasticsearchTestCase extends TestCase
3131
/**
3232
* {@inheritdoc}
3333
*/
34-
protected function setUp()
34+
protected function setUp(): void
3535
{
3636
parent::setUp();
3737

@@ -109,7 +109,7 @@ protected function getDataArray()
109109
/**
110110
* {@inheritdoc}
111111
*/
112-
protected function tearDown()
112+
protected function tearDown(): void
113113
{
114114
parent::tearDown();
115115
$this->deleteIndex();

tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function testDateRangeAggregationGetType()
7373
*
7474
* @return array
7575
*/
76-
public function testDateRangeAggregationConstructorProvider()
76+
public function getDateRangeAggregationConstructorProvider()
7777
{
7878
return [
7979
// Case #0. Minimum arguments.
@@ -112,7 +112,7 @@ public function testDateRangeAggregationConstructorProvider()
112112
* @param string $format
113113
* @param array $ranges
114114
*
115-
* @dataProvider testDateRangeAggregationConstructorProvider
115+
* @dataProvider getDateRangeAggregationConstructorProvider
116116
*/
117117
public function testDateRangeAggregationConstructor($field = null, $format = null, array $ranges = null)
118118
{

tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php

+24-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,18 @@ public function testSetField()
120120
public function testToArrayNoFilter()
121121
{
122122
$aggregation = new FilterAggregation('test_agg');
123-
$aggregation->toArray();
123+
$result = $aggregation->toArray();
124+
125+
$this->assertEquals(
126+
[
127+
'aggregation' => [
128+
'test_agg' => [
129+
'filter' => []
130+
]
131+
]
132+
],
133+
$result
134+
);
124135
}
125136

126137
/**
@@ -129,9 +140,19 @@ public function testToArrayNoFilter()
129140
public function testToArrayWithFilter()
130141
{
131142
$aggregation = new FilterAggregation('test_agg');
132-
133143
$aggregation->setFilter(new ExistsQuery('test'));
134-
$aggregation->toArray();
144+
$result = $aggregation->toArray();
145+
146+
$this->assertEquals(
147+
[
148+
'filter' => [
149+
'exists' => [
150+
'field' => 'test'
151+
]
152+
]
153+
],
154+
$result
155+
);
135156
}
136157

137158
/**

tests/Unit/Aggregation/Bucketing/GeoDistanceAggregationTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testGeoDistanceAggregationAddRangeException()
5858
*
5959
* @return array
6060
*/
61-
public function testGeoDistanceAggregationGetArrayDataProvider()
61+
public function getGeoDistanceAggregationGetArrayDataProvider()
6262
{
6363
$out = [];
6464
$filterData = [
@@ -88,7 +88,7 @@ public function testGeoDistanceAggregationGetArrayDataProvider()
8888
* @param array $filterData
8989
* @param array $expected
9090
*
91-
* @dataProvider testGeoDistanceAggregationGetArrayDataProvider
91+
* @dataProvider getGeoDistanceAggregationGetArrayDataProvider
9292
*/
9393
public function testGeoDistanceAggregationGetArray($filterData, $expected)
9494
{

tests/Unit/Aggregation/Metric/PercentileRanksAggregationTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation;
1313

1414
use ONGR\ElasticsearchDSL\Aggregation\Metric\PercentileRanksAggregation;
15+
use phpDocumentor\Reflection\Types\Void_;
1516

1617
/**
1718
* Percentile ranks aggregation unit tests.
@@ -26,7 +27,7 @@ class PercentileRanksAggregationTest extends \PHPUnit\Framework\TestCase
2627
/**
2728
* Phpunit setup.
2829
*/
29-
public function setUp()
30+
public function setUp(): void
3031
{
3132
$this->agg = new PercentileRanksAggregation('foo');
3233
}

tests/Unit/ParametersTraitTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ParametersTraitTest extends \PHPUnit\Framework\TestCase
2727
/**
2828
* {@inheritdoc}
2929
*/
30-
public function setUp()
30+
public function setUp(): void
3131
{
3232
$this->parametersTraitMock = $this->getMockForTrait('ONGR\ElasticsearchDSL\ParametersTrait');
3333
}

tests/Unit/Query/Compound/FunctionScoreQueryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function addRandomFunctionProvider()
6767
public function testAddRandomFunction($seed, $expectedArray)
6868
{
6969
/** @var MatchAllQuery|MockObject $matchAllQuery */
70-
$matchAllQuery = $this->getMockBuilder('ONGR\ElasticsearchDSL\Query\MatchAllQuery')->getMock();
70+
$matchAllQuery = $this->getMockBuilder(MatchAllQuery::class)->getMock();
7171

7272
$functionScoreQuery = new FunctionScoreQuery($matchAllQuery);
7373
$functionScoreQuery->addRandomFunction($seed);

tests/Unit/SearchEndpoint/HighlightEndpointTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class HighlightEndpointTest extends \PHPUnit\Framework\TestCase
2626
*/
2727
public function testItCanBeInstantiated()
2828
{
29-
$this->assertInstanceOf('ONGR\ElasticsearchDSL\SearchEndpoint\HighlightEndpoint', new HighlightEndpoint());
29+
$this->assertInstanceOf(HighlightEndpoint::class, new HighlightEndpoint());
3030
}
3131

3232
/**
@@ -37,7 +37,7 @@ public function testNormalization()
3737
$instance = new HighlightEndpoint();
3838
/** @var NormalizerInterface|MockObject $normalizerInterface */
3939
$normalizerInterface = $this->getMockForAbstractClass(
40-
'Symfony\Component\Serializer\Normalizer\NormalizerInterface'
40+
NormalizerInterface::class
4141
);
4242

4343
$this->assertNull($instance->normalize($normalizerInterface));

tests/Unit/SearchEndpoint/SearchEndpointFactoryTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use ONGR\ElasticsearchDSL\SearchEndpoint\AggregationsEndpoint;
1515
use ONGR\ElasticsearchDSL\SearchEndpoint\SearchEndpointFactory;
16+
use ONGR\ElasticsearchDSL\SearchEndpoint\SearchEndpointInterface;
1617

1718
/**
1819
* Unit test class for search endpoint factory.
@@ -34,6 +35,8 @@ public function testGet()
3435
*/
3536
public function testFactory()
3637
{
37-
SearchEndpointFactory::get(AggregationsEndpoint::NAME);
38+
$endpoinnt = SearchEndpointFactory::get(AggregationsEndpoint::NAME);
39+
40+
$this->assertInstanceOf(SearchEndpointInterface::class, $endpoinnt);
3841
}
3942
}

0 commit comments

Comments
 (0)