Skip to content

Commit

Permalink
update to support the symfony serializer 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
saimaz committed Feb 19, 2020
1 parent 97136d3 commit 057642e
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 32 deletions.
1 change: 1 addition & 0 deletions .phpunit.result.cache

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions .travis.yml
@@ -1,19 +1,17 @@
sudo: false
language: php
php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4snapshot
matrix:
allow_failures:
- php: 7.4snapshot
- 7.4
env:
global:
- ES_VERSION=7.4.0 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
- ES_VERSION=6.7.1 ES_DOWNLOAD_URL=https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}.tar.gz
install:
- wget ${ES_DOWNLOAD_URL}
- tar -xzf elasticsearch-${ES_VERSION}-linux-x86_64.tar.gz
- tar -xzf elasticsearch-${ES_VERSION}.tar.gz
- ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d
before_script:
- if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -17,7 +17,7 @@
},
"require-dev": {
"elasticsearch/elasticsearch": "^6.0",
"phpunit/phpunit": "~6.0",
"phpunit/phpunit": "^7.0",
"squizlabs/php_codesniffer": "^3.0"
},
"suggest": {
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/AggregationsEndpoint.php
Expand Up @@ -27,7 +27,7 @@ class AggregationsEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/HighlightEndpoint.php
Expand Up @@ -37,7 +37,7 @@ class HighlightEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
if ($this->highlight) {
return $this->highlight->toArray();
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/InnerHitsEndpoint.php
Expand Up @@ -27,7 +27,7 @@ class InnerHitsEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/PostFilterEndpoint.php
Expand Up @@ -26,7 +26,7 @@ class PostFilterEndpoint extends QueryEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
if (!$this->getBool()) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/QueryEndpoint.php
Expand Up @@ -39,7 +39,7 @@ class QueryEndpoint extends AbstractSearchEndpoint implements OrderedNormalizerI
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
if (!$this->filtersSet && $this->hasReference('filter_query')) {
/** @var BuilderInterface $filter */
Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/SortEndpoint.php
Expand Up @@ -26,7 +26,7 @@ class SortEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
$output = [];

Expand Down
2 changes: 1 addition & 1 deletion src/SearchEndpoint/SuggestEndpoint.php
Expand Up @@ -27,7 +27,7 @@ class SuggestEndpoint extends AbstractSearchEndpoint
/**
* {@inheritdoc}
*/
public function normalize(NormalizerInterface $normalizer, $format = null, array $context = [])
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
$output = [];
if (count($this->getAll()) > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/Serializer/Normalizer/CustomReferencedNormalizer.php
Expand Up @@ -26,7 +26,7 @@ class CustomReferencedNormalizer extends CustomNormalizer
/**
* {@inheritdoc}
*/
public function normalize($object, $format = null, array $context = [])
public function normalize($object, string $format = null, array $context = [])
{
$object->setReferences($this->references);
$data = parent::normalize($object, $format, $context);
Expand All @@ -38,7 +38,7 @@ public function normalize($object, $format = null, array $context = [])
/**
* {@inheritdoc}
*/
public function supportsNormalization($data, $format = null)
public function supportsNormalization($data, string $format = null)
{
return $data instanceof AbstractNormalizable;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/OrderedSerializer.php
Expand Up @@ -22,7 +22,7 @@ class OrderedSerializer extends Serializer
/**
* {@inheritdoc}
*/
public function normalize($data, $format = null, array $context = [])
public function normalize($data, string $format = null, array $context = [])
{
return parent::normalize(
is_array($data) ? $this->order($data) : $data,
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/AbstractElasticsearchTestCase.php
Expand Up @@ -31,7 +31,7 @@ abstract class AbstractElasticsearchTestCase extends TestCase
/**
* {@inheritdoc}
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -109,7 +109,7 @@ protected function getDataArray()
/**
* {@inheritdoc}
*/
protected function tearDown()
protected function tearDown(): void
{
parent::tearDown();
$this->deleteIndex();
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Aggregation/Bucketing/DateRangeAggregationTest.php
Expand Up @@ -73,7 +73,7 @@ public function testDateRangeAggregationGetType()
*
* @return array
*/
public function testDateRangeAggregationConstructorProvider()
public function getDateRangeAggregationConstructorProvider()
{
return [
// Case #0. Minimum arguments.
Expand Down Expand Up @@ -112,7 +112,7 @@ public function testDateRangeAggregationConstructorProvider()
* @param string $format
* @param array $ranges
*
* @dataProvider testDateRangeAggregationConstructorProvider
* @dataProvider getDateRangeAggregationConstructorProvider
*/
public function testDateRangeAggregationConstructor($field = null, $format = null, array $ranges = null)
{
Expand Down
27 changes: 24 additions & 3 deletions tests/Unit/Aggregation/Bucketing/FilterAggregationTest.php
Expand Up @@ -120,7 +120,18 @@ public function testSetField()
public function testToArrayNoFilter()
{
$aggregation = new FilterAggregation('test_agg');
$aggregation->toArray();
$result = $aggregation->toArray();

$this->assertEquals(
[
'aggregation' => [
'test_agg' => [
'filter' => []
]
]
],
$result
);
}

/**
Expand All @@ -129,9 +140,19 @@ public function testToArrayNoFilter()
public function testToArrayWithFilter()
{
$aggregation = new FilterAggregation('test_agg');

$aggregation->setFilter(new ExistsQuery('test'));
$aggregation->toArray();
$result = $aggregation->toArray();

$this->assertEquals(
[
'filter' => [
'exists' => [
'field' => 'test'
]
]
],
$result
);
}

/**
Expand Down
Expand Up @@ -58,7 +58,7 @@ public function testGeoDistanceAggregationAddRangeException()
*
* @return array
*/
public function testGeoDistanceAggregationGetArrayDataProvider()
public function getGeoDistanceAggregationGetArrayDataProvider()
{
$out = [];
$filterData = [
Expand Down Expand Up @@ -88,7 +88,7 @@ public function testGeoDistanceAggregationGetArrayDataProvider()
* @param array $filterData
* @param array $expected
*
* @dataProvider testGeoDistanceAggregationGetArrayDataProvider
* @dataProvider getGeoDistanceAggregationGetArrayDataProvider
*/
public function testGeoDistanceAggregationGetArray($filterData, $expected)
{
Expand Down
Expand Up @@ -12,6 +12,7 @@
namespace ONGR\ElasticsearchDSL\Tests\Unit\Metric\Aggregation;

use ONGR\ElasticsearchDSL\Aggregation\Metric\PercentileRanksAggregation;
use phpDocumentor\Reflection\Types\Void_;

/**
* Percentile ranks aggregation unit tests.
Expand All @@ -26,7 +27,7 @@ class PercentileRanksAggregationTest extends \PHPUnit\Framework\TestCase
/**
* Phpunit setup.
*/
public function setUp()
public function setUp(): void
{
$this->agg = new PercentileRanksAggregation('foo');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ParametersTraitTest.php
Expand Up @@ -27,7 +27,7 @@ class ParametersTraitTest extends \PHPUnit\Framework\TestCase
/**
* {@inheritdoc}
*/
public function setUp()
public function setUp(): void
{
$this->parametersTraitMock = $this->getMockForTrait('ONGR\ElasticsearchDSL\ParametersTrait');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Query/Compound/FunctionScoreQueryTest.php
Expand Up @@ -67,7 +67,7 @@ public function addRandomFunctionProvider()
public function testAddRandomFunction($seed, $expectedArray)
{
/** @var MatchAllQuery|MockObject $matchAllQuery */
$matchAllQuery = $this->getMockBuilder('ONGR\ElasticsearchDSL\Query\MatchAllQuery')->getMock();
$matchAllQuery = $this->getMockBuilder(MatchAllQuery::class)->getMock();

$functionScoreQuery = new FunctionScoreQuery($matchAllQuery);
$functionScoreQuery->addRandomFunction($seed);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/SearchEndpoint/HighlightEndpointTest.php
Expand Up @@ -26,7 +26,7 @@ class HighlightEndpointTest extends \PHPUnit\Framework\TestCase
*/
public function testItCanBeInstantiated()
{
$this->assertInstanceOf('ONGR\ElasticsearchDSL\SearchEndpoint\HighlightEndpoint', new HighlightEndpoint());
$this->assertInstanceOf(HighlightEndpoint::class, new HighlightEndpoint());
}

/**
Expand All @@ -37,7 +37,7 @@ public function testNormalization()
$instance = new HighlightEndpoint();
/** @var NormalizerInterface|MockObject $normalizerInterface */
$normalizerInterface = $this->getMockForAbstractClass(
'Symfony\Component\Serializer\Normalizer\NormalizerInterface'
NormalizerInterface::class
);

$this->assertNull($instance->normalize($normalizerInterface));
Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/SearchEndpoint/SearchEndpointFactoryTest.php
Expand Up @@ -13,6 +13,7 @@

use ONGR\ElasticsearchDSL\SearchEndpoint\AggregationsEndpoint;
use ONGR\ElasticsearchDSL\SearchEndpoint\SearchEndpointFactory;
use ONGR\ElasticsearchDSL\SearchEndpoint\SearchEndpointInterface;

/**
* Unit test class for search endpoint factory.
Expand All @@ -34,6 +35,8 @@ public function testGet()
*/
public function testFactory()
{
SearchEndpointFactory::get(AggregationsEndpoint::NAME);
$endpoinnt = SearchEndpointFactory::get(AggregationsEndpoint::NAME);

$this->assertInstanceOf(SearchEndpointInterface::class, $endpoinnt);
}
}

0 comments on commit 057642e

Please sign in to comment.