From a8a3268d2ef5a48e764f2c6781ed3e1ed56ec875 Mon Sep 17 00:00:00 2001 From: pmishev Date: Mon, 9 Oct 2023 17:54:20 +0100 Subject: [PATCH] Added github actions workflow and code style fixes --- .coveralls.yml | 3 - .env | 5 + .github/workflows/phpunit-tests.yml | 124 ++++++++++++ .php-cs-fixer.dist.php | 32 +--- .travis.yml | 31 --- README.md | 13 +- composer.json | 6 +- docker-compose.yml | 34 ++++ phpunit.xml.dist | 1 + src/Annotation/DocObject.php | 1 + src/Annotation/Id.php | 1 + src/Annotation/Score.php | 1 + .../Provider/ElasticsearchProvider.php | 6 +- src/Document/Repository/Repository.php | 2 +- .../IndexOrAliasNotFoundException.php | 4 +- src/Exception/IndexRebuildingException.php | 2 +- src/Finder/Adapter/ScrollAdapter.php | 4 +- src/Finder/Finder.php | 10 +- src/Manager/IndexManager.php | 6 +- src/Mapping/DocumentParser.php | 28 +-- src/Profiler/ElasticsearchProfiler.php | 24 +-- tests/AbstractElasticsearchTestCase.php | 2 - tests/App/config/config_test.yml | 2 +- .../Acme/BarBundle/Document/ObjCategory.php | 3 + .../Acme/BarBundle/Document/ObjTag.php | 1 + .../Acme/BarBundle/Document/Product.php | 8 + .../Document/Provider/CustomerProvider.php | 4 +- .../Document/Provider/OrderProvider.php | 4 +- .../Provider/ElasticsearchProviderTest.php | 8 +- .../Provider/ProviderRegistryTest.php | 6 +- tests/Functional/Document/RepositoryTest.php | 6 +- .../Adapter/KnpPaginatorAdapterTest.php | 24 +-- .../Finder/Adapter/ScrollAdapterTest.php | 14 +- tests/Functional/Finder/FinderTest.php | 34 ++-- tests/Functional/Manager/IndexManagerTest.php | 22 +-- .../Mapping/DocumentMetadataCollectorTest.php | 180 +++++++++--------- .../Functional/Mapping/DocumentParserTest.php | 156 +++++++-------- .../Profiler/ElasticsearchProfilerTest.php | 18 +- .../Result/DocumentConverterTest.php | 36 ++-- .../Result/DocumentIteratorTest.php | 24 +-- tests/Unit/Annotation/DocumentTest.php | 4 +- tests/Unit/Annotation/PropertyTest.php | 20 +- tests/Unit/DTO/BulkQueryItemTest.php | 6 +- .../Compiler/AddIndexManagersPassTest.php | 14 +- .../ElasticsearchExtensionTest.php | 36 ++-- tests/Unit/Document/MLPropertyTest.php | 12 +- tests/Unit/Mapping/CaserTest.php | 2 + tests/tests.bootstrap.php | 9 + 48 files changed, 569 insertions(+), 424 deletions(-) delete mode 100644 .coveralls.yml create mode 100644 .env create mode 100644 .github/workflows/phpunit-tests.yml delete mode 100644 .travis.yml create mode 100644 docker-compose.yml diff --git a/.coveralls.yml b/.coveralls.yml deleted file mode 100644 index 81fec43..0000000 --- a/.coveralls.yml +++ /dev/null @@ -1,3 +0,0 @@ -coverage_clover: tests/App/build/clover.xml -service_name: travis-ci -json_path: tests/App/build/coveralls.json diff --git a/.env b/.env new file mode 100644 index 0000000..8a9016e --- /dev/null +++ b/.env @@ -0,0 +1,5 @@ +# Override for the ES port to use for the docker container +ELASTICSEARCH_PORT=9201 + +# Override for the ES version to use for the docker container +#ELASTICSEARCH_VERSION=8.8.0 diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml new file mode 100644 index 0000000..aa95c42 --- /dev/null +++ b/.github/workflows/phpunit-tests.yml @@ -0,0 +1,124 @@ +name: tests + +concurrency: + group: phpunit-tests-${{ github.ref_name }} + cancel-in-progress: true + +on: ['push', 'pull_request', 'workflow_dispatch'] + +env: + ELASTICSEARCH_PORT: 9201 + +jobs: + static_code_analysis: + runs-on: 'ubuntu-20.04' + name: 'Static code analysis' + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + + - name: Checkout + uses: actions/checkout@v4 + + - name: 'Validate composer.json and composer.lock' + run: composer validate + + - name: 'Install dependencies with Composer' + uses: 'ramsey/composer-install@v2' + with: + dependency-versions: 'highest' + composer-options: '--prefer-dist' + + - name: Check PHP coding standards + run: php vendor/bin/php-cs-fixer fix --verbose --dry-run + + phpunit: + needs: [ static_code_analysis ] + runs-on: 'ubuntu-20.04' + name: 'PHPUnit (PHP ${{ matrix.php }}, Symfony ${{ matrix.symfony }}, ES ${{ matrix.elasticsearch }})' + timeout-minutes: 30 + continue-on-error: ${{ matrix.experimental }} + strategy: + matrix: + experimental: + - false + dependencies: + - 'highest' + php: + - '8.1' + - '8.2' + elasticsearch: + - '7.17.13' + symfony: + - '~5.0' + include: + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.0.1' + experimental: false + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.1.3' # there are some bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.1.html#breaking-changes-8.1 + experimental: false + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.5.3' # there are some bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.5.html + experimental: false + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.6.2' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.6.html + experimental: false + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.7.1' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.7.html + experimental: false + - php: '8.1' + symfony: '~5.0' + elasticsearch: '8.8.0' # there are no bc in minor version https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.8.html + experimental: false + - php: '8.1' + symfony: '~6.0' + elasticsearch: '8.10.2' # newest version + experimental: false + fail-fast: false + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '${{ matrix.php }}' + coverage: 'pcov' + tools: 'composer:v2' + extensions: 'curl, json, mbstring, openssl' + ini-values: 'memory_limit=256M' + + - name: 'Fix symfony/framework-bundle version' + run: composer require --no-update symfony/framework-bundle:${{ matrix.symfony }} + + - name: 'Install dependencies with Composer' + uses: 'ramsey/composer-install@v2' + with: + dependency-versions: '${{ matrix.dependencies }}' + composer-options: '--prefer-dist' + + - name: 'Dump composer autoloader' + run: composer dump-autoload --classmap-authoritative --no-ansi --no-interaction --no-scripts + + - name: 'Setup Elasticsearch' + env: + ELASTICSEARCH_VERSION: ${{ matrix.elasticsearch }} + run: docker compose up --detach --wait ; curl -XGET 'http://localhost:'"$ELASTICSEARCH_PORT" + + - name: 'Run phpunit tests' + run: | + vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml 2>/dev/null + + - name: Upload coverage results to Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} + run: | + vendor/bin/php-coveralls --coverage_clover=tests/App/build/clover.xml --json_path=tests/App/build/coveralls.json -v diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index ad545eb..3eb4e1f 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -8,31 +8,15 @@ return (new PhpCsFixer\Config()) ->setFinder($finder) ->setRules([ - '@PHP73Migration' => true, - '@PHPUnit75Migration:risky' => true, - '@PSR2' => true, '@Symfony' => true, - '@Symfony:risky' => true, - 'modernize_strpos' => true, - 'is_null' => true, - 'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'], - 'native_constant_invocation' => true, - 'native_function_invocation' => [ - 'include' => ['@all'], - ], - 'no_alias_functions' => true, - 'no_useless_else' => true, - 'nullable_type_declaration_for_default_null_value' => true, - 'ordered_imports' => true, - 'php_unit_dedicate_assert' => ['target' => 'newest'], - 'static_lambda' => true, - 'ternary_to_null_coalescing' => true, - 'visibility_required' => ['elements' => ['property', 'method', 'const']], - 'void_return' => false, - 'protected_to_private' => false, - 'phpdoc_summary' => false, + + // Exclude "phpdoc_summary" rule: "PHPDoc summary should end in either a full stop, exclamation mark, or question mark" + 'phpdoc_summary' => false, 'phpdoc_annotation_without_dot' => false, - 'phpdoc_to_comment' => ['ignored_tags' => ['@var']] + 'no_superfluous_phpdoc_tags' => ['allow_mixed' => true, 'remove_inheritdoc' => false], + // Indent '=>' operator + 'binary_operator_spaces' => ['operators' => ['=>' => 'align_single_space_minimal']], + // PSR12 imports order + 'ordered_imports' => ['imports_order' => ['class', 'function', 'const']], ]) ; - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 33b4319..0000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: php -php: - - '7.3' - - '8.0' - -env: - global: - - SYMFONY_VERSION="~5.0" ES_FILENAME_SUFFIX="-linux-x86_64" - matrix: - - ES_VERSION="7.2.1" - - ES_VERSION="7.2.1" SYMFONY_VERSION="~4.4" - - ES_VERSION="7.11.1" - - ES_VERSION="7.11.1" SYMFONY_VERSION="~4.4" - -install: - - composer require --no-update symfony/framework-bundle:${SYMFONY_VERSION} - - wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ES_VERSION}${ES_FILENAME_SUFFIX}.tar.gz - - tar -xzf elasticsearch-${ES_VERSION}${ES_FILENAME_SUFFIX}.tar.gz - - ./elasticsearch-${ES_VERSION}/bin/elasticsearch -d - - composer install --dev --no-interaction - -before_script: - - export XDEBUG_MODE=coverage - -script: - - wget -q --waitretry=1 --retry-connrefused -T 120 -O - http://127.0.0.1:9200 - - vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml 2>/dev/null - - vendor/bin/phpcs -np --standard=PSR2 --ignore=vendor/,tests/App/,var/ ./ - -after_script: - - travis_retry php vendor/bin/php-coveralls -v diff --git a/README.md b/README.md index 11f3a94..25e6367 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ ![License](https://img.shields.io/github/license/sineflow/elasticsearchbundle.svg) [![Latest Stable Version](https://img.shields.io/github/release/sineflow/elasticsearchbundle.svg)](https://packagist.org/packages/sineflow/elasticsearch-bundle) -[![Build Status](https://travis-ci.com/sineflow/ElasticsearchBundle.svg?branch=main)](https://app.travis-ci.com/github/sineflow/ElasticsearchBundle) -[![Coverage Status](https://coveralls.io/repos/sineflow/ElasticsearchBundle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sineflow/ElasticsearchBundle?branch=master) +![Tests Workflow](https://github.com/sineflow/ElasticsearchBundle/actions/workflows/phpunit-tests.yml/badge.svg) +[![Coverage Status](https://coveralls.io/repos/github/sineflow/ElasticsearchBundle/badge.svg?branch=main)](https://coveralls.io/github/sineflow/ElasticsearchBundle?branch=main) ## Key points @@ -31,3 +31,12 @@ Installation instructions and documentation of the bundle can be found [here](do ## License This bundle is licensed under the MIT license. Please, see the complete license in the [LICENSE](LICENSE) file. + +## Running tests + +``` +composer install +docker compose up --detach --wait +vendor/bin/simple-phpunit +docker compose down --remove-orphans +``` \ No newline at end of file diff --git a/composer.json b/composer.json index 4a1bf28..cf9d7af 100644 --- a/composer.json +++ b/composer.json @@ -32,11 +32,12 @@ "symfony/stopwatch": "^4.4 || ^5.0", "symfony/phpunit-bridge": "^4.4 || ^5.0", "symfony/browser-kit": "^4.4 || ^5.0", + "symfony/dotenv": "^4.4 || ^5.0", "doctrine/orm": "^2.6.3", "monolog/monolog": "^1.0|^2.0|^3.0", "knplabs/knp-paginator-bundle": "^4.0 || ^5.0", - "squizlabs/php_codesniffer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.34", "php-coveralls/php-coveralls": "^2.1", "escapestudios/symfony2-coding-standard": "^3.0", "jchook/phpunit-assert-throws": "^1.0", @@ -50,8 +51,7 @@ "autoload": { "psr-4": { "Sineflow\\ElasticsearchBundle\\": "src/" - }, - "exclude-from-classmap": ["/tests/"] + } }, "autoload-dev": { "psr-4": { diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b7166f8 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,34 @@ +services: + elasticsearch: + image: "docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION:-7.17.13}" + container_name: sfes_elasticsearch + environment: + - discovery.type=single-node + - bootstrap.memory_lock=true + - "ES_JAVA_OPTS=-Xms${ELASTICSEARCH_JAVA_MEM:-2048m} -Xmx${ELASTICSEARCH_JAVA_MEM:-2048m}" + - cluster.name=sfes + - node.name=sfes1 + - xpack.security.enabled=false + - indices.id_field_data.enabled=true # TODO: temporary requirement for ES8 until tests are fixed to not do sorting/aggregations on _id (https://github.com/elastic/elasticsearch/issues/43599) + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - elasticsearch-data:/usr/share/elasticsearch/data + ports: + - "${ELASTICSEARCH_PORT:-9200}:9200" + networks: + - elastic + healthcheck: + test: curl -s http://sfes_elasticsearch:$${ELASTICSEARCH_PORT:-9200} > /dev/null || exit 1 + interval: 1s + timeout: 5s + retries: 120 + +volumes: + elasticsearch-data: + +networks: + elastic: + driver: bridge diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e27392b..4f2f113 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -25,6 +25,7 @@ + diff --git a/src/Annotation/DocObject.php b/src/Annotation/DocObject.php index 2f34eba..3820afc 100644 --- a/src/Annotation/DocObject.php +++ b/src/Annotation/DocObject.php @@ -6,6 +6,7 @@ * Annotation to mark a class as an object during the parsing process. * * @Annotation + * * @Target("CLASS") */ final class DocObject diff --git a/src/Annotation/Id.php b/src/Annotation/Id.php index 004943a..8f3fa30 100644 --- a/src/Annotation/Id.php +++ b/src/Annotation/Id.php @@ -6,6 +6,7 @@ * Annotation used for the meta _id field * * @Annotation + * * @Target("PROPERTY") */ final class Id diff --git a/src/Annotation/Score.php b/src/Annotation/Score.php index 2d148ec..342b5a2 100644 --- a/src/Annotation/Score.php +++ b/src/Annotation/Score.php @@ -6,6 +6,7 @@ * Annotation used for the meta _score field, returned when searching * * @Annotation + * * @Target("PROPERTY") */ final class Score diff --git a/src/Document/Provider/ElasticsearchProvider.php b/src/Document/Provider/ElasticsearchProvider.php index 991f2bd..ad0389c 100644 --- a/src/Document/Provider/ElasticsearchProvider.php +++ b/src/Document/Provider/ElasticsearchProvider.php @@ -66,8 +66,8 @@ public function getDocuments() ['sort' => ['_doc']], Finder::RESULTS_RAW | Finder::ADAPTER_SCROLL, [ - 'index' => $this->sourceIndexManager->getLiveIndex(), - 'size' => $this->chunkSize, + 'index' => $this->sourceIndexManager->getLiveIndex(), + 'size' => $this->chunkSize, 'scroll' => $this->scrollTime, ] ); @@ -90,7 +90,7 @@ public function getDocument($id): array { $params = [ 'index' => $this->sourceIndexManager->getLiveIndex(), - 'id' => $id, + 'id' => $id, ]; $doc = $this->sourceIndexManager->getConnection()->getClient()->get($params); $result = $doc['_source']; diff --git a/src/Document/Repository/Repository.php b/src/Document/Repository/Repository.php index 3617186..93e7bca 100644 --- a/src/Document/Repository/Repository.php +++ b/src/Document/Repository/Repository.php @@ -65,7 +65,7 @@ public function getById(string $id, int $resultType = Finder::RESULTS_OBJECT) * * @return mixed */ - public function find(array $searchBody, int $resultsType = Finder::RESULTS_OBJECT, array $additionalRequestParams = [], ?int &$totalHits = null) + public function find(array $searchBody, int $resultsType = Finder::RESULTS_OBJECT, array $additionalRequestParams = [], int &$totalHits = null) { return $this->finder->find([$this->documentClass], $searchBody, $resultsType, $additionalRequestParams, $totalHits); } diff --git a/src/Exception/IndexOrAliasNotFoundException.php b/src/Exception/IndexOrAliasNotFoundException.php index 7ecf10f..0a2796d 100644 --- a/src/Exception/IndexOrAliasNotFoundException.php +++ b/src/Exception/IndexOrAliasNotFoundException.php @@ -2,8 +2,6 @@ namespace Sineflow\ElasticsearchBundle\Exception; -use Throwable; - /** * Class IndexOrAliasNotFoundException */ @@ -19,7 +17,7 @@ class IndexOrAliasNotFoundException extends Exception * * @param int $code */ - public function __construct(string $indexOrAlias, bool $isAlias = false, $code = 0, ?Throwable $previous = null) + public function __construct(string $indexOrAlias, bool $isAlias = false, $code = 0, \Throwable $previous = null) { $this->indexOrAlias = $indexOrAlias; diff --git a/src/Exception/IndexRebuildingException.php b/src/Exception/IndexRebuildingException.php index db79f37..c44b130 100644 --- a/src/Exception/IndexRebuildingException.php +++ b/src/Exception/IndexRebuildingException.php @@ -16,7 +16,7 @@ class IndexRebuildingException extends Exception * @param array $indicesInProgress The physical indices, which are in the process of being built * @param int $code */ - public function __construct(array $indicesInProgress, $code = 0, ?Exception $previous = null) + public function __construct(array $indicesInProgress, $code = 0, Exception $previous = null) { parent::__construct(\sprintf('Index is currently being rebuilt as "%s"', \implode(', ', $indicesInProgress)), $code, $previous); diff --git a/src/Finder/Adapter/ScrollAdapter.php b/src/Finder/Adapter/ScrollAdapter.php index c958448..69e9cf3 100644 --- a/src/Finder/Adapter/ScrollAdapter.php +++ b/src/Finder/Adapter/ScrollAdapter.php @@ -36,9 +36,9 @@ class ScrollAdapter private $resultsType; /** - * @var int + * @var int|null */ - private $totalHits = null; + private $totalHits; /** * When a search query with a 'scroll' param is performed, not only the scroll id is returned, but also the diff --git a/src/Finder/Finder.php b/src/Finder/Finder.php index 9e94f9b..30fa5e7 100644 --- a/src/Finder/Finder.php +++ b/src/Finder/Finder.php @@ -68,7 +68,7 @@ public function get(string $documentClass, string $id, int $resultType = self::R $search = [ 'index' => $this->indexManagerRegistry->get($indexManagerName)->getReadAlias(), - 'body' => ['query' => ['ids' => ['values' => [$id]]], 'version' => true], + 'body' => ['query' => ['ids' => ['values' => [$id]]], 'version' => true], ]; $results = $this->getConnection([$documentClass])->getClient()->search($search); @@ -127,7 +127,7 @@ public function find(array $documentClasses, array $searchBody, $resultsType = s // Set default scroll and size, unless custom ones were provided through $additionalRequestParams $params = \array_replace_recursive([ 'scroll' => self::SCROLL_TIME, - 'body' => ['sort' => ['_doc']], + 'body' => ['sort' => ['_doc']], ], $params); $rawResults = $client->search($params); @@ -154,14 +154,14 @@ public function find(array $documentClasses, array $searchBody, $resultsType = s * * @return mixed */ - public function scroll(array $documentClasses, string &$scrollId, string $scrollTime = self::SCROLL_TIME, int $resultsType = self::RESULTS_OBJECT, ?int &$totalHits = null) + public function scroll(array $documentClasses, string &$scrollId, string $scrollTime = self::SCROLL_TIME, int $resultsType = self::RESULTS_OBJECT, int &$totalHits = null) { $client = $this->getConnection($documentClasses)->getClient(); $params = [ 'body' => [ 'scroll_id' => $scrollId, - 'scroll' => $scrollTime, + 'scroll' => $scrollTime, ], ]; @@ -235,7 +235,7 @@ public function getTargetIndices(array $documentClasses): array * * @return array|DocumentIterator */ - public function parseResult(array $raw, int $resultsType, ?array $documentClasses = null) + public function parseResult(array $raw, int $resultsType, array $documentClasses = null) { switch ($resultsType & self::BITMASK_RESULT_TYPES) { case self::RESULTS_OBJECT: diff --git a/src/Manager/IndexManager.php b/src/Manager/IndexManager.php index d96ed9d..d8808ec 100644 --- a/src/Manager/IndexManager.php +++ b/src/Manager/IndexManager.php @@ -65,7 +65,7 @@ class IndexManager /** * @var array */ - protected $indexMapping = null; + protected $indexMapping; /** * @var array @@ -540,7 +540,7 @@ public function update(string $id, array $fields = [], $script = null, array $qu $query = \array_filter(\array_merge( $queryParams, [ - 'doc' => $fields, + 'doc' => $fields, 'script' => $script, ] )); @@ -601,7 +601,7 @@ public function persistRaw(array $documentArray, array $metaParams = []) /** * Created a new index with a unique name */ - protected function createNewIndexWithUniqueName(?string $suffix = null): string + protected function createNewIndexWithUniqueName(string $suffix = null): string { $settings = $this->getIndexMapping(); $newIndex = $this->getUniqueIndexName($suffix); diff --git a/src/Mapping/DocumentParser.php b/src/Mapping/DocumentParser.php index 26f82ba..ec6693e 100644 --- a/src/Mapping/DocumentParser.php +++ b/src/Mapping/DocumentParser.php @@ -83,12 +83,12 @@ public function parse(\ReflectionClass $documentReflection, array $indexAnalyzer $properties = $this->getProperties($documentReflection, $indexAnalyzers); $metadata = [ - 'properties' => $properties, - 'fields' => \array_filter($classAnnotation->dump()), + 'properties' => $properties, + 'fields' => \array_filter($classAnnotation->dump()), 'propertiesMetadata' => $this->getPropertiesMetadata($documentReflection), - 'repositoryClass' => $classAnnotation->repositoryClass, - 'providerClass' => $classAnnotation->providerClass, - 'className' => $documentReflection->getName(), + 'repositoryClass' => $classAnnotation->repositoryClass, + 'providerClass' => $classAnnotation->providerClass, + 'className' => $documentReflection->getName(), ]; } @@ -125,8 +125,8 @@ public function getPropertiesMetadata(\ReflectionClass $documentReflection) switch (\get_class($propertyAnnotation)) { case Property::class: $propertyMetadata[$propertyAnnotation->name] = [ - 'propertyName' => $propertyName, - 'type' => $propertyAnnotation->type, + 'propertyName' => $propertyName, + 'type' => $propertyAnnotation->type, 'multilanguage' => $propertyAnnotation->multilanguage, ]; @@ -139,9 +139,9 @@ public function getPropertiesMetadata(\ReflectionClass $documentReflection) $propertyMetadata[$propertyAnnotation->name] = \array_merge( $propertyMetadata[$propertyAnnotation->name], [ - 'multiple' => $propertyAnnotation->multiple, + 'multiple' => $propertyAnnotation->multiple, 'propertiesMetadata' => $this->getPropertiesMetadata($child), - 'className' => $child->getName(), + 'className' => $child->getName(), ] ); } @@ -152,7 +152,7 @@ public function getPropertiesMetadata(\ReflectionClass $documentReflection) $propertyAnnotation->type = 'keyword'; $propertyMetadata[$propertyAnnotation->name] = [ 'propertyName' => $propertyName, - 'type' => $propertyAnnotation->type, + 'type' => $propertyAnnotation->type, ]; break; @@ -161,7 +161,7 @@ public function getPropertiesMetadata(\ReflectionClass $documentReflection) $propertyAnnotation->type = 'float'; $propertyMetadata[$propertyAnnotation->name] = [ 'propertyName' => $propertyName, - 'type' => $propertyAnnotation->type, + 'type' => $propertyAnnotation->type, ]; break; } @@ -295,7 +295,7 @@ private function getProperties(\ReflectionClass $documentReflection, array $inde // TODO: The application should decide whether it wants to use a default field at all and set its mapping on a global base // The custom mapping from the application should be set here, using perhaps some kind of decorator $mapping[$propertyAnnotation->name.$this->languageSeparator.Property::DEFAULT_LANG_SUFFIX] = $propertyAnnotation->multilanguageDefaultOptions ?: [ - 'type' => 'keyword', + 'type' => 'keyword', 'ignore_above' => 256, ]; } else { @@ -311,10 +311,10 @@ private function getProperties(\ReflectionClass $documentReflection, array $inde * * @throws \ReflectionException */ - private function getPropertyMapping(Property $propertyAnnotation, ?string $language = null, array $indexAnalyzers = []) + private function getPropertyMapping(Property $propertyAnnotation, string $language = null, array $indexAnalyzers = []) { $propertyMapping = $propertyAnnotation->dump([ - 'language' => $language, + 'language' => $language, 'indexAnalyzers' => $indexAnalyzers, ]); diff --git a/src/Profiler/ElasticsearchProfiler.php b/src/Profiler/ElasticsearchProfiler.php index 945bb71..1362952 100644 --- a/src/Profiler/ElasticsearchProfiler.php +++ b/src/Profiler/ElasticsearchProfiler.php @@ -44,7 +44,7 @@ public function addLogger(Logger $logger) /** * {@inheritDoc} */ - public function collect(Request $request, Response $response, ?\Throwable $exception = null) + public function collect(Request $request, Response $response, \Throwable $exception = null) { $this->data['indexManagers'] = $this->cloneVar($this->indexManagers); @@ -64,10 +64,10 @@ public function collect(Request $request, Response $response, ?\Throwable $excep public function reset() { $this->data = [ - 'indexManagers' => [], // The list of all defined index managers - 'queryCount' => 0, // The queries count - 'time' => .0, // Total time for all queries in ms. - 'queries' => [], // Array with all the queries + 'indexManagers' => [], // The list of all defined index managers + 'queryCount' => 0, // The queries count + 'time' => .0, // Total time for all queries in ms. + 'queries' => [], // Array with all the queries ]; } @@ -148,10 +148,10 @@ private function addQuery(string $route, array $record, string $queryBody, strin $parsedUrl = \array_merge( [ 'scheme' => '', - 'host' => '', - 'port' => '', - 'path' => '', - 'query' => '', + 'host' => '', + 'port' => '', + 'path' => '', + 'query' => '', ], \parse_url($record['context']['uri']) ); @@ -165,10 +165,10 @@ private function addQuery(string $route, array $record, string $queryBody, strin $this->data['queries'][$route][] = \array_merge( [ - 'time' => $record['context']['duration'] * 1000, - 'curlRequest' => $rawRequest, + 'time' => $record['context']['duration'] * 1000, + 'curlRequest' => $rawRequest, 'senseRequest' => $senseRequest, - 'backtrace' => $record['extra']['backtrace'], + 'backtrace' => $record['extra']['backtrace'], ], \array_diff_key(\parse_url($record['context']['uri']), \array_flip(['query'])) ); diff --git a/tests/AbstractElasticsearchTestCase.php b/tests/AbstractElasticsearchTestCase.php index 790a7b9..ab37078 100644 --- a/tests/AbstractElasticsearchTestCase.php +++ b/tests/AbstractElasticsearchTestCase.php @@ -117,8 +117,6 @@ protected function getIndexManager($name, $createIndex = true) /** * Return whether a given index manager has already been created in the current class instance * - * @param $name - * * @return bool */ protected function hasCreatedIndexManager($name) diff --git a/tests/App/config/config_test.yml b/tests/App/config/config_test.yml index a1fa257..64ae922 100644 --- a/tests/App/config/config_test.yml +++ b/tests/App/config/config_test.yml @@ -1,6 +1,6 @@ parameters: elasticsearch_hosts: - - '127.0.0.1:9200' + - '127.0.0.1:%env(ELASTICSEARCH_PORT)%' # Framework Configuration framework: diff --git a/tests/App/fixture/Acme/BarBundle/Document/ObjCategory.php b/tests/App/fixture/Acme/BarBundle/Document/ObjCategory.php index 6da77f0..9d60557 100644 --- a/tests/App/fixture/Acme/BarBundle/Document/ObjCategory.php +++ b/tests/App/fixture/Acme/BarBundle/Document/ObjCategory.php @@ -19,18 +19,21 @@ class ObjCategory implements ObjectInterface /** * @var int + * * @ES\Property(type="integer", name="id") */ public $id; /** * @var string + * * @ES\Property(type="keyword", name="title") */ public $title; /** * @var ObjTag[] + * * @ES\Property(type="object", name="tags", multiple=true, objectName="AcmeBarBundle:ObjTag") */ public $tags; diff --git a/tests/App/fixture/Acme/BarBundle/Document/ObjTag.php b/tests/App/fixture/Acme/BarBundle/Document/ObjTag.php index f73907b..99a6e6f 100644 --- a/tests/App/fixture/Acme/BarBundle/Document/ObjTag.php +++ b/tests/App/fixture/Acme/BarBundle/Document/ObjTag.php @@ -14,6 +14,7 @@ class ObjTag implements ObjectInterface { /** * @var string + * * @ES\Property(type="text", name="tagname") */ public $tagName; diff --git a/tests/App/fixture/Acme/BarBundle/Document/Product.php b/tests/App/fixture/Acme/BarBundle/Document/Product.php index 206002b..cdaa912 100644 --- a/tests/App/fixture/Acme/BarBundle/Document/Product.php +++ b/tests/App/fixture/Acme/BarBundle/Document/Product.php @@ -21,6 +21,7 @@ class Product extends AbstractDocument { /** * @var string + * * @ES\Property( * type="text", * name="title", @@ -36,42 +37,49 @@ class Product extends AbstractDocument /** * @var string + * * @ES\Property(type="text", name="description") */ public $description; /** * @var ObjCategory + * * @ES\Property(type="object", name="category", objectName="AcmeBarBundle:ObjCategory") */ public $category; /** * @var ObjCategory[]|ObjectIterator + * * @ES\Property(type="object", name="related_categories", multiple=true, objectName="AcmeBarBundle:ObjCategory") */ public $relatedCategories; /** * @var int + * * @ES\Property(type="float", name="price") */ public $price; /** * @var string + * * @ES\Property(type="geo_point", name="location") */ public $location; /** * @var string + * * @ES\Property(type="boolean", name="limited") */ public $limited; /** * @var string + * * @ES\Property(type="date", name="released") */ public $released; diff --git a/tests/App/fixture/Acme/FooBundle/Document/Provider/CustomerProvider.php b/tests/App/fixture/Acme/FooBundle/Document/Provider/CustomerProvider.php index 1c04a22..f904f13 100644 --- a/tests/App/fixture/Acme/FooBundle/Document/Provider/CustomerProvider.php +++ b/tests/App/fixture/Acme/FooBundle/Document/Provider/CustomerProvider.php @@ -9,11 +9,11 @@ class CustomerProvider extends AbstractProvider { private $fixedDocuments = [ 1 => [ - 'id' => 1, + 'id' => 1, 'name' => 'John', ], 2 => [ - 'id' => 2, + 'id' => 2, 'name' => 'Jane', ], ]; diff --git a/tests/App/fixture/Acme/FooBundle/Document/Provider/OrderProvider.php b/tests/App/fixture/Acme/FooBundle/Document/Provider/OrderProvider.php index c9eee74..2254fd6 100644 --- a/tests/App/fixture/Acme/FooBundle/Document/Provider/OrderProvider.php +++ b/tests/App/fixture/Acme/FooBundle/Document/Provider/OrderProvider.php @@ -9,11 +9,11 @@ class OrderProvider extends AbstractProvider { private $fixedDocuments = [ 1 => [ - 'id' => 1, + 'id' => 1, 'order_time' => 1452250000, ], 2 => [ - 'id' => 2, + 'id' => 2, 'order_time' => 1452251632, ], ]; diff --git a/tests/Functional/Document/Provider/ElasticsearchProviderTest.php b/tests/Functional/Document/Provider/ElasticsearchProviderTest.php index cd52838..2b5dfb7 100644 --- a/tests/Functional/Document/Provider/ElasticsearchProviderTest.php +++ b/tests/Functional/Document/Provider/ElasticsearchProviderTest.php @@ -16,15 +16,15 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => 1, + '_id' => 1, 'title' => 'Product 1', ], [ - '_id' => 2, + '_id' => 2, 'title' => 'Product 2', ], [ - '_id' => 3, + '_id' => 3, 'title' => 'Product 3', ], ], @@ -38,7 +38,7 @@ public function testGetDocument() $doc = $esProvider->getDocument(3); $this->assertEquals([ - '_id' => 3, + '_id' => 3, 'title' => 'Product 3', ], $doc); } diff --git a/tests/Functional/Document/Provider/ProviderRegistryTest.php b/tests/Functional/Document/Provider/ProviderRegistryTest.php index 6263131..3053dfb 100644 --- a/tests/Functional/Document/Provider/ProviderRegistryTest.php +++ b/tests/Functional/Document/Provider/ProviderRegistryTest.php @@ -27,19 +27,19 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => 'product1', + '_id' => 'product1', 'title' => 'Product1', ], ], 'customer' => [ [ - '_id' => 'customer1', + '_id' => 'customer1', 'name' => 'Customer1', ], ], 'order' => [ [ - '_id' => 'order1', + '_id' => 'order1', 'order_time' => 11112222, ], ], diff --git a/tests/Functional/Document/RepositoryTest.php b/tests/Functional/Document/RepositoryTest.php index 8ba3d37..fa10b08 100644 --- a/tests/Functional/Document/RepositoryTest.php +++ b/tests/Functional/Document/RepositoryTest.php @@ -41,15 +41,15 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => 'doc1', + '_id' => 'doc1', 'title' => 'aaa', ], [ - '_id' => 2, + '_id' => 2, 'title' => 'ccc', ], [ - '_id' => 3, + '_id' => 3, 'title' => 'ccc', ], ], diff --git a/tests/Functional/Finder/Adapter/KnpPaginatorAdapterTest.php b/tests/Functional/Finder/Adapter/KnpPaginatorAdapterTest.php index 916a20a..f524bd2 100644 --- a/tests/Functional/Finder/Adapter/KnpPaginatorAdapterTest.php +++ b/tests/Functional/Finder/Adapter/KnpPaginatorAdapterTest.php @@ -20,12 +20,12 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => '1', - 'title' => 'Foo Product', - 'price' => 10, + '_id' => '1', + 'title' => 'Foo Product', + 'price' => 10, 'category' => [ 'title' => 'Bar', - 'tags' => [ + 'tags' => [ ['tagname' => 'first tag'], ['tagname' => 'second tag'], ], @@ -33,7 +33,7 @@ protected function getDataArray() 'related_categories' => [ [ 'title' => 'Acme', - 'tags' => [ + 'tags' => [ ['tagname' => 'tutu'], ], ], @@ -45,10 +45,10 @@ protected function getDataArray() 'ml_info-fr' => 'info in French', ], [ - '_id' => '2', - 'title' => 'Bar Product', - 'price' => 15, - 'category' => null, + '_id' => '2', + 'title' => 'Bar Product', + 'price' => 15, + 'category' => null, 'related_categories' => [ [ 'title' => 'Acme', @@ -59,9 +59,9 @@ protected function getDataArray() ], ], [ - '_id' => '3', - 'price' => 5, - 'title' => '3rd Product', + '_id' => '3', + 'price' => 5, + 'title' => '3rd Product', 'related_categories' => [], ], [ diff --git a/tests/Functional/Finder/Adapter/ScrollAdapterTest.php b/tests/Functional/Finder/Adapter/ScrollAdapterTest.php index cdb3c2b..96e5c3d 100644 --- a/tests/Functional/Finder/Adapter/ScrollAdapterTest.php +++ b/tests/Functional/Finder/Adapter/ScrollAdapterTest.php @@ -18,34 +18,34 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => '1', + '_id' => '1', 'title' => 'Foo Product', ], [ - '_id' => '2', + '_id' => '2', 'title' => 'Bar Product', ], [ - '_id' => '3', + '_id' => '3', 'title' => '3rd product', ], [ - '_id' => 'aaa', + '_id' => 'aaa', 'title' => 'bla bla product', ], [ - '_id' => 'bbb', + '_id' => 'bbb', 'title' => 'blu blu', ], [ '_id' => '54321', ], [ - '_id' => '8', + '_id' => '8', 'title' => 'product X', ], [ - '_id' => '9', + '_id' => '9', 'title' => 'product Y', ], ], diff --git a/tests/Functional/Finder/FinderTest.php b/tests/Functional/Finder/FinderTest.php index d20d0e7..5721e2a 100644 --- a/tests/Functional/Finder/FinderTest.php +++ b/tests/Functional/Finder/FinderTest.php @@ -25,23 +25,23 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => 'doc1', + '_id' => 'doc1', 'title' => 'aaa', ], [ - '_id' => 'doc2', + '_id' => 'doc2', 'title' => 'bbb', ], [ - '_id' => 3, + '_id' => 3, 'title' => 'ccc', ], ], 'customer' => [ [ - '_id' => 111, - 'name' => 'Jane Doe', - 'title' => 'aaa bbb', + '_id' => 111, + 'name' => 'Jane Doe', + 'title' => 'aaa bbb', 'active' => true, ], ], @@ -92,18 +92,18 @@ protected function setUp(): void // Enter data in the read-only index $im->getConnection()->getClient()->index([ - 'index' => $this->readOnlyIndexName, - 'id' => 111, + 'index' => $this->readOnlyIndexName, + 'id' => 111, 'refresh' => true, - 'body' => [ + 'body' => [ 'name' => 'Another Jane', ], ]); $im->getConnection()->getClient()->index([ - 'index' => $this->readOnlyIndexName, - 'id' => 123, + 'index' => $this->readOnlyIndexName, + 'id' => 123, 'refresh' => true, - 'body' => [ + 'body' => [ 'name' => 'Jason Bourne', ], ]); @@ -123,10 +123,10 @@ public function testGetById() $docAsRaw = $finder->get('AcmeBarBundle:Product', 'doc1', Finder::RESULTS_RAW); $this->assertArraySubset([ - '_index' => 'sineflow-esb-test-bar', - '_id' => 'doc1', + '_index' => 'sineflow-esb-test-bar', + '_id' => 'doc1', '_version' => 1, - '_source' => ['title' => 'aaa'], + '_source' => ['title' => 'aaa'], ], $docAsRaw); $docAsObjectKNP = $finder->get('AcmeBarBundle:Product', 'doc1', Finder::RESULTS_OBJECT | Finder::ADAPTER_KNP); @@ -166,8 +166,8 @@ public function testFindInMultipleTypesAndIndices() 'title' => 'bbb', ], 111 => [ - 'name' => 'Jane Doe', - 'title' => 'aaa bbb', + 'name' => 'Jane Doe', + 'title' => 'aaa bbb', 'active' => true, ], ], $res); diff --git a/tests/Functional/Manager/IndexManagerTest.php b/tests/Functional/Manager/IndexManagerTest.php index 96c9784..9836ee8 100644 --- a/tests/Functional/Manager/IndexManagerTest.php +++ b/tests/Functional/Manager/IndexManagerTest.php @@ -30,8 +30,8 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => 'doc1', - 'title' => 'Foo Product', + '_id' => 'doc1', + 'title' => 'Foo Product', 'category' => [ 'title' => 'Bar', ], @@ -46,14 +46,14 @@ protected function getDataArray() ], 'customer' => [ [ - '_id' => 111, - 'name' => 'Jane Doe', + '_id' => 111, + 'name' => 'Jane Doe', 'active' => true, ], ], 'backup' => [ [ - '_id' => 'abcde', + '_id' => 'abcde', 'entry' => 'log entry', ], ], @@ -214,7 +214,7 @@ public function testPersistForManagerWithAliasesWithoutAutocommit() // Simulate state during rebuilding when write alias points to more than 1 index $settings = [ 'index' => 'sineflow-esb-test-temp', - 'body' => ['mappings' => ['properties' => ['name' => ['type' => 'keyword']]]], + 'body' => ['mappings' => ['properties' => ['name' => ['type' => 'keyword']]]], ]; $imWithAliases->getConnection()->getClient()->indices()->create($settings); $setAliasParams = [ @@ -239,7 +239,7 @@ public function testPersistForManagerWithAliasesWithoutAutocommit() // Check that value is set in the additional index for the write alias as well $raw = $imWithAliases->getConnection()->getClient()->get([ 'index' => 'sineflow-esb-test-temp', - 'id' => 555, + 'id' => 555, ]); $this->assertEquals('John Doe', $raw['_source']['name']); @@ -252,8 +252,8 @@ public function testPersistRawWithAutocommit() $imWithAliases->getConnection()->setAutocommit(true); $imWithAliases->persistRaw([ - '_id' => 444, - 'name' => 'Jane', + '_id' => 444, + 'name' => 'Jane', '_score' => 1, ]); @@ -307,7 +307,7 @@ public function testDelete() // Simulate state during rebuilding when write alias points to more than 1 index $settings = [ 'index' => 'sineflow-esb-test-temp', - 'body' => ['mappings' => ['properties' => ['name' => ['type' => 'keyword']]]], + 'body' => ['mappings' => ['properties' => ['name' => ['type' => 'keyword']]]], ]; $imWithAliases->getConnection()->getClient()->indices()->create($settings); $setAliasParams = [ @@ -330,7 +330,7 @@ public function testDelete() // Check that value is deleted in the additional index for the write alias as well $imWithAliases->getConnection()->getClient()->get([ 'index' => 'sineflow-esb-test-temp', - 'id' => 111, + 'id' => 111, ]); } diff --git a/tests/Functional/Mapping/DocumentMetadataCollectorTest.php b/tests/Functional/Mapping/DocumentMetadataCollectorTest.php index 1c07eea..078bd44 100644 --- a/tests/Functional/Mapping/DocumentMetadataCollectorTest.php +++ b/tests/Functional/Mapping/DocumentMetadataCollectorTest.php @@ -63,35 +63,35 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase ], 'propertiesMetadata' => [ 'name' => [ - 'propertyName' => 'name', - 'type' => 'keyword', - 'multilanguage' => null, + 'propertyName' => 'name', + 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'active' => [ - 'propertyName' => 'active', - 'type' => 'boolean', + 'propertyName' => 'active', + 'type' => 'boolean', 'multilanguage' => null, - 'methods' => [ + 'methods' => [ 'getter' => 'isActive', 'setter' => 'setActive', ], 'propertyAccess' => 2, ], '_id' => [ - 'propertyName' => 'id', - 'type' => 'keyword', + 'propertyName' => 'id', + 'type' => 'keyword', 'propertyAccess' => 1, ], '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', + 'propertyName' => 'score', + 'type' => 'float', 'propertyAccess' => 1, ], ], 'repositoryClass' => null, - 'providerClass' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\FooBundle\\Document\\Provider\\CustomerProvider', - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\FooBundle\\Document\\Customer', + 'providerClass' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\FooBundle\\Document\\Provider\\CustomerProvider', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\FooBundle\\Document\\Customer', ]; private $expectedProductMetadata = [ @@ -158,9 +158,9 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase ], 'ml_info-en' => [ 'analyzer' => 'en_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ - 'type' => 'text', + 'type' => 'text', 'analyzer' => 'en_analyzer', ], ], @@ -168,16 +168,16 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase ], 'ml_info-fr' => [ 'analyzer' => 'default_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ - 'type' => 'text', + 'type' => 'text', 'analyzer' => 'default_analyzer', ], ], 'type' => 'text', ], 'ml_info-default' => [ - 'type' => 'keyword', + 'type' => 'keyword', 'ignore_above' => 256, ], 'ml_more_info-en' => [ @@ -187,13 +187,13 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase 'type' => 'text', ], 'ml_more_info-default' => [ - 'type' => 'text', + 'type' => 'text', 'index' => false, ], 'pieces_count' => [ 'fields' => [ 'count' => [ - 'type' => 'token_count', + 'type' => 'token_count', 'analyzer' => 'whitespace', ], ], @@ -205,149 +205,149 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase ], 'propertiesMetadata' => [ 'title' => [ - 'propertyName' => 'title', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'description' => [ - 'propertyName' => 'description', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'description', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'category' => [ - 'propertyName' => 'category', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => null, + 'propertyName' => 'category', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => null, 'propertiesMetadata' => [ 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', 'propertyAccess' => 1, ], 'related_categories' => [ - 'propertyName' => 'relatedCategories', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'relatedCategories', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', 'propertyAccess' => 1, ], 'price' => [ - 'propertyName' => 'price', - 'type' => 'float', - 'multilanguage' => null, + 'propertyName' => 'price', + 'type' => 'float', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'location' => [ - 'propertyName' => 'location', - 'type' => 'geo_point', - 'multilanguage' => null, + 'propertyName' => 'location', + 'type' => 'geo_point', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'limited' => [ - 'propertyName' => 'limited', - 'type' => 'boolean', - 'multilanguage' => null, + 'propertyName' => 'limited', + 'type' => 'boolean', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'released' => [ - 'propertyName' => 'released', - 'type' => 'date', - 'multilanguage' => null, + 'propertyName' => 'released', + 'type' => 'date', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'ml_info' => [ - 'propertyName' => 'mlInfo', - 'type' => 'text', - 'multilanguage' => true, + 'propertyName' => 'mlInfo', + 'type' => 'text', + 'multilanguage' => true, 'propertyAccess' => 1, ], 'ml_more_info' => [ - 'propertyName' => 'mlMoreInfo', - 'type' => 'text', - 'multilanguage' => true, + 'propertyName' => 'mlMoreInfo', + 'type' => 'text', + 'multilanguage' => true, 'propertyAccess' => 1, ], 'pieces_count' => [ - 'propertyName' => 'tokenPiecesCount', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tokenPiecesCount', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], '_id' => [ - 'propertyName' => 'id', - 'type' => 'keyword', + 'propertyName' => 'id', + 'type' => 'keyword', 'propertyAccess' => 1, ], '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', + 'propertyName' => 'score', + 'type' => 'float', 'propertyAccess' => 1, ], ], 'repositoryClass' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Repository\\ProductRepository', - 'providerClass' => null, - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Product', + 'providerClass' => null, + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Product', ]; protected function setUp(): void diff --git a/tests/Functional/Mapping/DocumentParserTest.php b/tests/Functional/Mapping/DocumentParserTest.php index b9083e7..9b92637 100644 --- a/tests/Functional/Mapping/DocumentParserTest.php +++ b/tests/Functional/Mapping/DocumentParserTest.php @@ -112,9 +112,9 @@ public function testParse() ], 'ml_info-en' => [ 'analyzer' => 'en_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ - 'type' => 'text', + 'type' => 'text', 'analyzer' => 'en_analyzer', ], ], @@ -122,16 +122,16 @@ public function testParse() ], 'ml_info-fr' => [ 'analyzer' => 'default_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ - 'type' => 'text', + 'type' => 'text', 'analyzer' => 'default_analyzer', ], ], 'type' => 'text', ], 'ml_info-default' => [ - 'type' => 'keyword', + 'type' => 'keyword', 'ignore_above' => 256, ], 'ml_more_info-en' => [ @@ -141,13 +141,13 @@ public function testParse() 'type' => 'text', ], 'ml_more_info-default' => [ - 'type' => 'text', + 'type' => 'text', 'index' => false, ], 'pieces_count' => [ 'fields' => [ 'count' => [ - 'type' => 'token_count', + 'type' => 'token_count', 'analyzer' => 'whitespace', ], ], @@ -159,149 +159,149 @@ public function testParse() ], 'propertiesMetadata' => [ 'title' => [ - 'propertyName' => 'title', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'description' => [ - 'propertyName' => 'description', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'description', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'category' => [ - 'propertyName' => 'category', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => null, + 'propertyName' => 'category', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => null, 'propertiesMetadata' => [ 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', 'propertyAccess' => 1, ], 'related_categories' => [ - 'propertyName' => 'relatedCategories', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'relatedCategories', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, 'propertiesMetadata' => [ 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', 'propertyAccess' => 1, ], 'price' => [ - 'propertyName' => 'price', - 'type' => 'float', - 'multilanguage' => null, + 'propertyName' => 'price', + 'type' => 'float', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'location' => [ - 'propertyName' => 'location', - 'type' => 'geo_point', - 'multilanguage' => null, + 'propertyName' => 'location', + 'type' => 'geo_point', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'limited' => [ - 'propertyName' => 'limited', - 'type' => 'boolean', - 'multilanguage' => null, + 'propertyName' => 'limited', + 'type' => 'boolean', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'released' => [ - 'propertyName' => 'released', - 'type' => 'date', - 'multilanguage' => null, + 'propertyName' => 'released', + 'type' => 'date', + 'multilanguage' => null, 'propertyAccess' => 1, ], 'ml_info' => [ - 'propertyName' => 'mlInfo', - 'type' => 'text', - 'multilanguage' => true, + 'propertyName' => 'mlInfo', + 'type' => 'text', + 'multilanguage' => true, 'propertyAccess' => 1, ], 'ml_more_info' => [ - 'propertyName' => 'mlMoreInfo', - 'type' => 'text', - 'multilanguage' => true, + 'propertyName' => 'mlMoreInfo', + 'type' => 'text', + 'multilanguage' => true, 'propertyAccess' => 1, ], 'pieces_count' => [ - 'propertyName' => 'tokenPiecesCount', - 'type' => 'text', - 'multilanguage' => null, + 'propertyName' => 'tokenPiecesCount', + 'type' => 'text', + 'multilanguage' => null, 'propertyAccess' => 1, ], '_id' => [ - 'propertyName' => 'id', - 'type' => 'keyword', + 'propertyName' => 'id', + 'type' => 'keyword', 'propertyAccess' => 1, ], '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', + 'propertyName' => 'score', + 'type' => 'float', 'propertyAccess' => 1, ], ], 'repositoryClass' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Repository\\ProductRepository', - 'providerClass' => null, - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Product', + 'providerClass' => null, + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Product', ]; $this->assertEquals($expected, $res); diff --git a/tests/Functional/Profiler/ElasticsearchProfilerTest.php b/tests/Functional/Profiler/ElasticsearchProfilerTest.php index 994b183..4b6fdd2 100644 --- a/tests/Functional/Profiler/ElasticsearchProfilerTest.php +++ b/tests/Functional/Profiler/ElasticsearchProfilerTest.php @@ -22,15 +22,15 @@ protected function getDataArray() 'default' => [ 'product' => [ [ - '_id' => 1, + '_id' => 1, 'title' => 'foo', ], [ - '_id' => 2, + '_id' => 2, 'title' => 'bar', ], [ - '_id' => 3, + '_id' => 3, 'title' => 'pizza', ], ], @@ -95,13 +95,13 @@ public function testCorrectDataLogged() $this->assertArraySubset( [ - 'curlRequest' => "curl -XPOST 'http://".\implode(':', $esHostAndPort)."/sineflow-esb-test-bar/_search?pretty=true' -d '{\"query\":{\"ids\":{\"values\":[\"3\"]}},\"version\":true}'", + 'curlRequest' => "curl -XPOST 'http://".\implode(':', $esHostAndPort)."/sineflow-esb-test-bar/_search?pretty=true' -d '{\"query\":{\"ids\":{\"values\":[\"3\"]}},\"version\":true}'", 'senseRequest' => "POST /sineflow-esb-test-bar/_search\n{\"query\":{\"ids\":{\"values\":[\"3\"]}},\"version\":true}", - 'backtrace' => null, - 'scheme' => 'http', - 'host' => $esHostAndPort[0], - 'port' => (int) $esHostAndPort[1], - 'path' => '/sineflow-esb-test-bar/_search', + 'backtrace' => null, + 'scheme' => 'http', + 'host' => $esHostAndPort[0], + 'port' => (int) $esHostAndPort[1], + 'path' => '/sineflow-esb-test-bar/_search', ], $lastQuery, 'Logged data did not match expected data.' diff --git a/tests/Functional/Result/DocumentConverterTest.php b/tests/Functional/Result/DocumentConverterTest.php index 9d66b7a..cd37378 100644 --- a/tests/Functional/Result/DocumentConverterTest.php +++ b/tests/Functional/Result/DocumentConverterTest.php @@ -17,8 +17,8 @@ class DocumentConverterTest extends AbstractContainerAwareTestCase use ArraySubsetAsserts; private $fullDocArray = [ - '_id' => 'doc1', - 'title' => 'Foo Product', + '_id' => 'doc1', + 'title' => 'Foo Product', 'category' => [ 'title' => 'Bar', ], @@ -27,9 +27,9 @@ class DocumentConverterTest extends AbstractContainerAwareTestCase 'title' => 'Acme', ], ], - 'ml_info-en' => 'info in English', - 'ml_info-fr' => 'info in French', - 'ml_info' => 'should be skipped', + 'ml_info-en' => 'info in English', + 'ml_info-fr' => 'info in French', + 'ml_info' => 'should be skipped', 'nonexisting' => 'should be skipped', ]; @@ -40,9 +40,9 @@ public function testAssignArrayToObjectWithNestedSingleValueInsteadOfArray() // Raw doc with a single object value where an array of objects is expected according to metadata def $rawDoc = [ - '_id' => 'rawDocWithSingleObjValueInsteadOfArray', + '_id' => 'rawDocWithSingleObjValueInsteadOfArray', 'related_categories' => [ - 'id' => '123', + 'id' => '123', 'title' => 'Acme', ], ]; @@ -65,10 +65,10 @@ public function testAssignArrayToObjectWithNestedSingleValueArrayInsteadOfSingle // Raw doc with array of single object where a single object value is expected according to metadata def $rawDoc = [ - '_id' => 'rawDocWithArrayValueInsteadOfSingleObject', + '_id' => 'rawDocWithArrayValueInsteadOfSingleObject', 'category' => [ [ - 'id' => '123', + 'id' => '123', 'title' => 'Acme', ], ], @@ -91,14 +91,14 @@ public function testAssignArrayToObjectWithNestedMultiValueArrayInsteadOfSingleV // Raw doc with array of many objects where a single object value is expected according to metadata def $rawDoc = [ - '_id' => 'rawDocWithArrayValueInsteadOfSingleObject', + '_id' => 'rawDocWithArrayValueInsteadOfSingleObject', 'category' => [ [ - 'id' => '123', + 'id' => '123', 'title' => 'Acme', ], [ - 'id' => '234', + 'id' => '234', 'title' => 'Ucme', ], ], @@ -197,12 +197,12 @@ public function testConvertToArray(Product $product) public function testConvertToDocumentWithSource() { $rawFromEs = [ - '_index' => 'sineflow-esb-test-bar', - '_id' => 'doc1', + '_index' => 'sineflow-esb-test-bar', + '_id' => 'doc1', '_version' => 1, - 'found' => true, - '_source' => [ - 'title' => 'Foo Product', + 'found' => true, + '_source' => [ + 'title' => 'Foo Product', 'category' => [ 'title' => 'Bar', ], @@ -234,7 +234,7 @@ public function testConvertToDocumentWithFields() { $rawFromEs = [ '_index' => 'sineflow-esb-test-bar', - '_id' => 'doc1', + '_id' => 'doc1', '_score' => 1, 'fields' => [ 'title' => [ diff --git a/tests/Functional/Result/DocumentIteratorTest.php b/tests/Functional/Result/DocumentIteratorTest.php index 9c477a9..3405d08 100644 --- a/tests/Functional/Result/DocumentIteratorTest.php +++ b/tests/Functional/Result/DocumentIteratorTest.php @@ -23,11 +23,11 @@ protected function getDataArray() return [ 'bar' => [ [ - '_id' => '1', - 'title' => 'Foo Product', + '_id' => '1', + 'title' => 'Foo Product', 'category' => [ 'title' => 'Bar', - 'tags' => [ + 'tags' => [ ['tagname' => 'first tag'], ['tagname' => 'second tag'], ], @@ -35,7 +35,7 @@ protected function getDataArray() 'related_categories' => [ [ 'title' => 'Acme', - 'tags' => [ + 'tags' => [ ['tagname' => 'tutu'], ], ], @@ -47,9 +47,9 @@ protected function getDataArray() 'ml_info-fr' => 'info in French', ], [ - '_id' => '2', - 'title' => 'Bar Product', - 'category' => null, + '_id' => '2', + 'title' => 'Bar Product', + 'category' => null, 'related_categories' => [ [ 'title' => 'Acme', @@ -60,8 +60,8 @@ protected function getDataArray() ], ], [ - '_id' => '3', - 'title' => '3rd Product', + '_id' => '3', + 'title' => '3rd Product', 'related_categories' => [], ], [ @@ -197,7 +197,7 @@ public function testAggregations() /** @var DocumentIterator $iterator */ $iterator = $repo->find([ 'query' => ['match_all' => (object) []], - 'aggs' => [ + 'aggs' => [ 'my_count' => [ 'value_count' => [ 'field' => 'title.raw', @@ -221,12 +221,12 @@ public function testSuggestions() /** @var DocumentIterator $iterator */ $iterator = $repo->find([ - 'query' => ['match_all' => (object) []], + 'query' => ['match_all' => (object) []], 'suggest' => [ 'title-suggestions' => [ 'text' => ['prodcut foot'], 'term' => [ - 'size' => 3, + 'size' => 3, 'field' => 'title', ], ], diff --git a/tests/Unit/Annotation/DocumentTest.php b/tests/Unit/Annotation/DocumentTest.php index 903d50a..e1cca77 100644 --- a/tests/Unit/Annotation/DocumentTest.php +++ b/tests/Unit/Annotation/DocumentTest.php @@ -20,13 +20,13 @@ public function testDump() $doc->type = 'product'; $doc->options = [ 'dynamic' => 'strict', - 'foo' => 'bar', + 'foo' => 'bar', ]; $this->assertEquals( [ 'dynamic' => 'strict', - 'foo' => 'bar', + 'foo' => 'bar', ], $doc->dump(), 'All and only options should be dumped' diff --git a/tests/Unit/Annotation/PropertyTest.php b/tests/Unit/Annotation/PropertyTest.php index 0bc5355..5cbe007 100644 --- a/tests/Unit/Annotation/PropertyTest.php +++ b/tests/Unit/Annotation/PropertyTest.php @@ -23,17 +23,17 @@ public function testDump() $type->objectName = 'foo/bar'; $type->multiple = null; $type->options = [ - 'type' => 'this should not be set here', + 'type' => 'this should not be set here', 'analyzer' => 'standard', - 'foo' => 'bar', + 'foo' => 'bar', ]; $type->foo = 'bar'; $this->assertEquals( [ 'analyzer' => 'standard', - 'foo' => 'bar', - 'type' => 'mytype', + 'foo' => 'bar', + 'type' => 'mytype', ], $type->dump(), 'Properties should be filtered' @@ -53,9 +53,9 @@ public function testDumpML() $type->objectName = 'foo/bar'; $type->multiple = null; $type->options = [ - 'copy_to' => '{lang}_all', + 'copy_to' => '{lang}_all', 'analyzer' => '{lang}_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ 'analyzer' => '{lang}_analyzer', ], @@ -63,7 +63,7 @@ public function testDumpML() ]; $settings = [ - 'language' => 'en', + 'language' => 'en', 'indexAnalyzers' => [ 'default_analyzer' => [ 'type' => 'standard', @@ -76,9 +76,9 @@ public function testDumpML() $this->assertEquals( [ - 'copy_to' => 'en_all', + 'copy_to' => 'en_all', 'analyzer' => 'en_analyzer', - 'fields' => [ + 'fields' => [ 'ngram' => [ 'analyzer' => 'en_analyzer', ], @@ -131,7 +131,7 @@ public function testDumpNoDefaultException() ]; $settings = [ - 'language' => 'en', + 'language' => 'en', 'indexAnalyzers' => [ 'en_analyzer' => [ 'type' => 'standard', diff --git a/tests/Unit/DTO/BulkQueryItemTest.php b/tests/Unit/DTO/BulkQueryItemTest.php index c6e7823..f546a4b 100644 --- a/tests/Unit/DTO/BulkQueryItemTest.php +++ b/tests/Unit/DTO/BulkQueryItemTest.php @@ -22,7 +22,7 @@ public function getLinesProvider() [ 'index' => [ '_index' => 'myindex', - '_id' => 3, + '_id' => 3, ], ], [ @@ -49,7 +49,7 @@ public function getLinesProvider() [ 'update' => [ '_index' => 'forcedindex', - '_id' => 3, + '_id' => 3, ], ], [], @@ -62,7 +62,7 @@ public function getLinesProvider() [ 'delete' => [ '_index' => 'myindex', - '_id' => 3, + '_id' => 3, ], ], ], diff --git a/tests/Unit/DependencyInjection/Compiler/AddIndexManagersPassTest.php b/tests/Unit/DependencyInjection/Compiler/AddIndexManagersPassTest.php index 04b7311..d380231 100644 --- a/tests/Unit/DependencyInjection/Compiler/AddIndexManagersPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/AddIndexManagersPassTest.php @@ -19,20 +19,20 @@ public function testProcessWithSeveralManagers() { $connections = [ 'test1' => [ - 'hosts' => ['user:pass@eshost:1111'], - 'profiling' => false, - 'logging' => false, + 'hosts' => ['user:pass@eshost:1111'], + 'profiling' => false, + 'logging' => false, 'bulk_batch_size' => 123, ], ]; $managers = [ 'test' => [ - 'name' => 'testname', - 'connection' => 'test1', + 'name' => 'testname', + 'connection' => 'test1', 'use_aliases' => false, - 'settings' => [ - 'refresh_interval' => 2, + 'settings' => [ + 'refresh_interval' => 2, 'number_of_replicas' => 3, ], 'class' => 'testBundle:Foo', diff --git a/tests/Unit/DependencyInjection/ElasticsearchExtensionTest.php b/tests/Unit/DependencyInjection/ElasticsearchExtensionTest.php index 06f2e6e..c8cb67e 100644 --- a/tests/Unit/DependencyInjection/ElasticsearchExtensionTest.php +++ b/tests/Unit/DependencyInjection/ElasticsearchExtensionTest.php @@ -41,8 +41,8 @@ public function getData() 'hosts' => [ 'user:pass@eshost:1111', ], - 'profiling' => false, - 'logging' => false, + 'profiling' => false, + 'logging' => false, 'bulk_batch_size' => 123, ], ], @@ -53,7 +53,7 @@ public function getData() 'mapping.nested_fields.limit' => 10, ], 'number_of_replicas' => 1, - 'analysis' => [ + 'analysis' => [ 'filter' => [ 'base_filter' => [ 'type' => 'custom', @@ -63,14 +63,14 @@ public function getData() ], ], 'test' => [ - 'extends' => '_base', - 'name' => 'testname', - 'connection' => 'test1', + 'extends' => '_base', + 'name' => 'testname', + 'connection' => 'test1', 'use_aliases' => false, - 'settings' => [ - 'refresh_interval' => 2, + 'settings' => [ + 'refresh_interval' => 2, 'number_of_replicas' => 3, - 'analysis' => [ + 'analysis' => [ 'filter' => [ 'test_filter' => [ 'type' => 'ngram', @@ -103,23 +103,23 @@ public function getData() $expectedConnections = [ 'test1' => [ - 'hosts' => ['user:pass@eshost:1111'], - 'profiling' => false, - 'logging' => false, - 'bulk_batch_size' => 123, + 'hosts' => ['user:pass@eshost:1111'], + 'profiling' => false, + 'logging' => false, + 'bulk_batch_size' => 123, 'ssl_verification' => null, ], ]; $expectedManagers = [ 'test' => [ - 'name' => 'testname', - 'connection' => 'test1', + 'name' => 'testname', + 'connection' => 'test1', 'use_aliases' => false, - 'settings' => [ - 'refresh_interval' => 2, + 'settings' => [ + 'refresh_interval' => 2, 'number_of_replicas' => 3, - 'index' => [ + 'index' => [ 'mapping.nested_fields.limit' => 10, ], 'analysis' => [ diff --git a/tests/Unit/Document/MLPropertyTest.php b/tests/Unit/Document/MLPropertyTest.php index 2c9ca3f..8a4d384 100644 --- a/tests/Unit/Document/MLPropertyTest.php +++ b/tests/Unit/Document/MLPropertyTest.php @@ -57,8 +57,8 @@ public function testGetValues() $this->assertEquals( [ 'default' => 'test default', - 'en' => 'test en', - 'bg' => 'test bg', + 'en' => 'test en', + 'bg' => 'test bg', ], $mlProperty->getValues(), 'MLProperty does not return all values correctly.' @@ -72,15 +72,15 @@ public function testConstruct() { $mlProperty = new MLProperty([ 'default' => 'test default', - 'en' => 'test en', - 'bg' => 'test bg', + 'en' => 'test en', + 'bg' => 'test bg', ]); $this->assertEquals( [ 'default' => 'test default', - 'en' => 'test en', - 'bg' => 'test bg', + 'en' => 'test en', + 'bg' => 'test bg', ], $mlProperty->getValues(), 'MLProperty construct does not set all values correctly.' diff --git a/tests/Unit/Mapping/CaserTest.php b/tests/Unit/Mapping/CaserTest.php index e6f594b..840942e 100644 --- a/tests/Unit/Mapping/CaserTest.php +++ b/tests/Unit/Mapping/CaserTest.php @@ -35,6 +35,7 @@ public function providerForSnake() /** * @param string $input * @param string $expected + * * @dataProvider providerForCamel */ public function testCamel($input, $expected) @@ -45,6 +46,7 @@ public function testCamel($input, $expected) /** * @param string $input * @param string $expected + * * @dataProvider providerForSnake */ public function testSnake($input, $expected) diff --git a/tests/tests.bootstrap.php b/tests/tests.bootstrap.php index 991ea43..a532347 100644 --- a/tests/tests.bootstrap.php +++ b/tests/tests.bootstrap.php @@ -1,3 +1,12 @@ bootEnv(dirname(__DIR__).'/.env'); +}