Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into index-templates-s…
Browse files Browse the repository at this point in the history
…upport

# Conflicts:
#	composer.json
#	src/DependencyInjection/Configuration.php
  • Loading branch information
dbalabka committed Jan 24, 2019
2 parents e227eb3 + 84f5e1c commit 4523775
Show file tree
Hide file tree
Showing 26 changed files with 812 additions and 118 deletions.
16 changes: 3 additions & 13 deletions .travis.yml
Expand Up @@ -15,25 +15,18 @@ matrix:
fast_finish: true
include:
# Minimum supported dependencies with min and max PHP version
- php: 5.6
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
- php: 7.3
- php: 7.1
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"

# Latest supported dependencies with each PHP version
- php: 5.6
- php: 7.0
- php: 7.1
- php: 7.2
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-clover=coverage.clover"
- php: 7.3
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-clover=coverage.clover"

# Install all SF components in the same major version, see https://github.com/dunglas/symfony-lock
- php: 7.2
env: SYMFONY_VERSION="^3"
- php: 7.3
env: SYMFONY_VERSION="^4"

before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
Expand All @@ -51,9 +44,6 @@ install:

before_script:
- phpenv config-add .travis/php.ini
- if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" = "5.6" ]; then composer require --dev --no-update doctrine/mongodb-odm=^1; fi;
- if [ "$TRAVIS_PHP_VERSION" = "7.0" ]; then echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [ "$TRAVIS_PHP_VERSION" = "7.1" ]; then echo "extension = mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;

script:
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG-5.1.md
@@ -0,0 +1,9 @@
CHANGELOG for 5.1.x
===================

This changelog references the relevant changes (bug and security fixes) done
in 5.1 versions.

### 5.1.0 (2019-xx-xx)

* Added compatibility with Symfony 4.2.
7 changes: 4 additions & 3 deletions README.md
Expand Up @@ -31,9 +31,10 @@ The following table shows the compatibilities of different versions of the bundl

| FOSElasticaBundle | Elastica | Elasticsearch | Symfony | PHP |
| --------------------------------------------------------------------------------------- | ---------| ------------- | ---------- | ----- |
| [5.x](https://github.com/FriendsOfSymfony/FOSElasticaBundle/tree/master) | ^5.2\|^6 | 5.\*\|6.\* | ^3.2\|^4 | >=5.6 |
| [4.x](https://github.com/FriendsOfSymfony/FOSElasticaBundle/tree/4.x) (unmaintained) | 3.2.\* | 2.\* | ^2.8\|^3.2 | >=5.5 |
| [3.2.x](https://github.com/FriendsOfSymfony/FOSElasticaBundle/tree/3.2.x) (unmaintained)| ^2.1 | 1.\* | ^2.3\|^3 | >=5.3 |
| [5.1] (master) | ^5.3\|^6 | 5.\*\|6.\* | ^3.4\|^4 | >=7.1 |
| [5.0] (unmaintained) | ^5.2\|^6 | 5.\*\|6.\* | ^3.2\|^4 | >=5.6 |
| [4.x] (unmaintained) | 3.2.\* | 2.\* | ^2.8\|^3.2 | >=5.5 |
| [3.2.x] (unmaintained) | ^2.1 | 1.\* | ^2.3\|^3 | >=5.3 |

License
-------
Expand Down
24 changes: 12 additions & 12 deletions composer.json
Expand Up @@ -12,30 +12,30 @@
{ "name": "Jeremy Mikola", "email": "jmikola@gmail.com" }
],
"require": {
"php": "^5.6.0|^7.0",
"symfony/framework-bundle": "^3.2|^4",
"symfony/console": "^3.2|^4",
"symfony/dependency-injection": "^3.3|^4",
"symfony/property-access": "^3.2|^4",
"php": "^7.1",
"symfony/framework-bundle": "^3.4|^4",
"symfony/console": "^3.4|^4",
"symfony/dependency-injection": "^3.4|^4",
"symfony/property-access": "^3.4|^4",
"pagerfanta/pagerfanta": "^1.0.5|^2.0",
"psr/log": "^1.0",
"ruflin/elastica": "^5.2.1|^6.0"
"ruflin/elastica": "^5.3|^6.1"
},
"require-dev": {
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/phpcr-bundle": "^1.3",
"doctrine/phpcr-bundle": "^1.3|^2.0",
"doctrine/phpcr-odm": "^1.4",
"jackalope/jackalope-doctrine-dbal": "^1.2",
"jms/serializer-bundle": "^2.2",
"phpunit/phpunit": "^5.7.11|^6.5",
"knplabs/knp-components": "^1.2",
"symfony/expression-language" : "^3.2|^4",
"symfony/twig-bundle": "^3.2|^4",
"symfony/serializer": "^3.2|^4",
"symfony/yaml": "^3.2|^4",
"symfony/expression-language" : "^3.4|^4",
"symfony/twig-bundle": "^3.4|^4",
"symfony/serializer": "^3.4|^4",
"symfony/yaml": "^3.4|^4",
"friendsofphp/php-cs-fixer": "^2.2",
"symfony/web-profiler-bundle": "^3.0|^4.0",
"symfony/web-profiler-bundle": "^3.4|^4.0"
"phpdocumentor/type-resolver": "~0.2.1"
},
"suggest": {
Expand Down
47 changes: 27 additions & 20 deletions src/DependencyInjection/Configuration.php
Expand Up @@ -78,8 +78,7 @@ public function getConfigTreeBuilder()
*/
public function getDynamicTemplateNode()
{
$builder = new TreeBuilder();
$node = $builder->root('dynamic_templates');
$node = $this->createTreeBuilderNode('dynamic_templates');

$node
->prototype('array')
Expand Down Expand Up @@ -109,8 +108,7 @@ public function getDynamicTemplateNode()
*/
protected function getTypesNode()
{
$builder = new TreeBuilder();
$node = $builder->root('types');
$node = $this->createTreeBuilderNode('types');

$node
->useAttributeAsKey('name')
Expand Down Expand Up @@ -169,8 +167,7 @@ protected function getTypesNode()
*/
protected function getPropertiesNode()
{
$builder = new TreeBuilder();
$node = $builder->root('properties');
$node = $this->createTreeBuilderNode('properties');

$node
->useAttributeAsKey('name')
Expand All @@ -185,8 +182,7 @@ protected function getPropertiesNode()
*/
protected function getIdNode()
{
$builder = new TreeBuilder();
$node = $builder->root('_id');
$node = $this->createTreeBuilderNode('_id');

$node
->children()
Expand All @@ -202,8 +198,7 @@ protected function getIdNode()
*/
protected function getSourceNode()
{
$builder = new TreeBuilder();
$node = $builder->root('_source');
$node = $this->createTreeBuilderNode('_source');

$node
->children()
Expand All @@ -229,8 +224,7 @@ protected function getSourceNode()
*/
protected function getRoutingNode()
{
$builder = new TreeBuilder();
$node = $builder->root('_routing');
$node = $this->createTreeBuilderNode('_routing');

$node
->children()
Expand All @@ -247,8 +241,7 @@ protected function getRoutingNode()
*/
protected function getParentNode()
{
$builder = new TreeBuilder();
$node = $builder->root('_parent');
$node = $this->createTreeBuilderNode('_parent');

$node
->children()
Expand All @@ -266,8 +259,7 @@ protected function getParentNode()
*/
protected function getAllNode()
{
$builder = new TreeBuilder();
$node = $builder->root('_all');
$node = $this->createTreeBuilderNode('_all');

$node
->children()
Expand All @@ -284,8 +276,7 @@ protected function getAllNode()
*/
protected function getPersistenceNode()
{
$builder = new TreeBuilder();
$node = $builder->root('persistence');
$node = $this->createTreeBuilderNode('persistence');

$node
->validate()
Expand Down Expand Up @@ -388,8 +379,7 @@ protected function getPersistenceNode()
*/
protected function getSerializerNode()
{
$builder = new TreeBuilder();
$node = $builder->root('serializer');
$node = $this->createTreeBuilderNode('serializer');

$node
->addDefaultsIfNotSet()
Expand Down Expand Up @@ -540,6 +530,23 @@ private function addIndexesSection(ArrayNodeDefinition $rootNode)
;
}

/**
* @return ArrayNodeDefinition|\Symfony\Component\Config\Definition\Builder\NodeDefinition
*/
private function createTreeBuilderNode($name)
{
$builder = new TreeBuilder($name);

if (method_exists($builder, 'getRootNode')) {
$node = $builder->getRootNode();
} else {
// BC layer for symfony/config 4.1 and older
$node = $builder->root($name);
}

return $node;
}

/**
* Adds the configuration for the "index_templates" key.
*
Expand Down
18 changes: 0 additions & 18 deletions src/Transformer/AbstractElasticaToModelTransformer.php
Expand Up @@ -31,22 +31,4 @@ public function setPropertyAccessor(PropertyAccessorInterface $propertyAccessor)
{
$this->propertyAccessor = $propertyAccessor;
}

/**
* Returns a sorting closure to be used with usort() to put retrieved objects
* back in the order that they were returned by ElasticSearch.
*
* @param array $idPos
* @param string $identifierPath
*
* @return callable
*/
protected function getSortingClosure(array $idPos, $identifierPath)
{
$propertyAccessor = $this->propertyAccessor;

return function ($a, $b) use ($idPos, $identifierPath, $propertyAccessor) {
return $idPos[(string) $propertyAccessor->getValue($a, $identifierPath)] > $idPos[(string) $propertyAccessor->getValue($b, $identifierPath)];
};
}
}
9 changes: 0 additions & 9 deletions tests/Functional/TypeObj.php
Expand Up @@ -9,15 +9,6 @@
* file that was distributed with this source code.
*/

/**
* This file is part of the FOSElasticaBundle project.
*
* (c) Infinite Networks Pty Ltd <http://www.infinite.net.au>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\ElasticaBundle\Tests\Functional;

class TypeObj
Expand Down
9 changes: 0 additions & 9 deletions tests/Functional/TypeObject.php
Expand Up @@ -9,15 +9,6 @@
* file that was distributed with this source code.
*/

/**
* This file is part of the FOSElasticaBundle project.
*
* (c) Infinite Networks Pty Ltd <http://www.infinite.net.au>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\ElasticaBundle\Tests\Functional;

class TypeObject
Expand Down
9 changes: 0 additions & 9 deletions tests/Functional/app/ORM/IndexableService.php
Expand Up @@ -9,15 +9,6 @@
* file that was distributed with this source code.
*/

/**
* This file is part of the FOSElasticaBundle project.
*
* (c) Infinite Networks Pty Ltd <http://www.infinite.net.au>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\ElasticaBundle\Tests\Functional\app\ORM;

class IndexableService
Expand Down
17 changes: 15 additions & 2 deletions tests/Unit/DataCollector/ElasticaDataCollectorTest.php
Expand Up @@ -13,14 +13,14 @@

use FOS\ElasticaBundle\DataCollector\ElasticaDataCollector;
use FOS\ElasticaBundle\Logger\ElasticaLogger;
use PHPUnit\Framework\TestCase;
use FOS\ElasticaBundle\Tests\Unit\UnitTestHelper;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

/**
* @author Richard Miller <info@limethinking.co.uk>
*/
class ElasticaDataCollectorTest extends TestCase
class ElasticaDataCollectorTest extends UnitTestHelper
{
public function testCorrectAmountOfQueries()
{
Expand Down Expand Up @@ -103,4 +103,17 @@ public function testName()

$this->assertSame('elastica', $elasticaDataCollector->getName());
}

public function testReset()
{
/** @var $loggerMock \PHPUnit_Framework_MockObject_MockObject|ElasticaLogger */
$loggerMock = $this->createMock(ElasticaLogger::class);
$loggerMock->expects($this->once())
->method('reset')
->willReturn('foo');

$elasticaDataCollector = new ElasticaDataCollector($loggerMock);
$elasticaDataCollector->reset();
$this->assertSame([], $this->getProtectedProperty($elasticaDataCollector, 'data'));
}
}
33 changes: 33 additions & 0 deletions tests/Unit/Event/IndexEventTest.php
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the FOSElasticaBundle package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\ElasticaBundle\Tests\Unit\Event;

use FOS\ElasticaBundle\Event\IndexEvent;
use PHPUnit\Framework\TestCase;

class IndexEventTest extends TestCase
{
/**
* @var IndexEvent
*/
private $event;

protected function setUp()
{
$this->event = new IndexEvent('index');
}

public function testIndex()
{
$this->assertEquals('index', $this->event->getIndex());
}
}

0 comments on commit 4523775

Please sign in to comment.