diff --git a/.github/workflows/phpunit-tests.yml b/.github/workflows/phpunit-tests.yml index aa95c42..dcde895 100644 --- a/.github/workflows/phpunit-tests.yml +++ b/.github/workflows/phpunit-tests.yml @@ -48,39 +48,39 @@ jobs: - 'highest' php: - '8.1' - - '8.2' + - '8.3' elasticsearch: - - '7.17.13' + - '7.17.24' symfony: - - '~5.0' + - '~6.0' include: - - php: '8.1' - symfony: '~5.0' + - php: '8.3' + symfony: '~6.0' elasticsearch: '8.0.1' experimental: false - - php: '8.1' - symfony: '~5.0' + - php: '8.3' + symfony: '~6.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' + - php: '8.3' + symfony: '~6.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' + - php: '8.3' + symfony: '~6.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' + - php: '8.3' + symfony: '~6.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' + - php: '8.3' + symfony: '~6.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 + symfony: '~5.0' + elasticsearch: '8.15.2' # newest version experimental: false fail-fast: false steps: @@ -115,7 +115,7 @@ jobs: - name: 'Run phpunit tests' run: | - vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml 2>/dev/null + vendor/bin/simple-phpunit --coverage-clover=tests/App/build/clover.xml - name: Upload coverage results to Coveralls env: diff --git a/composer.json b/composer.json index cf9d7af..64e5229 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,13 @@ "php": "^7.3 || ^8.0", "psr/log": "^1.0", - "symfony/framework-bundle": "^4.4 || ^5.0", - "symfony/options-resolver": "^4.4 || ^5.0", - "symfony/config": "^4.4 || ^5.0", - "symfony/event-dispatcher": "^4.4 || ^5.0", - "symfony/translation": "^4.4 || ^5.0", - "symfony/console": "^4.4 || ^5.0", - "symfony/http-kernel": "^4.4 || ^5.0", + "symfony/framework-bundle": "^4.4 || ^5.0 || ^6.0", + "symfony/options-resolver": "^4.4 || ^5.0 || ^6.0", + "symfony/config": "^4.4 || ^5.0 || ^6.0", + "symfony/event-dispatcher": "^4.4 || ^5.0 || ^6.0", + "symfony/translation": "^4.4 || ^5.0 || ^6.0", + "symfony/console": "^4.4 || ^5.0 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.0 || ^6.0", "symfony/event-dispatcher-contracts": "^1.1 || ^2.2", "doctrine/annotations": "^1.2", @@ -28,11 +28,11 @@ "elasticsearch/elasticsearch": "^7.0" }, "require-dev": { - "symfony/debug": "^4.4 || ^5.0", - "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", + "symfony/debug": "^4.4 || ^5.0 || ^6.0", + "symfony/stopwatch": "^4.4 || ^5.0 || ^6.0", + "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6.0", + "symfony/browser-kit": "^4.4 || ^5.0 || ^6.0", + "symfony/dotenv": "^4.4 || ^5.0 || ^6.0", "doctrine/orm": "^2.6.3", "monolog/monolog": "^1.0|^2.0|^3.0", diff --git a/src/Annotation/DocObject.php b/src/Annotation/DocObject.php index 3820afc..2f34eba 100644 --- a/src/Annotation/DocObject.php +++ b/src/Annotation/DocObject.php @@ -6,7 +6,6 @@ * Annotation to mark a class as an object during the parsing process. * * @Annotation - * * @Target("CLASS") */ final class DocObject diff --git a/src/Annotation/Document.php b/src/Annotation/Document.php index 936946c..92d7b0c 100644 --- a/src/Annotation/Document.php +++ b/src/Annotation/Document.php @@ -8,7 +8,6 @@ * Annotation to mark a class as an Elasticsearch document. * * @Annotation - * * @Target("CLASS") */ final class Document implements DumperInterface diff --git a/src/Annotation/Id.php b/src/Annotation/Id.php index 8f3fa30..004943a 100644 --- a/src/Annotation/Id.php +++ b/src/Annotation/Id.php @@ -6,7 +6,6 @@ * Annotation used for the meta _id field * * @Annotation - * * @Target("PROPERTY") */ final class Id diff --git a/src/Annotation/Property.php b/src/Annotation/Property.php index e05d0e2..be087b8 100644 --- a/src/Annotation/Property.php +++ b/src/Annotation/Property.php @@ -8,7 +8,6 @@ * Annotation used to check mapping type during the parsing process. * * @Annotation - * * @Target("PROPERTY") */ final class Property implements DumperInterface diff --git a/src/Annotation/Score.php b/src/Annotation/Score.php index 342b5a2..2d148ec 100644 --- a/src/Annotation/Score.php +++ b/src/Annotation/Score.php @@ -6,7 +6,6 @@ * 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 ad0389c..3ab2678 100644 --- a/src/Document/Provider/ElasticsearchProvider.php +++ b/src/Document/Provider/ElasticsearchProvider.php @@ -45,7 +45,7 @@ class ElasticsearchProvider extends AbstractProvider public function __construct( DocumentMetadataCollector $metadataCollector, IndexManager $sourceIndexManager, - string $sourceDocumentClass + string $sourceDocumentClass, ) { $this->metadataCollector = $metadataCollector; $this->sourceIndexManager = $sourceIndexManager; diff --git a/src/Document/Provider/ProviderRegistry.php b/src/Document/Provider/ProviderRegistry.php index 18f2f04..f1bb1a2 100644 --- a/src/Document/Provider/ProviderRegistry.php +++ b/src/Document/Provider/ProviderRegistry.php @@ -38,7 +38,7 @@ public function __construct( ServiceLocator $serviceLocator, DocumentMetadataCollector $documentMetadataCollector, IndexManagerRegistry $indexManagerRegistry, - string $selfProviderClass + string $selfProviderClass, ) { $this->serviceLocator = $serviceLocator; $this->documentMetadataCollector = $documentMetadataCollector; diff --git a/src/Document/Repository/Repository.php b/src/Document/Repository/Repository.php index 93e7bca..3617186 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 0a2796d..540bd45 100644 --- a/src/Exception/IndexOrAliasNotFoundException.php +++ b/src/Exception/IndexOrAliasNotFoundException.php @@ -17,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 c44b130..db79f37 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/Finder.php b/src/Finder/Finder.php index 30fa5e7..e54703e 100644 --- a/src/Finder/Finder.php +++ b/src/Finder/Finder.php @@ -48,7 +48,7 @@ class Finder public function __construct( DocumentMetadataCollector $documentMetadataCollector, IndexManagerRegistry $indexManagerRegistry, - DocumentConverter $documentConverter + DocumentConverter $documentConverter, ) { $this->documentMetadataCollector = $documentMetadataCollector; $this->indexManagerRegistry = $indexManagerRegistry; @@ -154,7 +154,7 @@ 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(); @@ -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 d8808ec..9848bc3 100644 --- a/src/Manager/IndexManager.php +++ b/src/Manager/IndexManager.php @@ -105,7 +105,7 @@ public function __construct( ProviderRegistry $providerRegistry, Finder $finder, DocumentConverter $documentConverter, - RepositoryFactory $repositoryFactory + RepositoryFactory $repositoryFactory, ) { $this->managerName = $managerName; $this->connection = $connection; @@ -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 ec6693e..c3b7b68 100644 --- a/src/Mapping/DocumentParser.php +++ b/src/Mapping/DocumentParser.php @@ -311,7 +311,7 @@ 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, diff --git a/src/Profiler/ElasticsearchProfiler.php b/src/Profiler/ElasticsearchProfiler.php index 1362952..bd93f5f 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); diff --git a/tests/App/AppKernel.php b/tests/App/AppKernel.php index f058abf..81c19a9 100644 --- a/tests/App/AppKernel.php +++ b/tests/App/AppKernel.php @@ -20,7 +20,7 @@ class AppKernel extends Kernel * * @return array */ - public function registerBundles() + public function registerBundles(): iterable { $bundles = [ new FrameworkBundle(), diff --git a/tests/Functional/Mapping/DocumentMetadataCollectorTest.php b/tests/Functional/Mapping/DocumentMetadataCollectorTest.php index 078bd44..dce8e78 100644 --- a/tests/Functional/Mapping/DocumentMetadataCollectorTest.php +++ b/tests/Functional/Mapping/DocumentMetadataCollectorTest.php @@ -52,43 +52,43 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase */ private $expectedCustomerMetadata = [ 'properties' => [ - 'name' => [ - 'type' => 'keyword', - ], - 'active' => [ - 'type' => 'boolean', - ], + 'name' => [ + 'type' => 'keyword', ], - 'fields' => [ + 'active' => [ + 'type' => 'boolean', ], + ], + 'fields' => [ + ], 'propertiesMetadata' => [ - 'name' => [ - 'propertyName' => 'name', - 'type' => 'keyword', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'active' => [ - 'propertyName' => 'active', - 'type' => 'boolean', - 'multilanguage' => null, - 'methods' => [ - 'getter' => 'isActive', - 'setter' => 'setActive', - ], - 'propertyAccess' => 2, - ], - '_id' => [ - 'propertyName' => 'id', - 'type' => 'keyword', - 'propertyAccess' => 1, - ], - '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', - 'propertyAccess' => 1, - ], + 'name' => [ + 'propertyName' => 'name', + 'type' => 'keyword', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'active' => [ + 'propertyName' => 'active', + 'type' => 'boolean', + 'multilanguage' => null, + 'methods' => [ + 'getter' => 'isActive', + 'setter' => 'setActive', + ], + 'propertyAccess' => 2, ], + '_id' => [ + 'propertyName' => 'id', + 'type' => 'keyword', + 'propertyAccess' => 1, + ], + '_score' => [ + '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', @@ -96,255 +96,255 @@ class DocumentMetadataCollectorTest extends AbstractContainerAwareTestCase private $expectedProductMetadata = [ 'properties' => [ - 'title' => [ - 'fields' => [ - 'raw' => [ - 'type' => 'keyword', - ], - 'title' => [ - 'type' => 'text', - ], - ], - 'type' => 'text', + 'title' => [ + 'fields' => [ + 'raw' => [ + 'type' => 'keyword', ], - 'description' => [ + 'title' => [ 'type' => 'text', ], - 'category' => [ - 'properties' => [ - 'id' => [ - 'type' => 'integer', - ], - 'title' => [ - 'type' => 'keyword', - ], - 'tags' => [ - 'properties' => [ - 'tagname' => [ - 'type' => 'text', - ], - ], - ], - ], + ], + 'type' => 'text', + ], + 'description' => [ + 'type' => 'text', + ], + 'category' => [ + 'properties' => [ + 'id' => [ + 'type' => 'integer', ], - 'related_categories' => [ + 'title' => [ + 'type' => 'keyword', + ], + 'tags' => [ 'properties' => [ - 'id' => [ - 'type' => 'integer', - ], - 'title' => [ - 'type' => 'keyword', - ], - 'tags' => [ - 'properties' => [ - 'tagname' => [ - 'type' => 'text', - ], - ], - ], + 'tagname' => [ + 'type' => 'text', ], + ], ], - 'price' => [ - 'type' => 'float', - ], - 'location' => [ - 'type' => 'geo_point', + ], + ], + 'related_categories' => [ + 'properties' => [ + 'id' => [ + 'type' => 'integer', ], - 'limited' => [ - 'type' => 'boolean', + 'title' => [ + 'type' => 'keyword', ], - 'released' => [ - 'type' => 'date', + 'tags' => [ + 'properties' => [ + 'tagname' => [ + 'type' => 'text', + ], + ], ], - 'ml_info-en' => [ + ], + ], + 'price' => [ + 'type' => 'float', + ], + 'location' => [ + 'type' => 'geo_point', + ], + 'limited' => [ + 'type' => 'boolean', + ], + 'released' => [ + 'type' => 'date', + ], + 'ml_info-en' => [ + 'analyzer' => 'en_analyzer', + 'fields' => [ + 'ngram' => [ + 'type' => 'text', 'analyzer' => 'en_analyzer', - 'fields' => [ - 'ngram' => [ - 'type' => 'text', - 'analyzer' => 'en_analyzer', - ], - ], - 'type' => 'text', ], - 'ml_info-fr' => [ + ], + 'type' => 'text', + ], + 'ml_info-fr' => [ + 'analyzer' => 'default_analyzer', + 'fields' => [ + 'ngram' => [ + 'type' => 'text', 'analyzer' => 'default_analyzer', - 'fields' => [ - 'ngram' => [ - 'type' => 'text', - 'analyzer' => 'default_analyzer', - ], - ], - 'type' => 'text', - ], - 'ml_info-default' => [ - 'type' => 'keyword', - 'ignore_above' => 256, - ], - 'ml_more_info-en' => [ - 'type' => 'text', - ], - 'ml_more_info-fr' => [ - 'type' => 'text', - ], - 'ml_more_info-default' => [ - 'type' => 'text', - 'index' => false, - ], - 'pieces_count' => [ - 'fields' => [ - 'count' => [ - 'type' => 'token_count', - 'analyzer' => 'whitespace', - ], - ], - 'type' => 'text', ], + ], + 'type' => 'text', ], - 'fields' => [ - 'dynamic' => 'strict', + 'ml_info-default' => [ + 'type' => 'keyword', + 'ignore_above' => 256, + ], + 'ml_more_info-en' => [ + 'type' => 'text', + ], + 'ml_more_info-fr' => [ + 'type' => 'text', + ], + 'ml_more_info-default' => [ + 'type' => 'text', + 'index' => false, ], + 'pieces_count' => [ + 'fields' => [ + 'count' => [ + 'type' => 'token_count', + 'analyzer' => 'whitespace', + ], + ], + 'type' => 'text', + ], + ], + 'fields' => [ + 'dynamic' => 'strict', + ], 'propertiesMetadata' => [ - 'title' => [ - 'propertyName' => 'title', - 'type' => 'text', + 'title' => [ + 'propertyName' => 'title', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'description' => [ + 'propertyName' => 'description', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'category' => [ + 'propertyName' => 'category', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => null, + 'propertiesMetadata' => [ + 'id' => [ + 'propertyName' => 'id', + 'type' => 'integer', 'multilanguage' => null, 'propertyAccess' => 1, ], - 'description' => [ - 'propertyName' => 'description', - 'type' => 'text', + 'title' => [ + 'propertyName' => 'title', + 'type' => 'keyword', 'multilanguage' => null, 'propertyAccess' => 1, ], - 'category' => [ - 'propertyName' => 'category', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => null, - 'propertiesMetadata' => [ - 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, - 'propertiesMetadata' => [ - 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', - 'propertyAccess' => 1, - ], - 'related_categories' => [ - 'propertyName' => 'relatedCategories', + 'tags' => [ + 'propertyName' => 'tags', 'type' => 'object', 'multilanguage' => null, 'multiple' => true, 'propertiesMetadata' => [ - 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, - 'propertiesMetadata' => [ - 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', - 'propertyAccess' => 1, - ], + 'tagname' => [ + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', - 'propertyAccess' => 1, - ], - 'price' => [ - 'propertyName' => 'price', - 'type' => 'float', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'location' => [ - 'propertyName' => 'location', - 'type' => 'geo_point', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'limited' => [ - 'propertyName' => 'limited', - 'type' => 'boolean', - 'multilanguage' => null, + ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], - 'released' => [ - 'propertyName' => 'released', - 'type' => 'date', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'ml_info' => [ - 'propertyName' => 'mlInfo', - 'type' => 'text', - 'multilanguage' => true, - 'propertyAccess' => 1, - ], - 'ml_more_info' => [ - 'propertyName' => 'mlMoreInfo', - 'type' => 'text', - 'multilanguage' => true, - 'propertyAccess' => 1, - ], - 'pieces_count' => [ - 'propertyName' => 'tokenPiecesCount', - 'type' => 'text', + ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'propertyAccess' => 1, + ], + 'related_categories' => [ + 'propertyName' => 'relatedCategories', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, + 'propertiesMetadata' => [ + 'id' => [ + 'propertyName' => 'id', + 'type' => 'integer', 'multilanguage' => null, 'propertyAccess' => 1, ], - '_id' => [ - 'propertyName' => 'id', + 'title' => [ + 'propertyName' => 'title', 'type' => 'keyword', + 'multilanguage' => null, 'propertyAccess' => 1, ], - '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', + 'tags' => [ + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, + 'propertiesMetadata' => [ + 'tagname' => [ + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], + ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'propertyAccess' => 1, + ], + 'price' => [ + 'propertyName' => 'price', + 'type' => 'float', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'location' => [ + 'propertyName' => 'location', + 'type' => 'geo_point', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'limited' => [ + 'propertyName' => 'limited', + 'type' => 'boolean', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'released' => [ + 'propertyName' => 'released', + 'type' => 'date', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'ml_info' => [ + 'propertyName' => 'mlInfo', + 'type' => 'text', + 'multilanguage' => true, + 'propertyAccess' => 1, + ], + 'ml_more_info' => [ + 'propertyName' => 'mlMoreInfo', + 'type' => 'text', + 'multilanguage' => true, + 'propertyAccess' => 1, + ], + 'pieces_count' => [ + 'propertyName' => 'tokenPiecesCount', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + '_id' => [ + 'propertyName' => 'id', + 'type' => 'keyword', + 'propertyAccess' => 1, + ], + '_score' => [ + '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', diff --git a/tests/Functional/Mapping/DocumentParserTest.php b/tests/Functional/Mapping/DocumentParserTest.php index 9b92637..f84734b 100644 --- a/tests/Functional/Mapping/DocumentParserTest.php +++ b/tests/Functional/Mapping/DocumentParserTest.php @@ -39,269 +39,269 @@ public function testParse() $reflection = new \ReflectionClass('Sineflow\ElasticsearchBundle\Tests\App\Fixture\Acme\BarBundle\Document\Product'); $indexAnalyzers = [ 'default_analyzer' => [ - 'type' => 'standard', - ], + 'type' => 'standard', + ], 'en_analyzer' => [ - 'type' => 'standard', - ], + 'type' => 'standard', + ], ]; $res = $this->documentParser->parse($reflection, $indexAnalyzers); $expected = [ 'properties' => [ - 'title' => [ - 'fields' => [ - 'raw' => [ - 'type' => 'keyword', - ], - 'title' => [ - 'type' => 'text', - ], - ], + 'title' => [ + 'fields' => [ + 'raw' => [ + 'type' => 'keyword', + ], + 'title' => [ 'type' => 'text', + ], ], - 'description' => [ - 'type' => 'text', - ], - 'category' => [ - 'properties' => [ - 'id' => [ - 'type' => 'integer', - ], - 'title' => [ - 'type' => 'keyword', - ], - 'tags' => [ - 'properties' => [ - 'tagname' => [ - 'type' => 'text', - ], - ], - ], - ], - ], - 'related_categories' => [ - 'properties' => [ - 'id' => [ - 'type' => 'integer', - ], - 'title' => [ - 'type' => 'keyword', - ], - 'tags' => [ - 'properties' => [ - 'tagname' => [ - 'type' => 'text', - ], - ], - ], - ], - ], - 'price' => [ - 'type' => 'float', - ], - 'location' => [ - 'type' => 'geo_point', - ], - 'limited' => [ - 'type' => 'boolean', - ], - 'released' => [ - 'type' => 'date', - ], - 'ml_info-en' => [ - 'analyzer' => 'en_analyzer', - 'fields' => [ - 'ngram' => [ - 'type' => 'text', - 'analyzer' => 'en_analyzer', - ], + 'type' => 'text', + ], + 'description' => [ + 'type' => 'text', + ], + 'category' => [ + 'properties' => [ + 'id' => [ + 'type' => 'integer', + ], + 'title' => [ + 'type' => 'keyword', + ], + 'tags' => [ + 'properties' => [ + 'tagname' => [ + 'type' => 'text', + ], ], - 'type' => 'text', + ], ], - 'ml_info-fr' => [ - 'analyzer' => 'default_analyzer', - 'fields' => [ - 'ngram' => [ - 'type' => 'text', - 'analyzer' => 'default_analyzer', - ], + ], + 'related_categories' => [ + 'properties' => [ + 'id' => [ + 'type' => 'integer', + ], + 'title' => [ + 'type' => 'keyword', + ], + 'tags' => [ + 'properties' => [ + 'tagname' => [ + 'type' => 'text', + ], ], - 'type' => 'text', - ], - 'ml_info-default' => [ - 'type' => 'keyword', - 'ignore_above' => 256, - ], - 'ml_more_info-en' => [ - 'type' => 'text', - ], - 'ml_more_info-fr' => [ - 'type' => 'text', + ], ], - 'ml_more_info-default' => [ - 'type' => 'text', - 'index' => false, + ], + 'price' => [ + 'type' => 'float', + ], + 'location' => [ + 'type' => 'geo_point', + ], + 'limited' => [ + 'type' => 'boolean', + ], + 'released' => [ + 'type' => 'date', + ], + 'ml_info-en' => [ + 'analyzer' => 'en_analyzer', + 'fields' => [ + 'ngram' => [ + 'type' => 'text', + 'analyzer' => 'en_analyzer', + ], ], - 'pieces_count' => [ - 'fields' => [ - 'count' => [ - 'type' => 'token_count', - 'analyzer' => 'whitespace', - ], - ], - 'type' => 'text', + 'type' => 'text', + ], + 'ml_info-fr' => [ + 'analyzer' => 'default_analyzer', + 'fields' => [ + 'ngram' => [ + 'type' => 'text', + 'analyzer' => 'default_analyzer', + ], ], + 'type' => 'text', ], - 'fields' => [ - 'dynamic' => 'strict', + 'ml_info-default' => [ + 'type' => 'keyword', + 'ignore_above' => 256, ], - 'propertiesMetadata' => [ - 'title' => [ - 'propertyName' => 'title', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'description' => [ - 'propertyName' => 'description', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, + 'ml_more_info-en' => [ + 'type' => 'text', + ], + 'ml_more_info-fr' => [ + 'type' => 'text', + ], + 'ml_more_info-default' => [ + 'type' => 'text', + 'index' => false, + ], + 'pieces_count' => [ + 'fields' => [ + 'count' => [ + 'type' => 'token_count', + 'analyzer' => 'whitespace', + ], ], - 'category' => [ - 'propertyName' => 'category', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => null, - 'propertiesMetadata' => [ - 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, - 'propertiesMetadata' => [ - 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'type' => 'text', + ], + ], + 'fields' => [ + 'dynamic' => 'strict', + ], + 'propertiesMetadata' => [ + 'title' => [ + 'propertyName' => 'title', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'description' => [ + 'propertyName' => 'description', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'category' => [ + 'propertyName' => 'category', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => null, + 'propertiesMetadata' => [ + 'id' => [ + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, - ], - 'related_categories' => [ - 'propertyName' => 'relatedCategories', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, - 'propertiesMetadata' => [ - 'id' => [ - 'propertyName' => 'id', - 'type' => 'integer', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'title' => [ - 'propertyName' => 'title', - 'type' => 'keyword', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'tags' => [ - 'propertyName' => 'tags', - 'type' => 'object', - 'multilanguage' => null, - 'multiple' => true, - 'propertiesMetadata' => [ - 'tagname' => [ - 'propertyName' => 'tagName', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', - 'propertyAccess' => 1, - ], + ], + 'title' => [ + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'tags' => [ + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, + 'propertiesMetadata' => [ + 'tagname' => [ + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], ], - 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, + ], ], - 'price' => [ - 'propertyName' => 'price', - 'type' => 'float', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'location' => [ - 'propertyName' => 'location', - 'type' => 'geo_point', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'limited' => [ - 'propertyName' => 'limited', - 'type' => 'boolean', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'released' => [ - 'propertyName' => 'released', - 'type' => 'date', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - 'ml_info' => [ - 'propertyName' => 'mlInfo', - 'type' => 'text', - 'multilanguage' => true, + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'propertyAccess' => 1, + ], + 'related_categories' => [ + 'propertyName' => 'relatedCategories', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, + 'propertiesMetadata' => [ + 'id' => [ + 'propertyName' => 'id', + 'type' => 'integer', + 'multilanguage' => null, 'propertyAccess' => 1, ], - 'ml_more_info' => [ - 'propertyName' => 'mlMoreInfo', - 'type' => 'text', - 'multilanguage' => true, + 'title' => [ + 'propertyName' => 'title', + 'type' => 'keyword', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'tags' => [ + 'propertyName' => 'tags', + 'type' => 'object', + 'multilanguage' => null, + 'multiple' => true, + 'propertiesMetadata' => [ + 'tagname' => [ + 'propertyName' => 'tagName', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjTag', 'propertyAccess' => 1, ], - 'pieces_count' => [ - 'propertyName' => 'tokenPiecesCount', - 'type' => 'text', - 'multilanguage' => null, - 'propertyAccess' => 1, - ], - '_id' => [ - 'propertyName' => 'id', - 'type' => 'keyword', - 'propertyAccess' => 1, - ], - '_score' => [ - 'propertyName' => 'score', - 'type' => 'float', - 'propertyAccess' => 1, ], + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\ObjCategory', + 'propertyAccess' => 1, + ], + 'price' => [ + 'propertyName' => 'price', + 'type' => 'float', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'location' => [ + 'propertyName' => 'location', + 'type' => 'geo_point', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'limited' => [ + 'propertyName' => 'limited', + 'type' => 'boolean', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'released' => [ + 'propertyName' => 'released', + 'type' => 'date', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + 'ml_info' => [ + 'propertyName' => 'mlInfo', + 'type' => 'text', + 'multilanguage' => true, + 'propertyAccess' => 1, + ], + 'ml_more_info' => [ + 'propertyName' => 'mlMoreInfo', + 'type' => 'text', + 'multilanguage' => true, + 'propertyAccess' => 1, + ], + 'pieces_count' => [ + 'propertyName' => 'tokenPiecesCount', + 'type' => 'text', + 'multilanguage' => null, + 'propertyAccess' => 1, + ], + '_id' => [ + 'propertyName' => 'id', + 'type' => 'keyword', + 'propertyAccess' => 1, + ], + '_score' => [ + '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', + ], + 'repositoryClass' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Repository\\ProductRepository', + 'providerClass' => null, + 'className' => 'Sineflow\\ElasticsearchBundle\\Tests\\App\\Fixture\\Acme\\BarBundle\\Document\\Product', ]; $this->assertEquals($expected, $res); diff --git a/tests/Functional/Result/DocumentConverterTest.php b/tests/Functional/Result/DocumentConverterTest.php index cd37378..ec97b1e 100644 --- a/tests/Functional/Result/DocumentConverterTest.php +++ b/tests/Functional/Result/DocumentConverterTest.php @@ -202,18 +202,18 @@ public function testConvertToDocumentWithSource() '_version' => 1, 'found' => true, '_source' => [ - 'title' => 'Foo Product', - 'category' => [ - 'title' => 'Bar', - ], - 'related_categories' => [ - 0 => [ - 'title' => 'Acme', - ], - ], - 'ml_info-en' => 'info in English', - 'ml_info-fr' => 'info in French', + 'title' => 'Foo Product', + 'category' => [ + 'title' => 'Bar', ], + 'related_categories' => [ + 0 => [ + 'title' => 'Acme', + ], + ], + 'ml_info-en' => 'info in English', + 'ml_info-fr' => 'info in French', + ], ]; $converter = $this->getContainer()->get('Sineflow\ElasticsearchBundle\Result\DocumentConverter'); @@ -237,20 +237,20 @@ public function testConvertToDocumentWithFields() '_id' => 'doc1', '_score' => 1, 'fields' => [ - 'title' => [ - 0 => 'Foo Product', - ], - 'related_categories.title' => [ - 0 => 'Acme', - 1 => 'Bar', - ], - 'category.title' => [ - 0 => 'Bar', - ], - 'ml_info-en' => [ - 0 => 'info in English', - ], + 'title' => [ + 0 => 'Foo Product', + ], + 'related_categories.title' => [ + 0 => 'Acme', + 1 => 'Bar', ], + 'category.title' => [ + 0 => 'Bar', + ], + 'ml_info-en' => [ + 0 => 'info in English', + ], + ], ]; /** @var DocumentConverter $converter */ diff --git a/tests/Unit/Annotation/PropertyTest.php b/tests/Unit/Annotation/PropertyTest.php index 5cbe007..4e42d1c 100644 --- a/tests/Unit/Annotation/PropertyTest.php +++ b/tests/Unit/Annotation/PropertyTest.php @@ -79,10 +79,10 @@ public function testDumpML() 'copy_to' => 'en_all', 'analyzer' => 'en_analyzer', 'fields' => [ - 'ngram' => [ - 'analyzer' => 'en_analyzer', - ], + 'ngram' => [ + 'analyzer' => 'en_analyzer', ], + ], 'type' => 'mytype', ], $type->dump($settings),