diff --git a/vendor/electrolinux/phpquery/phpQuery/phpQuery/phpQueryObject.php b/vendor/electrolinux/phpquery/phpQuery/phpQuery/phpQueryObject.php index f0dfa1d..df7db9e 100644 --- a/vendor/electrolinux/phpquery/phpQuery/phpQuery/phpQueryObject.php +++ b/vendor/electrolinux/phpquery/phpQuery/phpQuery/phpQueryObject.php @@ -3121,7 +3121,7 @@ public function whois($oneNode = null) { .($node->getAttribute('id') ? '#'.$node->getAttribute('id'):'') .($node->getAttribute('class') - ? '.'.join('.', split(' ', $node->getAttribute('class'))):'') + ? '.'.join('.', preg_split(' ', $node->getAttribute('class'))):'') .($node->getAttribute('name') ? '[name="'.$node->getAttribute('name').'"]':'') .($node->getAttribute('value') && strpos($node->getAttribute('value'), '<'.'?php') === false diff --git a/vendor/ruflin/elastica/CHANGELOG.md b/vendor/ruflin/elastica/CHANGELOG.md index 54c53ef..8cd3bd0 100644 --- a/vendor/ruflin/elastica/CHANGELOG.md +++ b/vendor/ruflin/elastica/CHANGELOG.md @@ -1,23 +1,62 @@ # Change Log All notable changes to this project will be documented in this file based on the [Keep a Changelog](http://keepachangelog.com/) Standard. This project adheres to [Semantic Versioning](http://semver.org/). -## [Unreleased](https://github.com/ruflin/Elastica/compare/3.1.1...HEAD) +## [Unreleased](https://github.com/ruflin/Elastica/compare/3.2.1...HEAD) + +### Backward Compatibility Fixes + +### Bugfixes +- Set HTTP headers on each request preventing server error if persistent connection is enabled and compression enabled and later disabled for the same connection. + +### Added +- Elastica\QueryBuilder\DSL\Query::geo_distance + +### Improvements +- Set PHP 7.0 as default development version +- Get the root reason from Elasticsearch's error JSON, when available [#1111](https://github.com/ruflin/Elastica/pull/1111) + +## [3.2.1](https://github.com/ruflin/Elastica/compare/3.2.0...3.2.1) + +### Backward Compatibility Fixes +- Reintroduced properties in ResultSet removed in 3.2.0 as deprecated properties to be removed in 4.0 + +### Bugfixes +- Fix fatal error on `Query::addScriptField()` if scripts were already set via `setScriptFields()` [#1086](https://github.com/ruflin/Elastica/pull/1086) +- Fix namespace collision of `Type` in `Query\Ids` [#1104](https://github.com/ruflin/Elastica/pull/1104) + +### Added +- Added the concept of ResultSet Transformers. The Transformer adds more information to a Result, for example the original object or data that created the Result. [#1066](https://github.com/ruflin/Elastica/pull/1066) +- Tidied property initialisation in classes where it was duplicated + +## [3.2.0](https://github.com/ruflin/Elastica/compare/3.1.1...3.2.0) ### Backward Compatibility Breaks +- Method \Elastica\ResultSet::create and property \Elastica\ResultSet::$class were removed. To change the ResultSet class, implement your own ResultSet Builder. [#1065](https://github.com/ruflin/Elastica/pull/1065) +- Properties on \Elastica\ResultSet _totalHits, _maxScore, _took and _timedOut that were originally set on object construction are now accessed by the getters on the ResultSet. [#1065](https://github.com/ruflin/Elastica/pull/1065) ### Bugfixes +- Fix php notice on `\Elastica\Index::getAliases()` if index has no aliases [#1078](https://github.com/ruflin/Elastica/issues/1078) ### Added +- Update elasticsearch build dependency to elasticsearch 2.3.2 [#1084](https://github.com/ruflin/Elastica/pull/1084) ### Improvements +- `Elastica\Type->deleteByQuery($query, $options)` $query param can be a query `array` again https://github.com/ruflin/Elastica/issues/1072 [#1073](https://github.com/ruflin/Elastica/pull/1073) +- `Elastica\Client->connect()` allows to establish a connection to ES server when the config was set using method `Elastica\Client->setConfigValue()` https://github.com/ruflin/Elastica/issues/1076 [#1077](https://github.com/ruflin/Elastica/pull/1077) +- Elastica\Client constructor now accepts a LoggerInterface and will log both successful and failed requests. [#1069](https://github.com/ruflin/Elastica/pull/1069) ### Deprecated +- Configuring the logger in \Elastica\Client $config constructor is deprecated and will be removed. Use the $logger argument instead. [#1069](https://github.com/ruflin/Elastica/pull/1069) +- Extracted creation of ResultSet objects to a new dedicated ResultSet\Builder implementation. [#1065](https://github.com/ruflin/Elastica/pull/1065) + +### Deprecated +- All properties in the \Elastica\ResultSet class will be moved to private in 4.0. To manipulate the creation of a ResultSet, implement the \Elastica\ResultSet\BuilderInterface and pass your new Builder to the \Elastica\Search instances. [#1065](https://github.com/ruflin/Elastica/pull/1065) ## [3.1.1](https://github.com/ruflin/Elastica/compare/3.1.0...3.1.1) ### Added -- Add an "AwsAuthV4" transport that automatically signs requests using credentials from the environment or from the client config. This allows using Elastica with Amazon ElasticSearch Service domains that are restricted to IAM roles or policies. https://github.com/ruflin/Elastica/pull/1056 +- Add an "AwsAuthV4" transport that automatically signs requests using credentials from the environment or from the client config. This allows using Elastica with Amazon ElasticSearch Service domains that are restricted to IAM roles or policies. [#1056](https://github.com/ruflin/Elastica/pull/1056) - Update elasticsearch build dependency to elasticsearch 2.2.1 ### Improvements @@ -48,8 +87,8 @@ All notable changes to this project will be documented in this file based on the ## [3.0.1](https://github.com/ruflin/Elastica/compare/3.0.0...3.0.1) ### Improvements -- Update build dependency to elasticsearch 2.1.1 #1022 -- Readd \Elastica\Filter\Nested. See https://github.com/ruflin/Elastica/issues/1001 #1020 +- Update build dependency to elasticsearch 2.1.1 [#1022](https://github.com/ruflin/Elastica/pull/1022) +- Readd \Elastica\Filter\Nested. See https://github.com/ruflin/Elastica/issues/1001 [#1020](https://github.com/ruflin/Elastica/pull/1020) ## [3.0.0](https://github.com/ruflin/Elastica/compare/3.0.0-beta1...3.0.0) @@ -58,10 +97,10 @@ All notable changes to this project will be documented in this file based on the - Revert getError changes in Response object and make it better BC compatible. See comment [here](https://github.com/ruflin/Elastica/commit/41a7a2075837320bc9bd3bca4150e05a1ec9a115#commitcomment-15136374). ### Bugfixes -- Function score query: corrected the `score_method` `average` to `avg` #975 -- Set `json_decode()` assoc parameter to true in `Elastica\Response` #1005 -- Add `bigintConversion` to keys passed to connection config in `Elastica\Client` #1005 -- Use POST instead of PUT to send bulk requests #1010 +- Function score query: corrected the `score_method` `average` to `avg` [#975](https://github.com/ruflin/Elastica/pull/975) +- Set `json_decode()` assoc parameter to true in `Elastica\Response` [#1005](https://github.com/ruflin/Elastica/pull/1005) +- Add `bigintConversion` to keys passed to connection config in `Elastica\Client` [#1005](https://github.com/ruflin/Elastica/pull/1005) +- Use POST instead of PUT to send bulk requests [#1010](https://github.com/ruflin/Elastica/issues/1010) ### Added - Elastica\Query\MultiMatch::setFuzziness now supports being set to `AUTO` with the const `MultiMatch::FUZZINESS_AUTO` @@ -70,7 +109,7 @@ All notable changes to this project will be documented in this file based on the ### Improvements - More info on Elastica\Exception\PartialShardFailureException. Not just number of failed shards. -- Allow bool in TopHits::setSource function #1012 +- Allow bool in TopHits::setSource function [#1012](https://github.com/ruflin/Elastica/issues/1012) ### Deprecated - Elastica\Query\Filtered triggers E_USER_DEPRECATED error because filtered query is deprecated since ES 2.0.0-beta1. Use BoolQuery instead. @@ -136,18 +175,18 @@ All notable changes to this project will be documented in this file based on the ## [2.3.1](https://github.com/ruflin/Elastica/releases/tag/2.3.1) - 2015-10-17 ### Bugfixes -- Filters aggregation: empty name is named bucket #935 -- Prevent mix keys in filters (#936) #939 -- Fix empty string is not anonymous filter #935 -- Filters aggregation: empty name is named bucket #935 +- Filters aggregation: empty name is named bucket [#935](https://github.com/ruflin/Elastica/pull/935) +- Prevent mix keys in filters ([#936](https://github.com/ruflin/Elastica/pull/936)) [#939](https://github.com/ruflin/Elastica/pull/939) +- Fix empty string is not anonymous filter [#935](https://github.com/ruflin/Elastica/pull/935) +- Filters aggregation: empty name is named bucket [#935](https://github.com/ruflin/Elastica/pull/935) ### Added -- Support for field_value_factor #953 -- Added setMinDocCount and setExtendedBounds options #947 -- Avoid environment dependecies in tests #938 +- Support for field_value_factor [#953](https://github.com/ruflin/Elastica/pull/953) +- Added setMinDocCount and setExtendedBounds options [#947](https://github.com/ruflin/Elastica/pull/947) +- Avoid environment dependecies in tests [#938](https://github.com/ruflin/Elastica/pull/938) ### Improvements -- Update elasticsearch dependency to elasticsearch 1.7.3 #957 +- Update elasticsearch dependency to elasticsearch 1.7.3 [#957](https://github.com/ruflin/Elastica/pull/957) ### Deprecated - Added exceptions of deprecated transports to deprecation list @@ -162,10 +201,10 @@ All notable changes to this project will be documented in this file based on the as argument. [#916](https://github.com/ruflin/Elastica/pull/916) ### Added -- Add Script File feature #902 #914 +- Add Script File feature [#902](https://github.com/ruflin/Elastica/pull/902) [#914](https://github.com/ruflin/Elastica/pull/914) ### Improvements -- Support the http.compression in the Http transport adapter #515 +- Support the http.compression in the Http transport adapter [#515](https://github.com/ruflin/Elastica/issues/515) - Introduction of Lazy toArray [#916](https://github.com/ruflin/Elastica/pull/916) - Update Elasticsearch dependency to 1.7.2 [#929](https://github.com/ruflin/Elastica/pull/929) @@ -219,17 +258,17 @@ All notable changes to this project will be documented in this file based on the - Support for a custom connection timeout through a connectTimeout parameter. [#841](https://github.com/ruflin/Elastica/issues/841/) - SignificantTerms Aggregation [#847](https://github.com/ruflin/Elastica/issues/847/) - Support for 'precision_threshold' and 'rehash' options for the Cardinality Aggregation [#851] -- Support for retrieving id node #852 +- Support for retrieving id node [#852](https://github.com/ruflin/Elastica/pull/852) - Scroll Iterator [#842](https://github.com/ruflin/Elastica/issues/842/) - Gitter Elastica Chat Room add for Elastica discussions: https://gitter.im/ruflin/Elastica -- Introduce PHP7 compatibility and tests. #837 +- Introduce PHP7 compatibility and tests. [#837](https://github.com/ruflin/Elastica/pull/837) - `Tool\CrossIndex` for reindexing and copying data and mapping between indices [#853](https://github.com/ruflin/Elastica/pull/853) -- CONTIRUBTING.md file added for contributor guidelines. #854 +- CONTIRUBTING.md file added for contributor guidelines. [#854](https://github.com/ruflin/Elastica/pull/854) ### Improvements - Introduction of Changelog standard based on http://keepachangelog.com/. changes.txt moved to CHANGELOG.md [#844](https://github.com/ruflin/Elastica/issues/844/) -- Make host for all tests dynamic to prepare it for a more dynamic test environment #846 -- Node information is retrieved based on id instead of name as multiple nodes can have the same name. #852 +- Make host for all tests dynamic to prepare it for a more dynamic test environment [#846](https://github.com/ruflin/Elastica/pull/846) +- Node information is retrieved based on id instead of name as multiple nodes can have the same name. [#852](https://github.com/ruflin/Elastica/pull/852) - Guzzle Http dependency updated to 5.3.* - Remove NO_DEV builds from travis build matrix to speed up building. All builds include no dev packages. - Introduction of benchmark test group to make it easy to run benchmark tests. @@ -242,7 +281,7 @@ All notable changes to this project will be documented in this file based on the ### Deprecated - Facets are deprecated. You are encouraged to migrate to aggregations instead. [#855](https://github.com/ruflin/Elastica/pull/855/) - Elastica\Query\Builder is deprecated. Use new Elastica\QueryBuilder instead. [#855](https://github.com/ruflin/Elastica/pull/855/) -- For PHP 7 compatibility Elastica\Query\Bool was renamed to *\BoolQuery, Elastica\Filter\Bool was renamed to BoolFilter, Elastica\Transport\Null was renamed to NullTransport as Null and Bool are reserved phrases in PHP 7. Proxy objects for all three exist to keep backward compatibility. It is recommended to start using the new objects as the proxy classes will be deprecated as soon as PHP 7 is stable. #837 +- For PHP 7 compatibility Elastica\Query\Bool was renamed to *\BoolQuery, Elastica\Filter\Bool was renamed to BoolFilter, Elastica\Transport\Null was renamed to NullTransport as Null and Bool are reserved phrases in PHP 7. Proxy objects for all three exist to keep backward compatibility. It is recommended to start using the new objects as the proxy classes will be deprecated as soon as PHP 7 is stable. [#837](https://github.com/ruflin/Elastica/pull/837) @@ -1210,3 +1249,6 @@ The changelog before version 2.0.0 was organised by date. All changes can be fou - getResponse in Elastica_Response renamed to getData. getResponse now deprecated - Index status objects added - getIndexName in Elastica_Index renamed to getName. getIndexName is deprecated + +2011-03-21 +- ChildrenAggregation added - https://www.elastic.co/guide/en/elasticsearch/guide/current/children-agg.html diff --git a/vendor/ruflin/elastica/Makefile b/vendor/ruflin/elastica/Makefile index 8bfe688..386ce22 100644 --- a/vendor/ruflin/elastica/Makefile +++ b/vendor/ruflin/elastica/Makefile @@ -1,7 +1,7 @@ #/bin/bash SOURCE = "./lib" -TARGET?=56 +TARGET?=70 # By default docker environment is used to run commands. To run without the predefined environment, set RUN_ENV=" " either as parameter or as environment variable ifndef RUN_ENV diff --git a/vendor/ruflin/elastica/README.md b/vendor/ruflin/elastica/README.md index 23fa87b..a479956 100644 --- a/vendor/ruflin/elastica/README.md +++ b/vendor/ruflin/elastica/README.md @@ -17,7 +17,7 @@ All library issues should go to the [issue tracker from github](https://github.c Compatibility ------------- -This release is compatible with all elasticsearch 2.x releases. It was tested with version 2.2.1 +This release is compatible with all elasticsearch 2.x releases. It was tested with version 2.3.2 Contributing @@ -29,5 +29,5 @@ Dependencies ------------ | Project | Version | Required | |---------|---------|----------| -|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v2.2.1)|2.2.1|yes| +|[Elasticsearch](https://github.com/elasticsearch/elasticsearch/tree/v2.3.2)|2.3.2|yes| |[Elasticsearch image plugin](https://github.com/Jmoati/elasticsearch-image/releases/tag/1.7.1)|1.7.1|no| diff --git a/vendor/ruflin/elastica/composer.json b/vendor/ruflin/elastica/composer.json index f78669f..56545b5 100644 --- a/vendor/ruflin/elastica/composer.json +++ b/vendor/ruflin/elastica/composer.json @@ -16,14 +16,14 @@ "psr/log": "~1.0" }, "require-dev": { - "guzzlehttp/guzzle": "~6.0", - "aws/aws-sdk-php": "~3.0" + "aws/aws-sdk-php": "~3.0", + "guzzlehttp/guzzle": "~6.0" }, "suggest": { - "guzzlehttp/guzzle": "Allow using guzzle 6 as the http transport (Requires php 5.5)", + "aws/aws-sdk-php": "Allow using IAM authentication with Amazon ElasticSearch Service", "egeloen/http-adapter": "Allow using httpadapter transport", - "monolog/monolog": "Logging request", - "aws/aws-sdk-php": "Allow using IAM authentication with Amazon ElasticSearch Service" + "guzzlehttp/guzzle": "Allow using guzzle 6 as the http transport (Requires php 5.5)", + "monolog/monolog": "Logging request" }, "autoload": { "psr-4": { @@ -37,7 +37,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "3.2.x-dev" } } } diff --git a/vendor/ruflin/elastica/docker-entrypoint.sh b/vendor/ruflin/elastica/docker-entrypoint.sh old mode 100755 new mode 100644 index 73505fc..7ad3300 --- a/vendor/ruflin/elastica/docker-entrypoint.sh +++ b/vendor/ruflin/elastica/docker-entrypoint.sh @@ -26,7 +26,7 @@ readParams() { # green or yellow. waitForElasticsearch() { echo -n "Waiting on elasticsearch(${ES_HOST}:${ES_PORT}) to start." - for ((i=1;i<=30;i++)) + for ((i=1;i<=60;i++)) do health=$(curl --silent "http://${ES_HOST}:${ES_PORT}/_cat/health" | awk '{print $4}') if [[ "$health" == "green" ]] || [[ "$health" == "yellow" ]] diff --git a/vendor/ruflin/elastica/env/elastica/Docker54 b/vendor/ruflin/elastica/env/elastica/Docker54 index e2ec58c..581b41a 100644 --- a/vendor/ruflin/elastica/env/elastica/Docker54 +++ b/vendor/ruflin/elastica/env/elastica/Docker54 @@ -9,7 +9,8 @@ RUN apt-get update && apt-get install -y \ graphviz \ libxslt-dev \ nano \ - php5-xsl + php5-xsl \ + wget # XSL and Graphviz for PhpDocumentor RUN docker-php-ext-install sockets xsl @@ -24,10 +25,13 @@ RUN pecl install xdebug-2.3.2 RUN echo "memory_limit=1024M" >> /usr/local/etc/php/conf.d/memory-limit.ini RUN echo "date.timezone=UTC" >> /usr/local/etc/php/conf.d/timezone.ini #RUN echo "extension=/usr/lib/php5/20131226/xsl.so" >> /usr/local/etc/php/conf.d/xsl.ini # TODO: Debian is putting the xsl extension in a different directory, should be in: /usr/local/lib/php/extensions/no-debug-non-zts-20131226 -RUN echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini +RUN echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini # Install and setup composer -RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer +RUN wget https://getcomposer.org/download/1.0.3/composer.phar +RUN mv composer.phar /usr/local/bin/composer +RUN chmod a+x /usr/local/bin/composer + ENV COMPOSER_HOME /root/composer # Add composer bin to the environment diff --git a/vendor/ruflin/elastica/env/elastica/Docker70 b/vendor/ruflin/elastica/env/elastica/Docker70 index 45aa855..852c629 100644 --- a/vendor/ruflin/elastica/env/elastica/Docker70 +++ b/vendor/ruflin/elastica/env/elastica/Docker70 @@ -9,7 +9,8 @@ RUN apt-get update && apt-get install -y \ graphviz \ libxslt-dev \ nano \ - php5-xsl + php5-xsl \ + zip unzip # XSL and Graphviz for PhpDocumentor RUN docker-php-ext-install sockets xsl @@ -17,14 +18,13 @@ RUN docker-php-ext-install sockets xsl RUN rm -r /var/lib/apt/lists/* # Xdebug for coverage report -RUN pecl install xdebug-2.3.2 +RUN pecl install xdebug-2.4.0 ## PHP Configuration RUN echo "memory_limit=1024M" >> /usr/local/etc/php/conf.d/memory-limit.ini RUN echo "date.timezone=UTC" >> /usr/local/etc/php/conf.d/timezone.ini -#RUN echo "extension=/usr/lib/php5/20131226/xsl.so" >> /usr/local/etc/php/conf.d/xsl.ini # TODO: Debian is putting the xsl extension in a different directory, should be in: /usr/local/lib/php/extensions/no-debug-non-zts-20131226 -RUN echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini +RUN echo "zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so" >> /usr/local/etc/php/conf.d/xdebug.ini # Install and setup composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer diff --git a/vendor/ruflin/elastica/env/elasticsearch/Dockerfile b/vendor/ruflin/elastica/env/elasticsearch/Dockerfile index e21fa3f..75f2ee3 100644 --- a/vendor/ruflin/elastica/env/elasticsearch/Dockerfile +++ b/vendor/ruflin/elastica/env/elasticsearch/Dockerfile @@ -1,4 +1,4 @@ -FROM elasticsearch:2.2.1 +FROM elasticsearch:2.3.2 MAINTAINER Nicolas Ruflin # Dependencies diff --git a/vendor/ruflin/elastica/lib/Elastica/AbstractScript.php b/vendor/ruflin/elastica/lib/Elastica/AbstractScript.php index 81c1633..f1e8621 100644 --- a/vendor/ruflin/elastica/lib/Elastica/AbstractScript.php +++ b/vendor/ruflin/elastica/lib/Elastica/AbstractScript.php @@ -1,5 +1,4 @@ hasParam($key) && '' !== (string) $this->getParam($key)) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php index 6ade6da..0857593 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractAggregation.php @@ -1,5 +1,4 @@ new \stdClass()); + $array = ['global' => new \stdClass()]; } if (sizeof($this->_aggs)) { $array['aggs'] = $this->_convertArrayable($this->_aggs); diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php index 88210a0..d20a876 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/AbstractSimpleAggregation.php @@ -1,5 +1,4 @@ setParam('include', $pattern); } - return $this->setParam('include', array( + return $this->setParam('include', [ 'pattern' => $pattern, 'flags' => $flags, - )); + ]); } /** @@ -53,10 +52,10 @@ public function setExclude($pattern, $flags = null) return $this->setParam('exclude', $pattern); } - return $this->setParam('exclude', array( + return $this->setParam('exclude', [ 'pattern' => $pattern, 'flags' => $flags, - )); + ]); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php index 73c81cb..ad9084c 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Avg.php @@ -1,5 +1,4 @@ setParam('type', $type); + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php index 78a5d64..bed4cb6 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/DateHistogram.php @@ -1,5 +1,4 @@ $this->getParam('filter')->toArray(), - ); + ]; if ($this->_aggs) { $array['aggs'] = $this->_convertArrayable($this->_aggs); diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php index 920a4f7..5e3d61b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Filters.php @@ -1,5 +1,4 @@ getParam('filters'); foreach ($filters as $filter) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php index 0c7e32d..8648211 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/GeoDistance.php @@ -1,5 +1,4 @@ setParam('order', array($order => $direction)); + return $this->setParam('order', [$order => $direction]); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php index 9cbaa2d..a7208f7 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/IpRange.php @@ -1,5 +1,4 @@ addParam('ranges', array('mask' => $mask)); + return $this->addParam('ranges', ['mask' => $mask]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php index 8162e18..a8721d7 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/Max.php @@ -1,5 +1,4 @@ setParam('order', array($order => $direction)); + return $this->setParam('order', [$order => $direction]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php index 5f51f88..f280075 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php +++ b/vendor/ruflin/elastica/lib/Elastica/Aggregation/TopHits.php @@ -1,5 +1,4 @@ getIndex(); + return null !== $this->getIndex() && '' !== $this->getIndex(); } /** @@ -97,7 +96,7 @@ public function setType($type) } /** - * @return string + * @return string|null */ public function getType() { @@ -109,7 +108,7 @@ public function getType() */ public function hasType() { - return '' !== $this->_type; + return null !== $this->getType() && '' !== $this->getType(); } /** @@ -228,7 +227,7 @@ public function addScripts(array $scripts, $opType = null) public function addData($data, $opType = null) { if (!is_array($data)) { - $data = array($data); + $data = [$data]; } foreach ($data as $actionData) { @@ -337,7 +336,7 @@ public function toString() */ public function toArray() { - $data = array(); + $data = []; foreach ($this->getActions() as $action) { foreach ($action->toArray() as $row) { $data[] = $row; @@ -374,7 +373,7 @@ protected function _processResponse(Response $response) $actions = $this->getActions(); - $bulkResponses = array(); + $bulkResponses = []; if (isset($responseData['items']) && is_array($responseData['items'])) { foreach ($responseData['items'] as $key => $item) { @@ -390,7 +389,7 @@ protected function _processResponse(Response $response) if ($action instanceof AbstractDocumentAction) { $data = $action->getData(); if ($data instanceof Document && $data->isAutoPopulate() - || $this->_client->getConfigValue(array('document', 'autoPopulate'), false) + || $this->_client->getConfigValue(['document', 'autoPopulate'], false) ) { if (!$data->hasId() && isset($bulkResponseData['_id'])) { $data->setId($bulkResponseData['_id']); diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php index afbc2fc..0210ccc 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action.php @@ -1,5 +1,4 @@ setOpType($opType); $this->setMetadata($metadata); @@ -96,7 +95,7 @@ public function getMetadata() */ public function getActionMetadata() { - return array($this->_opType => $this->getMetadata()); + return [$this->_opType => $this->getMetadata()]; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php index 10096cb..2251ab2 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/AbstractDocument.php @@ -1,5 +1,4 @@ getOptions($params, true); return $metadata; diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php index 3a412cf..fd7f338 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/IndexDocument.php @@ -1,5 +1,4 @@ getOptions($params, true); diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php index e5a72c5..aeffd1a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Action/UpdateDocument.php @@ -1,5 +1,4 @@ $document->getData()); + $source = ['doc' => $document->getData()]; if ($document->getDocAsUpsert()) { $source['doc_as_upsert'] = true; diff --git a/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php b/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php index 73afb68..855a72c 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php +++ b/vendor/ruflin/elastica/lib/Elastica/Bulk/Response.php @@ -1,5 +1,4 @@ getBulkResponses() as $bulkResponse) { if ($bulkResponse->hasError()) { - $error = $bulkResponse->getError(); - break; + return $bulkResponse->getError(); } } - return $error; + return ''; } /** @@ -61,16 +57,13 @@ public function getError() */ public function getFullError() { - $error = ''; - foreach ($this->getBulkResponses() as $bulkResponse) { if ($bulkResponse->hasError()) { - $error = $bulkResponse->getFullError(); - break; + return $bulkResponse->getFullError(); } } - return $error; + return ''; } /** @@ -78,16 +71,13 @@ public function getFullError() */ public function isOk() { - $return = true; - foreach ($this->getBulkResponses() as $bulkResponse) { if (!$bulkResponse->isOk()) { - $return = false; - break; + return false; } } - return $return; + return true; } /** @@ -95,16 +85,13 @@ public function isOk() */ public function hasError() { - $return = false; - foreach ($this->getBulkResponses() as $bulkResponse) { if ($bulkResponse->hasError()) { - $return = true; - break; + return true; } } - return $return; + return false; } /** @@ -112,11 +99,9 @@ public function hasError() */ public function current() { - if ($this->valid()) { - return $this->_bulkResponses[$this->key()]; - } else { - return false; - } + return $this->valid() + ? $this->_bulkResponses[$this->key()] + : false; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Client.php b/vendor/ruflin/elastica/lib/Elastica/Client.php index 1693fb7..2dcf115 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Client.php +++ b/vendor/ruflin/elastica/lib/Elastica/Client.php @@ -1,13 +1,12 @@ null, 'port' => null, 'path' => null, @@ -34,49 +33,57 @@ class Client 'transport' => null, 'persistent' => true, 'timeout' => null, - 'connections' => array(), // host, port, path, timeout, transport, compression, persistent, timeout, config -> (curl, headers, url) + 'connections' => [], // host, port, path, timeout, transport, compression, persistent, timeout, config -> (curl, headers, url) 'roundRobin' => false, 'log' => false, 'retryOnConflict' => 0, 'bigintConversion' => false, 'username' => null, 'password' => null, - ); + ]; /** * @var callback */ - protected $_callback = null; + protected $_callback; + + /** + * @var Connection\ConnectionPool + */ + protected $_connectionPool; /** - * @var \Elastica\Request + * @var \Elastica\Request|null */ protected $_lastRequest; /** - * @var \Elastica\Response + * @var \Elastica\Response|null */ protected $_lastResponse; /** * @var LoggerInterface */ - protected $_logger = null; - /** - * @var Connection\ConnectionPool - */ - protected $_connectionPool = null; + protected $_logger; /** * Creates a new Elastica client. * - * @param array $config OPTIONAL Additional config options - * @param callback $callback OPTIONAL Callback function which can be used to be notified about errors (for example connection down) + * @param array $config OPTIONAL Additional config options + * @param callback $callback OPTIONAL Callback function which can be used to be notified about errors (for example connection down) + * @param LoggerInterface $logger */ - public function __construct(array $config = array(), $callback = null) + public function __construct(array $config = [], $callback = null, LoggerInterface $logger = null) { - $this->setConfig($config); $this->_callback = $callback; + + if (!$logger && isset($config['log']) && $config['log']) { + $logger = new Log($config['log']); + } + $this->_logger = $logger ?: new NullLogger(); + + $this->setConfig($config); $this->_initConnections(); } @@ -85,7 +92,7 @@ public function __construct(array $config = array(), $callback = null) */ protected function _initConnections() { - $connections = array(); + $connections = []; foreach ($this->getConfig('connections') as $connection) { $connections[] = Connection::create($this->_prepareConnectionParams($connection)); @@ -124,10 +131,10 @@ protected function _initConnections() */ protected function _prepareConnectionParams(array $config) { - $params = array(); - $params['config'] = array(); + $params = []; + $params['config'] = []; foreach ($config as $key => $value) { - if (in_array($key, array('bigintConversion', 'curl', 'headers', 'url'))) { + if (in_array($key, ['bigintConversion', 'curl', 'headers', 'url'])) { $params['config'][$key] = $value; } else { $params[$key] = $value; @@ -186,7 +193,7 @@ public function getConfig($key = '') */ public function setConfigValue($key, $value) { - return $this->setConfig(array($key => $value)); + return $this->setConfig([$key => $value]); } /** @@ -323,7 +330,7 @@ public function addDocuments(array $docs) /** * Update document, using update script. Requires elasticsearch >= 0.19.0. * - * @param int $id document id + * @param int|string $id document id * @param array|\Elastica\Script\AbstractScript|\Elastica\Document $data raw data for request body * @param string $index index to update * @param string $type type of index to update @@ -333,21 +340,21 @@ public function addDocuments(array $docs) * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update.html */ - public function updateDocument($id, $data, $index, $type, array $options = array()) + public function updateDocument($id, $data, $index, $type, array $options = []) { $path = $index.'/'.$type.'/'.$id.'/_update'; if ($data instanceof AbstractScript) { $requestData = $data->toArray(); } elseif ($data instanceof Document) { - $requestData = array('doc' => $data->getData()); + $requestData = ['doc' => $data->getData()]; if ($data->getDocAsUpsert()) { $requestData['doc_as_upsert'] = true; } $docOptions = $data->getOptions( - array( + [ 'version', 'version_type', 'routing', @@ -359,12 +366,12 @@ public function updateDocument($id, $data, $index, $type, array $options = array 'replication', 'refresh', 'timeout', - ) + ] ); $options += $docOptions; // set fields param to source only if options was not set before if ($data instanceof Document && ($data->isAutoPopulate() - || $this->getConfigValue(array('document', 'autoPopulate'), false)) + || $this->getConfigValue(['document', 'autoPopulate'], false)) && !isset($options['fields']) ) { $options['fields'] = '_source'; @@ -389,7 +396,7 @@ public function updateDocument($id, $data, $index, $type, array $options = array if ($response->isOk() && $data instanceof Document - && ($data->isAutoPopulate() || $this->getConfigValue(array('document', 'autoPopulate'), false)) + && ($data->isAutoPopulate() || $this->getConfigValue(['document', 'autoPopulate'], false)) ) { $responseData = $response->getData(); if (isset($responseData['_version'])) { @@ -470,6 +477,14 @@ public function getCluster() return new Cluster($this); } + /** + * Establishes the client connections. + */ + public function connect() + { + return $this->_initConnections(); + } + /** * @param \Elastica\Connection $connection * @@ -607,32 +622,28 @@ public function bulk(array $params) * * It's possible to make any REST query directly over this method * - * @param string $path Path to call - * @param string $method Rest method to use (GET, POST, DELETE, PUT) - * @param array $data OPTIONAL Arguments as array - * @param array $query OPTIONAL Query params + * @param string $path Path to call + * @param string $method Rest method to use (GET, POST, DELETE, PUT) + * @param array|string $data OPTIONAL Arguments as array or pre-encoded string + * @param array $query OPTIONAL Query params * * @throws Exception\ConnectionException|\Exception * - * @return \Elastica\Response Response object + * @return Response Response object */ - public function request($path, $method = Request::GET, $data = array(), array $query = array()) + public function request($path, $method = Request::GET, $data = [], array $query = []) { $connection = $this->getConnection(); - try { - $request = new Request($path, $method, $data, $query, $connection); - - $this->_log($request); + $request = $this->_lastRequest = new Request($path, $method, $data, $query, $connection); + $this->_lastResponse = null; - $response = $request->send(); - - $this->_lastRequest = $request; - $this->_lastResponse = $response; - - return $response; + try { + $response = $this->_lastResponse = $request->send(); } catch (ConnectionException $e) { $this->_connectionPool->onFail($connection, $e, $this); + $this->_log($e); + // In case there is no valid connection left, throw exception which caused the disabling of the connection. if (!$this->hasConnection()) { throw $e; @@ -640,6 +651,44 @@ public function request($path, $method = Request::GET, $data = array(), array $q return $this->request($path, $method, $data, $query); } + + $this->_log($request); + + return $response; + } + + /** + * logging. + * + * @deprecated Overwriting Client->_log is deprecated. Handle logging functionality by using a custom LoggerInterface. + * + * @param mixed $context + */ + protected function _log($context) + { + if ($context instanceof ConnectionException) { + $this->_logger->error('Elastica Request Failure', [ + 'exception' => $context, + 'request' => $context->getRequest()->toArray(), + 'retry' => $this->hasConnection(), + ]); + + return; + } + + if ($context instanceof Request) { + $this->_logger->debug('Elastica Request', [ + 'request' => $context->toArray(), + 'response' => $this->_lastResponse ? $this->_lastResponse->getData() : null, + 'responseStatus' => $this->_lastResponse ? $this->_lastResponse->getStatus() : null, + ]); + + return; + } + + $this->_logger->debug('Elastica Request', [ + 'message' => $context, + ]); } /** @@ -651,9 +700,9 @@ public function request($path, $method = Request::GET, $data = array(), array $q * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html */ - public function optimizeAll($args = array()) + public function optimizeAll($args = []) { - return $this->request('_optimize', Request::POST, array(), $args); + return $this->request('_optimize', Request::POST, [], $args); } /** @@ -669,32 +718,7 @@ public function refreshAll() } /** - * logging. - * - * @param string|\Elastica\Request $context - * - * @throws Exception\RuntimeException - */ - protected function _log($context) - { - $log = $this->getConfig('log'); - if ($log && !class_exists('Psr\Log\AbstractLogger')) { - throw new RuntimeException('Class Psr\Log\AbstractLogger not found'); - } elseif (!$this->_logger && $log) { - $this->setLogger(new Log($this->getConfig('log'))); - } - if ($this->_logger) { - if ($context instanceof Request) { - $data = $context->toArray(); - } else { - $data = array('message' => $context); - } - $this->_logger->debug('logging Request', $data); - } - } - - /** - * @return \Elastica\Request + * @return Request|null */ public function getLastRequest() { @@ -702,7 +726,7 @@ public function getLastRequest() } /** - * @return \Elastica\Response + * @return Response|null */ public function getLastResponse() { @@ -710,7 +734,7 @@ public function getLastResponse() } /** - * set Logger. + * Replace the existing logger. * * @param LoggerInterface $logger * diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster.php b/vendor/ruflin/elastica/lib/Elastica/Cluster.php index e2edada..8bd2c81 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Cluster.php +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster.php @@ -1,5 +1,4 @@ * @@ -20,7 +19,7 @@ class Cluster * * @var \Elastica\Client Client object */ - protected $_client = null; + protected $_client; /** * Cluster state response. @@ -74,14 +73,7 @@ public function getResponse() */ public function getIndexNames() { - $metaData = $this->_data['metadata']['indices']; - - $indices = array(); - foreach ($metaData as $key => $value) { - $indices[] = $key; - } - - return $indices; + return array_keys($this->_data['metadata']['indices']); } /** @@ -104,7 +96,7 @@ public function getState() public function getNodeNames() { $data = $this->getState(); - $nodeNames = array(); + $nodeNames = []; foreach ($data['nodes'] as $node) { $nodeNames[] = $node['name']; } @@ -119,7 +111,7 @@ public function getNodeNames() */ public function getNodes() { - $nodes = array(); + $nodes = []; $data = $this->getState(); foreach ($data['nodes'] as $id => $name) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php index 36c6c1d..10c478e 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health.php @@ -1,5 +1,4 @@ _data['indices'] as $indexName => $index) { $indices[] = new Index($indexName, $index); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php index 4741154..e8a77cf 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Index.php @@ -1,5 +1,4 @@ _data['shards'] as $shardNumber => $shard) { $shards[] = new Shard($shardNumber, $shard); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php index 7eb8d38..08933ee 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php +++ b/vendor/ruflin/elastica/lib/Elastica/Cluster/Health/Shard.php @@ -1,5 +1,4 @@ set( - array( - 'persistent' => array( + [ + 'persistent' => [ $key => $value, - ), - ) + ], + ] ); } @@ -133,11 +132,11 @@ public function setPersistent($key, $value) public function setTransient($key, $value) { return $this->set( - array( - 'transient' => array( + [ + 'transient' => [ $key => $value, - ), - ) + ], + ] ); } @@ -155,13 +154,9 @@ public function setReadOnly($readOnly = true, $persistent = false) { $key = 'cluster.blocks.read_only'; - if ($persistent) { - $response = $this->setPersistent($key, $readOnly); - } else { - $response = $this->setTransient($key, $readOnly); - } - - return $response; + return $persistent + ? $this->setPersistent($key, $readOnly) + : $this->setTransient($key, $readOnly); } /** @@ -194,7 +189,7 @@ public function getClient() * * @return \Elastica\Response Response object */ - public function request(array $data = array(), $method = Request::GET) + public function request(array $data = [], $method = Request::GET) { $path = '_cluster/settings'; diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection.php b/vendor/ruflin/elastica/lib/Elastica/Connection.php index fbcc050..bbaa378 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Connection.php +++ b/vendor/ruflin/elastica/lib/Elastica/Connection.php @@ -1,5 +1,4 @@ setParams($params); $this->setEnabled(true); // Set empty config param if not exists if (!$this->hasParam('config')) { - $this->setParam('config', array()); + $this->setParam('config', []); } } @@ -329,19 +328,17 @@ public function getConfig($key = '') * * @return self */ - public static function create($params = array()) + public static function create($params = []) { - $connection = null; + if (is_array($params)) { + return new self($params); + } if ($params instanceof self) { - $connection = $params; - } elseif (is_array($params)) { - $connection = new self($params); - } else { - throw new InvalidException('Invalid data type'); + return $params; } - return $connection; + throw new InvalidException('Invalid data type'); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php b/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php index 2c9729d..b5fa681 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php +++ b/vendor/ruflin/elastica/lib/Elastica/Connection/ConnectionPool.php @@ -1,5 +1,4 @@ _callback, array($connections)); + return call_user_func_array($this->_callback, [$connections]); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php index 871c811..92cd570 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php +++ b/vendor/ruflin/elastica/lib/Elastica/Connection/Strategy/RoundRobin.php @@ -1,5 +1,4 @@ setId($id); $this->setData($data); @@ -188,7 +187,7 @@ public function addFile($key, $filepath, $mimeType = '') $value = base64_encode(file_get_contents($filepath)); if (!empty($mimeType)) { - $value = array('_content_type' => $mimeType, '_name' => $filepath, '_content' => $value); + $value = ['_content_type' => $mimeType, '_name' => $filepath, '_content' => $value]; } $this->set($key, $value); @@ -224,7 +223,7 @@ public function addFileContent($key, $content) */ public function addGeoPoint($key, $latitude, $longitude) { - $value = array('lat' => $latitude, 'lon' => $longitude); + $value = ['lat' => $latitude, 'lon' => $longitude]; $this->set($key, $value); @@ -351,10 +350,12 @@ public static function create($data) { if ($data instanceof self) { return $data; - } elseif (is_array($data)) { + } + + if (is_array($data)) { return new self('', $data); - } else { - throw new InvalidException('Failed to create document. Invalid data passed.'); } + + throw new InvalidException('Failed to create document. Invalid data passed.'); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php index 4f7a201..5db0e49 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php +++ b/vendor/ruflin/elastica/lib/Elastica/Exception/Bulk/Response/ActionException.php @@ -1,5 +1,4 @@ getActionExceptions() as $actionException) { $errors[] = $actionException->getMessage(); diff --git a/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php index 6d38455..121cf55 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php +++ b/vendor/ruflin/elastica/lib/Elastica/Exception/BulkException.php @@ -1,5 +1,4 @@ setKey($key); $this->setLocation($location); } @@ -164,7 +162,7 @@ public function setGeohash($geohash) protected function _getLocationData() { if ($this->_locationType === self::LOCATION_TYPE_LATLON) { // Latitude/longitude - $location = array(); + $location = []; if (isset($this->_latitude)) { // Latitude $location['lat'] = $this->_latitude; diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php index 293ed6d..95ca452 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/AbstractGeoShape.php @@ -1,5 +1,4 @@ setFilters($filters); @@ -53,7 +52,7 @@ public function addFilter(AbstractFilter $filter) */ public function setFilters(array $filters) { - $this->_filters = array(); + $this->_filters = []; foreach ($filters as $filter) { $this->addFilter($filter); diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php index eecf655..2dfb07b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Bool.php @@ -1,5 +1,4 @@ _must)) { $args['bool']['must'] = $this->_must; diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php index 9fd71ff..511ffa5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/BoolNot.php @@ -1,5 +1,4 @@ setParam($key, array( + $this->setParam($key, [ 'top_left' => $coordinates[0], 'bottom_right' => $coordinates[1], - )); + ]); return $this; } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php index 2ee5cf5..975bc32 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoDistance.php @@ -1,5 +1,4 @@ _ranges = array(); + $this->_ranges = []; foreach ($ranges as $key => $value) { $this->setRange($key, $value); diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php index 3f9d53a..cfdc506 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoPolygon.php @@ -1,5 +1,4 @@ array( - $this->_key => array( + return [ + 'geo_polygon' => [ + $this->_key => [ 'points' => $this->_points, - ), - ), - ); + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php index 4ed70b0..35fcfc5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapePreIndexed.php @@ -1,5 +1,4 @@ array( - $this->_path => array( - 'indexed_shape' => array( + return [ + 'geo_shape' => [ + $this->_path => [ + 'indexed_shape' => [ 'id' => $this->_indexedId, 'type' => $this->_indexedType, 'index' => $this->_indexedIndex, 'path' => $this->_indexedPath, - ), + ], 'relation' => $this->_relation, - ), - ), - ); + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php index 0486725..bb4b7c6 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeoShapeProvided.php @@ -1,5 +1,4 @@ array( - $this->_path => array( - 'shape' => array( + return [ + 'geo_shape' => [ + $this->_path => [ + 'shape' => [ 'type' => $this->_shapeType, 'coordinates' => $this->_coordinates, 'relation' => $this->_relation, - ), - ), - ), - ); + ], + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php index 91b6ad4..6f00ad8 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/GeohashCell.php @@ -1,5 +1,4 @@ setType($type); $this->setIds($ids); @@ -90,7 +89,7 @@ public function setType($type) public function setIds($ids) { if (!is_array($ids)) { - $ids = array($ids); + $ids = [$ids]; } return $this->setParam('values', $ids); diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php index 564d394..178b0e6 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Indices.php @@ -1,5 +1,4 @@ setParam('indices', array()); + $this->setParam('indices', []); foreach ($indices as $index) { $this->addIndex($index); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php index d0b5351..2efca5d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Limit.php @@ -1,5 +1,4 @@ addField($fieldName, $args); diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php index 12e232a..9cc8224 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Regexp.php @@ -1,5 +1,4 @@ setField($field); $this->setRegexp($regexp); @@ -103,7 +102,7 @@ public function setOptions($options) public function toArray() { if (count($this->_options) > 0) { - $options = array('value' => $this->_regexp); + $options = ['value' => $this->_regexp]; $options = array_merge($options, $this->_options); $this->setParam($this->_field, $options); diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php index 6b0110e..d3bd38a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Script.php @@ -1,5 +1,4 @@ setRawTerm($term); } @@ -46,6 +45,6 @@ public function setRawTerm(array $term) */ public function setTerm($key, $value) { - return $this->setRawTerm(array($key => $value)); + return $this->setRawTerm([$key => $value]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php index 80286c9..706175f 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Terms.php @@ -1,5 +1,4 @@ setTerms($key, $terms); } @@ -75,17 +67,17 @@ public function setTerms($key, array $terms) * * @return $this */ - public function setLookup($key, $type, $id, $path, $options = array()) + public function setLookup($key, $type, $id, $path, $options = []) { $this->_key = $key; if ($type instanceof \Elastica\Type) { $type = $type->getName(); } - $this->_terms = array( + $this->_terms = [ 'type' => $type, 'id' => $id, 'path' => $path, - ); + ]; $index = $options; if (is_array($options)) { @@ -136,7 +128,7 @@ public function toArray() } $this->_params[$this->_key] = $this->_terms; - return array('terms' => $this->_params); + return ['terms' => $this->_params]; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php index b623652..03033c5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php +++ b/vendor/ruflin/elastica/lib/Elastica/Filter/Type.php @@ -1,5 +1,4 @@ array('value' => $this->_type), - ); + return [ + 'type' => ['value' => $this->_type], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Index.php b/vendor/ruflin/elastica/lib/Elastica/Index.php index dd3c73a..2a506ae 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Index.php +++ b/vendor/ruflin/elastica/lib/Elastica/Index.php @@ -1,11 +1,11 @@ request('_query', Request::DELETE, array(), $options); + return $this->request('_query', Request::DELETE, [], $options); } $query = Query::create($query)->getQuery(); - return $this->request('_query', Request::DELETE, array('query' => is_array($query) ? $query : $query->toArray()), $options); + return $this->request('_query', Request::DELETE, ['query' => is_array($query) ? $query : $query->toArray()], $options); } /** @@ -200,13 +198,13 @@ public function deleteDocuments(array $docs) * * @param array $args OPTIONAL Additional arguments * - * @return array Server response + * @return \Elastica\Response Server response * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-optimize.html */ - public function optimize($args = array()) + public function optimize($args = []) { - return $this->request('_optimize', Request::POST, array(), $args); + return $this->request('_optimize', Request::POST, [], $args); } /** @@ -218,7 +216,7 @@ public function optimize($args = array()) */ public function refresh() { - return $this->request('_refresh', Request::POST, array()); + return $this->request('_refresh', Request::POST, []); } /** @@ -234,12 +232,12 @@ public function refresh() * @throws \Elastica\Exception\InvalidException * @throws \Elastica\Exception\ResponseException * - * @return array Server response + * @return \Elastica\Response Server response */ - public function create(array $args = array(), $options = null) + public function create(array $args = [], $options = null) { $path = ''; - $query = array(); + $query = []; if (is_bool($options)) { if ($options) { @@ -261,7 +259,7 @@ public function create(array $args = array(), $options = null) } break; case 'routing' : - $query = array('routing' => $value); + $query = ['routing' => $value]; break; default: throw new InvalidException('Invalid option '.$key); @@ -290,12 +288,13 @@ public function exists() /** * @param string|array|\Elastica\Query $query * @param int|array $options + * @param BuilderInterface $builder * - * @return \Elastica\Search + * @return Search */ - public function createSearch($query = '', $options = null) + public function createSearch($query = '', $options = null, BuilderInterface $builder = null) { - $search = new Search($this->getClient()); + $search = new Search($this->getClient(), $builder); $search->addIndex($this); $search->setOptionsAndQuery($options, $query); @@ -393,16 +392,16 @@ public function addAlias($name, $replace = false) { $path = '_aliases'; - $data = array('actions' => array()); + $data = ['actions' => []]; if ($replace) { $status = new Status($this->getClient()); foreach ($status->getIndicesWithAlias($name) as $index) { - $data['actions'][] = array('remove' => array('index' => $index->getName(), 'alias' => $name)); + $data['actions'][] = ['remove' => ['index' => $index->getName(), 'alias' => $name]]; } } - $data['actions'][] = array('add' => array('index' => $this->getName(), 'alias' => $name)); + $data['actions'][] = ['add' => ['index' => $this->getName(), 'alias' => $name]]; return $this->getClient()->request($path, Request::POST, $data); } @@ -420,7 +419,7 @@ public function removeAlias($name) { $path = '_aliases'; - $data = array('actions' => array(array('remove' => array('index' => $this->getName(), 'alias' => $name)))); + $data = ['actions' => [['remove' => ['index' => $this->getName(), 'alias' => $name]]]]; return $this->getClient()->request($path, Request::POST, $data); } @@ -434,12 +433,16 @@ public function getAliases() { $responseData = $this->request('_alias/*', \Elastica\Request::GET)->getData(); + if (!isset($responseData[$this->getName()])) { + return []; + } + $data = $responseData[$this->getName()]; if (!empty($data['aliases'])) { return array_keys($data['aliases']); } - return array(); + return []; } /** @@ -481,7 +484,7 @@ public function flush($refresh = false) { $path = '_flush'; - return $this->request($path, Request::POST, array(), array('refresh' => $refresh)); + return $this->request($path, Request::POST, [], ['refresh' => $refresh]); } /** @@ -501,14 +504,14 @@ public function setSettings(array $data) /** * Makes calls to the elasticsearch server based on this index. * - * @param string $path Path to call - * @param string $method Rest method to use (GET, POST, DELETE, PUT) - * @param array $data OPTIONAL Arguments as array - * @param array $query OPTIONAL Query params + * @param string $path Path to call + * @param string $method Rest method to use (GET, POST, DELETE, PUT) + * @param array|string $data OPTIONAL Arguments as array or encoded string + * @param array $query OPTIONAL Query params * * @return \Elastica\Response Response object */ - public function request($path, $method, $data = array(), array $query = array()) + public function request($path, $method, $data = [], array $query = []) { $path = $this->getName().'/'.$path; @@ -527,7 +530,7 @@ public function request($path, $method, $data = array(), array $query = array()) * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-analyze.html */ - public function analyze($text, $args = array()) + public function analyze($text, $args = []) { $data = $this->request('_analyze', Request::POST, $text, $args)->getData(); diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php b/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php index d6e573e..c6582c0 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php +++ b/vendor/ruflin/elastica/lib/Elastica/Index/Settings.php @@ -1,5 +1,4 @@ $replicas); + $data = ['number_of_replicas' => $replicas]; return $this->set($data); } @@ -128,7 +127,7 @@ public function setNumberOfReplicas($replicas) */ public function setReadOnly($readOnly = true) { - return $this->set(array('blocks.write' => $readOnly)); + return $this->set(['blocks.write' => $readOnly]); } /** @@ -158,7 +157,7 @@ public function setBlocksRead($state = true) { $state = $state ? 1 : 0; - return $this->set(array('blocks.read' => $state)); + return $this->set(['blocks.read' => $state]); } /** @@ -178,7 +177,7 @@ public function setBlocksWrite($state = true) { $state = $state ? 1 : 0; - return $this->set(array('blocks.write' => $state)); + return $this->set(['blocks.write' => $state]); } /** @@ -194,9 +193,9 @@ public function getBlocksMetadata() if (strpos($e->getMessage(), 'ClusterBlockException') !== false) { // hacky way to test if the metadata is blocked since bug 9203 is not fixed return true; - } else { - throw $e; } + + throw $e; } } @@ -209,7 +208,7 @@ public function setBlocksMetadata($state = true) { $state = $state ? 1 : 0; - return $this->set(array('blocks.write' => $state)); + return $this->set(['blocks.write' => $state]); } /** @@ -224,7 +223,7 @@ public function setBlocksMetadata($state = true) */ public function setRefreshInterval($interval) { - return $this->set(array('refresh_interval' => $interval)); + return $this->set(['refresh_interval' => $interval]); } /** @@ -267,7 +266,7 @@ public function getMergePolicyType() public function setMergePolicyType($type) { $this->getIndex()->close(); - $response = $this->set(array('merge.policy.type' => $type)); + $response = $this->set(['merge.policy.type' => $type]); $this->getIndex()->open(); return $response; @@ -288,7 +287,7 @@ public function setMergePolicyType($type) public function setMergePolicy($key, $value) { $this->getIndex()->close(); - $response = $this->set(array('merge.policy.'.$key => $value)); + $response = $this->set(['merge.policy.'.$key => $value]); $this->getIndex()->open(); return $response; @@ -353,12 +352,12 @@ public function getIndex() * * @return \Elastica\Response Response object */ - public function request(array $data = array(), $method = Request::GET) + public function request(array $data = [], $method = Request::GET) { $path = '_settings'; if (!empty($data)) { - $data = array('index' => $data); + $data = ['index' => $data]; } return $this->getIndex()->request($path, $method, $data); diff --git a/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php index 661d78f..00c8c37 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php +++ b/vendor/ruflin/elastica/lib/Elastica/Index/Stats.php @@ -1,5 +1,4 @@ request(Request::PUT, $args); } @@ -112,7 +111,7 @@ public function getClient() * * @return \Elastica\Response Response object */ - public function request($method, $data = array()) + public function request($method, $data = []) { $path = '/_template/'.$this->getName(); diff --git a/vendor/ruflin/elastica/lib/Elastica/JSON.php b/vendor/ruflin/elastica/lib/Elastica/JSON.php index db11844..f2ea26d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/JSON.php +++ b/vendor/ruflin/elastica/lib/Elastica/JSON.php @@ -1,5 +1,4 @@ 1 && $args[1] === 'JSON_ELASTICSEARCH') { - // Use built in JSON constants if available (php >= 5.4) - $args[1] = defined('JSON_UNESCAPED_UNICODE') ? JSON_UNESCAPED_UNICODE : 256; + if (count($args) > 1 && $args[1] === 'JSON_ELASTICSEARCH') { + $args[1] = JSON_UNESCAPED_UNICODE; } // run encode and output diff --git a/vendor/ruflin/elastica/lib/Elastica/Log.php b/vendor/ruflin/elastica/lib/Elastica/Log.php index 3f0ba95..85f938b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Log.php +++ b/vendor/ruflin/elastica/lib/Elastica/Log.php @@ -1,5 +1,4 @@ _lastMessage = JSON::stringify($context); diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilder.php b/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilder.php new file mode 100644 index 0000000..58ce0be --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilder.php @@ -0,0 +1,58 @@ +buildResultSets($response, $searches); + + return new ResultSet($response, $resultSets); + } + + /** + * @param Response $childResponse + * @param BaseSearch $search + * + * @return \Elastica\ResultSet + */ + private function buildResultSet(Response $childResponse, BaseSearch $search) + { + return $search->getResultSetBuilder()->buildResultSet($childResponse, $search->getQuery()); + } + + /** + * @param Response $response + * @param BaseSearch[] $searches + * + * @return \Elastica\ResultSet[] + */ + private function buildResultSets(Response $response, $searches) + { + $resultSets = []; + + $data = $response->getData(); + if (!isset($data['responses']) || !is_array($data['responses'])) { + return $resultSets; + } + + reset($searches); + + foreach ($data['responses'] as $index => $responseData) { + list($key, $search) = each($searches); + + $resultSets[$key] = $this->buildResultSet(new Response($responseData), $search); + } + + return $resultSets; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilderInterface.php b/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilderInterface.php new file mode 100644 index 0000000..3eff06a --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/Multi/MultiBuilderInterface.php @@ -0,0 +1,16 @@ +rewind(); - $this->_init($response, $searches); - } - - /** - * @param \Elastica\Response $response - * @param array|\Elastica\Search[] $searches - * - * @throws \Elastica\Exception\InvalidException + * @param \Elastica\Response $response + * @param BaseResultSet[] */ - protected function _init(Response $response, array $searches) + public function __construct(Response $response, $resultSets) { $this->_response = $response; - $responseData = $response->getData(); - - if (isset($responseData['responses']) && is_array($responseData['responses'])) { - reset($searches); - foreach ($responseData['responses'] as $key => $responseData) { - $currentSearch = each($searches); - - if ($currentSearch === false) { - throw new InvalidException('No result found for search #'.$key); - } elseif (!$currentSearch['value'] instanceof BaseSearch) { - throw new InvalidException('Invalid object for search #'.$key.' provided. Should be Elastica\Search'); - } - - $search = $currentSearch['value']; - $query = $search->getQuery(); - - $response = new Response($responseData); - $this->_resultSets[$currentSearch['key']] = new BaseResultSet($response, $query); - } - } + $this->_resultSets = $resultSets; } /** @@ -118,11 +84,9 @@ public function hasError() */ public function current() { - if ($this->valid()) { - return $this->_resultSets[$this->key()]; - } else { - return false; - } + return $this->valid() + ? $this->_resultSets[$this->key()] + : false; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php b/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php index 566b8fe..985347a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php +++ b/vendor/ruflin/elastica/lib/Elastica/Multi/Search.php @@ -1,5 +1,4 @@ setClient($client); + $this->_builder = $builder ?: new MultiBuilder(); + $this->_client = $client; } /** @@ -49,24 +55,12 @@ public function getClient() return $this->_client; } - /** - * @param \Elastica\Client $client - * - * @return $this - */ - public function setClient(Client $client) - { - $this->_client = $client; - - return $this; - } - /** * @return $this */ public function clearSearches() { - $this->_searches = array(); + $this->_searches = []; return $this; } @@ -149,7 +143,7 @@ public function search() $this->_options ); - return new ResultSet($response, $this->getSearches()); + return $this->_builder->buildMultiResultSet($response, $this->getSearches()); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/NameableInterface.php b/vendor/ruflin/elastica/lib/Elastica/NameableInterface.php index 83b4373..5e46a79 100644 --- a/vendor/ruflin/elastica/lib/Elastica/NameableInterface.php +++ b/vendor/ruflin/elastica/lib/Elastica/NameableInterface.php @@ -1,5 +1,4 @@ _node = $node; $this->refresh($params); @@ -198,7 +204,7 @@ public function getResponse() * * @return \Elastica\Response Response object */ - public function refresh(array $params = array()) + public function refresh(array $params = []) { $this->_params = $params; diff --git a/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php index 96640f3..dd96152 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php +++ b/vendor/ruflin/elastica/lib/Elastica/Node/Stats.php @@ -1,5 +1,4 @@ _getBaseName() => $this->getParams()); + $data = [$this->_getBaseName() => $this->getParams()]; if (!empty($this->_rawParams)) { $data = array_merge($data, $this->_rawParams); @@ -54,7 +53,7 @@ public function toArray() */ protected function _convertArrayable(array $array) { - $arr = array(); + $arr = []; foreach ($array as $key => $value) { if ($value instanceof ArrayableInterface) { @@ -138,10 +137,6 @@ public function setParams(array $params) public function addParam($key, $value) { if ($key != null) { - if (!isset($this->_params[$key])) { - $this->_params[$key] = array(); - } - $this->_params[$key][] = $value; } else { $this->_params = $value; diff --git a/vendor/ruflin/elastica/lib/Elastica/Percolator.php b/vendor/ruflin/elastica/lib/Elastica/Percolator.php index ceaf131..2a1cb24 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Percolator.php +++ b/vendor/ruflin/elastica/lib/Elastica/Percolator.php @@ -1,5 +1,4 @@ _index->getName().'/.percolator/'.$name; $query = Query::create($query); @@ -98,10 +97,10 @@ public function unregisterQuery($name) * * @return array With matching registered queries. */ - public function matchDoc(Document $doc, $query = null, $type = 'type', $params = array()) + public function matchDoc(Document $doc, $query = null, $type = 'type', $params = []) { $path = $this->_index->getName().'/'.$type.'/_percolate'; - $data = array('doc' => $doc->getData()); + $data = ['doc' => $doc->getData()]; $this->_applyAdditionalRequestBodyOptions($params, $data); @@ -126,12 +125,12 @@ public function matchDoc(Document $doc, $query = null, $type = 'type', $params = * * @return array With matching registered queries. */ - public function matchExistingDoc($id, $type, $query = null, $params = array()) + public function matchExistingDoc($id, $type, $query = null, $params = []) { $id = urlencode($id); $path = $this->_index->getName().'/'.$type.'/'.$id.'/_percolate'; - $data = array(); + $data = []; $this->_applyAdditionalRequestBodyOptions($params, $data); return $this->_percolate($path, $query, $data, $params); @@ -161,7 +160,7 @@ protected function _applyAdditionalRequestBodyOptions(&$params, &$data) * * @return array */ - protected function _percolate($path, $query, $data = array(), $params = array()) + protected function _percolate($path, $query, $data = [], $params = []) { // Add query to filter the percolator queries which are executed. if ($query) { @@ -176,7 +175,7 @@ protected function _percolate($path, $query, $data = array(), $params = array()) return $data['matches']; } - return array(); + return []; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Query.php b/vendor/ruflin/elastica/lib/Elastica/Query.php index 47325b9..047a582 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query.php @@ -1,5 +1,4 @@ _params['script_fields'][$name] = $script; + if (isset($this->_params['script_fields'])) { + $this->_params['script_fields']->addScript($name, $script); + } else { + $this->setScriptFields([$name => $script]); + } return $this; } @@ -352,10 +348,6 @@ public function addScriptField($name, AbstractScript $script) */ public function addAggregation(AbstractAggregation $agg) { - if (!array_key_exists('aggs', $this->_params)) { - $this->_params['aggs'] = array(); - } - $this->_params['aggs'][] = $agg; return $this; @@ -429,7 +421,7 @@ public function setSuggest(Suggest $suggest) public function setRescore($rescore) { if (is_array($rescore)) { - $buffer = array(); + $buffer = []; foreach ($rescore as $rescoreQuery) { $buffer [] = $rescoreQuery; diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoDistance.php index f4cdb39..ad9ad4c 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoDistance.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoDistance.php @@ -1,5 +1,4 @@ setKey($key); $this->setLocation($location); } @@ -161,7 +159,7 @@ public function setGeohash($geohash) protected function _getLocationData() { if ($this->_locationType === self::LOCATION_TYPE_LATLON) { // Latitude/longitude - $location = array(); + $location = []; if (isset($this->_latitude)) { // Latitude $location['lat'] = $this->_latitude; diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoShape.php b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoShape.php index 76866ab..a50d67d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoShape.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/AbstractGeoShape.php @@ -1,5 +1,4 @@ hasParam('query') && $this->getParam('query') instanceof AbstractQuery) { $filtered['query'] = $this->getParam('query')->toArray(); @@ -114,6 +113,6 @@ public function toArray() throw new InvalidException('A query and/or filter is required'); } - return array('filtered' => $filtered); + return ['filtered' => $filtered]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php b/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php index 44e5328..830f081 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/FunctionScore.php @@ -1,5 +1,4 @@ $functionParams, - ); + ]; if (!is_null($filter)) { if ($filter instanceof AbstractFilter) { @@ -158,12 +157,12 @@ public function addDecayFunction( } } - $functionParams = array( - $field => array( + $functionParams = [ + $field => [ 'origin' => $origin, 'scale' => $scale, - ), - ); + ], + ]; if (!is_null($offset)) { $functionParams[$field]['offset'] = $offset; } @@ -190,9 +189,9 @@ public function addFieldValueFactorFunction( } } - $functionParams = array( + $functionParams = [ 'field' => $field, - ); + ]; if (!is_null($factor)) { $functionParams['factor'] = $factor; @@ -265,7 +264,7 @@ public function addRandomScoreFunction($seed, $filter = null, $weight = null) } } - $this->addFunction('random_score', array('seed' => $seed), $filter, $weight); + $this->addFunction('random_score', ['seed' => $seed], $filter, $weight); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php b/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php index 482433f..2ed803a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Fuzzy.php @@ -1,5 +1,4 @@ setField($fieldName, $value); } } @@ -36,14 +35,14 @@ public function __construct($fieldName = null, $value = null) */ public function setField($fieldName, $value) { - if (!is_string($value) or !is_string($fieldName)) { + if (!is_string($value) || !is_string($fieldName)) { throw new InvalidException('The field and value arguments must be of type string.'); } - if (count($this->getParams()) > 0 and array_shift(array_keys($this->getParams())) != $fieldName) { + if (count($this->getParams()) > 0 && array_shift(array_keys($this->getParams())) != $fieldName) { throw new InvalidException('Fuzzy query can only support a single field.'); } - return $this->setParam($fieldName, array('value' => $value)); + return $this->setParam($fieldName, ['value' => $value]); } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeoBoundingBox.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeoBoundingBox.php index 768bd5a..5e7bfc0 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeoBoundingBox.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeoBoundingBox.php @@ -1,5 +1,4 @@ setParam($key, array( + $this->setParam($key, [ 'top_left' => $coordinates[0], 'bottom_right' => $coordinates[1], - )); + ]); return $this; } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeoDistance.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeoDistance.php index dfdb968..7984d4a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeoDistance.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeoDistance.php @@ -1,5 +1,4 @@ _ranges = array(); + $this->_ranges = []; foreach ($ranges as $key => $value) { $this->setRange($key, $value); diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeoPolygon.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeoPolygon.php index 5f9c14b..aa5c16b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeoPolygon.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeoPolygon.php @@ -1,5 +1,4 @@ array( - $this->_key => array( + return [ + 'geo_polygon' => [ + $this->_key => [ 'points' => $this->_points, - ), - ), - ); + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapePreIndexed.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapePreIndexed.php index 112a12a..6de3165 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapePreIndexed.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapePreIndexed.php @@ -1,5 +1,4 @@ array( - $this->_path => array( - 'indexed_shape' => array( + return [ + 'geo_shape' => [ + $this->_path => [ + 'indexed_shape' => [ 'id' => $this->_indexedId, 'type' => $this->_indexedType, 'index' => $this->_indexedIndex, 'path' => $this->_indexedPath, - ), + ], 'relation' => $this->_relation, - ), - ), - ); + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapeProvided.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapeProvided.php index 8e3b34e..2760d34 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapeProvided.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeoShapeProvided.php @@ -1,5 +1,4 @@ array( - $this->_path => array( - 'shape' => array( + return [ + 'geo_shape' => [ + $this->_path => [ + 'shape' => [ 'type' => $this->_shapeType, 'coordinates' => $this->_coordinates, 'relation' => $this->_relation, - ), - ), - ), - ); + ], + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/GeohashCell.php b/vendor/ruflin/elastica/lib/Elastica/Query/GeohashCell.php index 9c6ffb2..e473eab 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/GeohashCell.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/GeohashCell.php @@ -1,5 +1,4 @@ setType($type); $this->setIds($ids); @@ -57,7 +49,7 @@ public function addId($id) */ public function addType($type) { - if ($type instanceof Type) { + if ($type instanceof ElasticaType) { $type = $type->getName(); } elseif (empty($type) && !is_numeric($type)) { // A type can be 0, but cannot be empty @@ -78,7 +70,7 @@ public function addType($type) */ public function setType($type) { - if ($type instanceof Type) { + if ($type instanceof ElasticaType) { $type = $type->getName(); } elseif (empty($type) && !is_numeric($type)) { // A type can be 0, but cannot be empty @@ -102,7 +94,7 @@ public function setIds($ids) if (is_array($ids)) { $this->_params['values'] = $ids; } else { - $this->_params['values'] = array($ids); + $this->_params['values'] = [$ids]; } return $this; @@ -117,6 +109,6 @@ public function setIds($ids) */ public function toArray() { - return array('ids' => $this->_params); + return ['ids' => $this->_params]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Image.php b/vendor/ruflin/elastica/lib/Elastica/Query/Image.php index edb9755..4ba3130 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Image.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Image.php @@ -1,5 +1,4 @@ setParams($image); } @@ -27,16 +26,16 @@ public function __construct(array $image = array()) /** * Sets a param for the given field. * - * @param string $field - * @param string $key - * @param string $value + * @param string $field + * @param string $key + * @param string|int|float $value * * @return $this */ public function setFieldParam($field, $key, $value) { if (!isset($this->_params[$field])) { - $this->_params[$field] = array(); + $this->_params[$field] = []; } $this->_params[$field][$key] = $value; diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Indices.php b/vendor/ruflin/elastica/lib/Elastica/Query/Indices.php index 82b9ef5..99e82ef 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Indices.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Indices.php @@ -1,5 +1,4 @@ setParam('indices', array()); + $this->setParam('indices', []); foreach ($indices as $index) { $this->addIndex($index); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Limit.php b/vendor/ruflin/elastica/lib/Elastica/Query/Limit.php index 1e3d3de..1cb1f04 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Limit.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Limit.php @@ -1,5 +1,4 @@ _params[$field])) { - $this->_params[$field] = array(); + $this->_params[$field] = []; } $this->_params[$field][$key] = $value; diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php b/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php index 3189d74..9dcb4da 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/MatchAll.php @@ -1,5 +1,4 @@ 1, '_type' => 1, '_id' => 1)); + $doc = array_intersect_key($doc, ['_index' => 1, '_type' => 1, '_id' => 1]); $array['more_like_this']['like'] = $doc; } elseif (!empty($array['more_like_this']['like']['_source'])) { $doc = $array['more_like_this']['like']; diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php b/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php index 6b5459e..cb1f633 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/MultiMatch.php @@ -1,5 +1,4 @@ setParam('fields', $fields); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php b/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php index c8952de..1712976 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Nested.php @@ -1,5 +1,4 @@ setRawPrefix($prefix); } @@ -43,6 +42,6 @@ public function setRawPrefix(array $prefix) */ public function setPrefix($key, $value, $boost = 1.0) { - return $this->setRawPrefix(array($key => array('value' => $value, 'boost' => $boost))); + return $this->setRawPrefix([$key => ['value' => $value, 'boost' => $boost]]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php b/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php index be6d731..eaba20b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/QueryString.php @@ -1,5 +1,4 @@ array_merge(array('query' => $this->_queryString), $this->getParams())); + return ['query_string' => array_merge(['query' => $this->_queryString], $this->getParams())]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Range.php b/vendor/ruflin/elastica/lib/Elastica/Query/Range.php index 19117af..0e2fa07 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Range.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Range.php @@ -1,5 +1,4 @@ addField($fieldName, $args); diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php b/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php index 73e5af0..ab2ecbb 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Regexp.php @@ -1,5 +1,4 @@ setParam($key, array('value' => $value, 'boost' => $boost)); + return $this->setParam($key, ['value' => $value, 'boost' => $boost]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Script.php b/vendor/ruflin/elastica/lib/Elastica/Query/Script.php index bb872e6..32e82e5 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Script.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Script.php @@ -1,5 +1,4 @@ setQuery($query); - if (sizeof($fields)) { + if (count($fields)) { $this->setFields($fields); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Term.php b/vendor/ruflin/elastica/lib/Elastica/Query/Term.php index 8ca6dec..da4c2f7 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Term.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Term.php @@ -1,5 +1,4 @@ setRawTerm($term); } @@ -45,6 +44,6 @@ public function setRawTerm(array $term) */ public function setTerm($key, $value, $boost = 1.0) { - return $this->setRawTerm(array($key => array('value' => $value, 'boost' => $boost))); + return $this->setRawTerm([$key => ['value' => $value, 'boost' => $boost]]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php index fd4f1af..66eb390 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Terms.php @@ -1,5 +1,4 @@ setTerms($key, $terms); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php b/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php index c498098..f0c32f9 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/TopChildren.php @@ -1,5 +1,4 @@ array('value' => $this->_type), - ); + return [ + 'type' => ['value' => $this->_type], + ]; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php b/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php index 58e5d00..0ad85fb 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php +++ b/vendor/ruflin/elastica/lib/Elastica/Query/Wildcard.php @@ -1,5 +1,4 @@ setParam($key, array('value' => $value, 'boost' => $boost)); + return $this->setParam($key, ['value' => $value, 'boost' => $boost]); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php index 5f96053..c27434c 100644 --- a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php +++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder.php @@ -1,5 +1,4 @@ _dsl, $name), $arguments); + return call_user_func_array([$this->_dsl, $name], $arguments); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php index 1dcf401..e8d3003 100644 --- a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php +++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version.php @@ -1,5 +1,4 @@ queries); - break; + return in_array($name, $this->queries); case DSL::TYPE_FILTER: - $supports = in_array($name, $this->filters); - break; + return in_array($name, $this->filters); case DSL::TYPE_AGGREGATION: - $supports = in_array($name, $this->aggregations); - break; + return in_array($name, $this->aggregations); case DSL::TYPE_SUGGEST: - $supports = in_array($name, $this->suggesters); - break; - default: - // disables version check in Facade for custom DSL objects - $supports = true; + return in_array($name, $this->suggesters); } - return $supports; + // disables version check in Facade for custom DSL objects + return true; } /** diff --git a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Latest.php b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Latest.php index c546fce..b2c682e 100644 --- a/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Latest.php +++ b/vendor/ruflin/elastica/lib/Elastica/QueryBuilder/Version/Latest.php @@ -1,5 +1,4 @@ setPath($path); $this->setMethod($method); @@ -126,7 +125,7 @@ public function getQuery() * * @return $this */ - public function setQuery(array $query = array()) + public function setQuery(array $query = []) { return $this->setParam('query', $query); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php b/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php index 979c93d..872c2ad 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php +++ b/vendor/ruflin/elastica/lib/Elastica/Rescore/AbstractRescore.php @@ -1,5 +1,4 @@ setParam('query', array()); + $this->setParam('query', []); $this->setRescoreQuery($query); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Response.php b/vendor/ruflin/elastica/lib/Elastica/Response.php index 3f29a8e..e0a44cd 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Response.php +++ b/vendor/ruflin/elastica/lib/Elastica/Response.php @@ -1,5 +1,4 @@ getData(); - if (isset($response['error'])) { - return true; - } - - return false; + return isset($response['error']); } /** @@ -181,11 +181,7 @@ public function isOk() // Bulk insert checks. Check every item if (isset($data['status'])) { - if ($data['status'] >= 200 && $data['status'] <= 300) { - return true; - } - - return false; + return $data['status'] >= 200 && $data['status'] <= 300; } if (isset($data['items'])) { @@ -196,7 +192,9 @@ public function isOk() foreach ($data['items'] as $item) { if (isset($item['index']['ok']) && false == $item['index']['ok']) { return false; - } elseif (isset($item['index']['status']) && ($item['index']['status'] < 200 || $item['index']['status'] >= 300)) { + } + + if (isset($item['index']['status']) && ($item['index']['status'] < 200 || $item['index']['status'] >= 300)) { return false; } } @@ -244,11 +242,11 @@ public function getData() } if (empty($response)) { - $response = array(); + $response = []; } if (is_string($response)) { - $response = array('message' => $response); + $response = ['message' => $response]; } $this->_response = $response; diff --git a/vendor/ruflin/elastica/lib/Elastica/Result.php b/vendor/ruflin/elastica/lib/Elastica/Result.php index 74236d4..c37be4f 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Result.php +++ b/vendor/ruflin/elastica/lib/Elastica/Result.php @@ -1,5 +1,4 @@ _hit[$name]; } - return array(); + return []; } /** @@ -149,10 +148,10 @@ public function getVersion() */ public function getData() { - if (isset($this->_hit['fields']) && !isset($this->_hit['_source'])) { - return $this->getFields(); - } elseif (isset($this->_hit['fields']) && isset($this->_hit['_source'])) { - return array_merge($this->getFields(), $this->getSource()); + if (isset($this->_hit['fields'])) { + return isset($this->_hit['_source']) + ? array_merge($this->getFields(), $this->getSource()) + : $this->getFields(); } return $this->getSource(); @@ -191,30 +190,33 @@ public function getExplanation() /** * Returns Document. * - * @return \Elastica\Document + * @return Document */ public function getDocument() { - $doc = new \Elastica\Document(); + $doc = new Document(); $doc->setData($this->getSource()); $hit = $this->getHit(); - if ($this->hasParam('_source')) { - unset($hit['_source']); - } - if ($this->hasParam('_explanation')) { - unset($hit['_explanation']); - } - if ($this->hasParam('highlight')) { - unset($hit['highlight']); - } - if ($this->hasParam('_score')) { - unset($hit['_score']); - } + unset($hit['_source']); + unset($hit['_explanation']); + unset($hit['highlight']); + unset($hit['_score']); $doc->setParams($hit); return $doc; } + /** + * Sets a parameter on the hit. + * + * @param string $param + * @param mixed $value + */ + public function setParam($param, $value) + { + $this->_hit[$param] = $value; + } + /** * Magic function to directly access keys inside the result. * diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet.php index a09f94b..c423286 100644 --- a/vendor/ruflin/elastica/lib/Elastica/ResultSet.php +++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet.php @@ -1,5 +1,4 @@ getMaxScore() instead. The property will become removed in 4.0. * - * @var array Results + * @var float */ - protected $_results = array(); + protected $_maxScore; /** * Current position. * + * @deprecated Accessing this property in an extended class is deprecated. The property will become private in 4.0. + * * @var int Current position */ protected $_position = 0; /** - * Response. + * Query. + * + * @deprecated Accessing this property in an extended class is deprecated. The property will become private in 4.0. Access the response by calling getQuery * - * @var \Elastica\Response Response object + * @var Query Query object */ - protected $_response = null; + protected $_query; /** - * Query. + * Response. + * + * @deprecated Accessing this property in an extended class is deprecated. The property will become private in 4.0. Access the response by calling getResponse * - * @var \Elastica\Query Query object + * @var Response Response object */ - protected $_query; + protected $_response; /** - * @var int + * Results. + * + * @deprecated Accessing this property in an extended class is deprecated. The property will become private in 4.0. Modify results by implementing BuilderInterface and passing a new Builder to your \Elastica\Search instances. + * + * @var Result[] Results */ - protected $_took = 0; + protected $_results = []; /** + * @deprecated This property is deprecated. Use ResultSet->hasTimedOut() instead. The property will become removed in 4.0. + * * @var bool */ protected $_timedOut = false; /** + * @deprecated This property is deprecated. Use ResultSet->getTotalTime() instead. The property will become removed in 4.0. + * * @var int */ - protected $_totalHits = 0; + protected $_took; /** - * @var float + * @deprecated This property is deprecated. Use ResultSet->getTotalHits() instead. The property will become removed in 4.0. + * + * @var int */ - protected $_maxScore = 0; + protected $_totalHits; /** * Constructs ResultSet object. * - * @param \Elastica\Response $response Response object - * @param \Elastica\Query $query Query object + * @param Response $response Response object + * @param Query $query Query object + * @param Result[] $results */ - public function __construct(Response $response, Query $query) + public function __construct(Response $response, Query $query, $results) { - $this->rewind(); - $this->_init($response); $this->_query = $query; - } - - /** - * Creates a new ResultSet object. Can be configured to return a different - * implementation of the ResultSet class. - * - * @param Response $response - * @param Query $query - * - * @return ResultSet - */ - public static function create(Response $response, Query $query) - { - $class = static::$_class; - - return new $class($response, $query); - } - - /** - * Sets the class to be used for the static create method. - * - * @param string $class - */ - public static function setClass($class) - { - static::$_class = $class; - } - - /** - * Loads all data into the results object (initialisation). - * - * @param \Elastica\Response $response Response object - */ - protected function _init(Response $response) - { $this->_response = $response; - $result = $response->getData(); - $this->_totalHits = isset($result['hits']['total']) ? $result['hits']['total'] : 0; - $this->_maxScore = isset($result['hits']['max_score']) ? $result['hits']['max_score'] : 0; - $this->_took = isset($result['took']) ? $result['took'] : 0; - $this->_timedOut = !empty($result['timed_out']); - if (isset($result['hits']['hits'])) { - foreach ($result['hits']['hits'] as $hit) { - $this->_results[] = new Result($hit); - } - } + $this->_results = $results; + + $data = $response->getData(); + $this->_maxScore = isset($data['hits']['max_score']) ? (float) $data['hits']['max_score'] : 0; + $this->_timedOut = !empty($data['timed_out']); + $this->_took = isset($data['took']) ? $data['took'] : 0; + $this->_totalHits = isset($data['hits']['total']) ? (int) $data['hits']['total'] : 0; } /** @@ -145,7 +114,7 @@ public function getResults() */ public function getDocuments() { - $documents = array(); + $documents = []; foreach ($this->_results as $doc) { $documents[] = $doc->getDocument(); } @@ -174,7 +143,7 @@ public function getSuggests() { $data = $this->_response->getData(); - return isset($data['suggest']) ? $data['suggest'] : array(); + return isset($data['suggest']) ? $data['suggest'] : []; } /** @@ -198,7 +167,7 @@ public function getAggregations() { $data = $this->_response->getData(); - return isset($data['aggregations']) ? $data['aggregations'] : array(); + return isset($data['aggregations']) ? $data['aggregations'] : []; } /** @@ -227,7 +196,7 @@ public function getAggregation($name) */ public function getTotalHits() { - return (int) $this->_totalHits; + return $this->_totalHits; } /** @@ -237,7 +206,7 @@ public function getTotalHits() */ public function getMaxScore() { - return (float) $this->_maxScore; + return $this->_maxScore; } /** @@ -247,23 +216,23 @@ public function getMaxScore() */ public function getTotalTime() { - return (int) $this->_took; + return $this->_took; } /** - * Returns true iff the query has timed out. + * Returns true if the query has timed out. * * @return bool Timed out */ public function hasTimedOut() { - return (bool) $this->_timedOut; + return $this->_timedOut; } /** * Returns response object. * - * @return \Elastica\Response Response object + * @return Response Response object */ public function getResponse() { @@ -271,7 +240,7 @@ public function getResponse() } /** - * @return \Elastica\Query + * @return Query */ public function getQuery() { diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet/BuilderInterface.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet/BuilderInterface.php new file mode 100644 index 0000000..a9fd526 --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet/BuilderInterface.php @@ -0,0 +1,19 @@ +processors = $processors; + } + + /** + * {@inheritdoc} + */ + public function process(ResultSet $resultSet) + { + foreach ($this->processors as $processor) { + $processor->process($resultSet); + } + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet/DefaultBuilder.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet/DefaultBuilder.php new file mode 100644 index 0000000..f8f3d6f --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet/DefaultBuilder.php @@ -0,0 +1,49 @@ +buildResults($response); + $resultSet = new ResultSet($response, $query, $results); + + return $resultSet; + } + + /** + * Builds individual result objects. + * + * @param Response $response + * + * @return Result[] + */ + private function buildResults(Response $response) + { + $data = $response->getData(); + $results = []; + + if (!isset($data['hits']['hits'])) { + return $results; + } + + foreach ($data['hits']['hits'] as $hit) { + $results[] = new Result($hit); + } + + return $results; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessingBuilder.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessingBuilder.php new file mode 100644 index 0000000..44ac6fe --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessingBuilder.php @@ -0,0 +1,48 @@ +builder = $builder; + $this->processor = $processor; + } + + /** + * Runs any registered transformers on the ResultSet before + * returning it, allowing the transformers to inject additional + * data into each Result. + * + * @param Response $response + * @param Query $query + * + * @return ResultSet + */ + public function buildResultSet(Response $response, Query $query) + { + $resultSet = $this->builder->buildResultSet($response, $query); + + $this->processor->process($resultSet); + + return $resultSet; + } +} diff --git a/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessorInterface.php b/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessorInterface.php new file mode 100644 index 0000000..80aa2ba --- /dev/null +++ b/vendor/ruflin/elastica/lib/Elastica/ResultSet/ProcessorInterface.php @@ -0,0 +1,15 @@ +_nextScrollId = null; - $this->_options = array(null, null, null, null); + $this->_options = [null, null, null, null]; $this->_saveOptions(); diff --git a/vendor/ruflin/elastica/lib/Elastica/Script.php b/vendor/ruflin/elastica/lib/Elastica/Script.php index ee4bdbd..6204697 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Script.php +++ b/vendor/ruflin/elastica/lib/Elastica/Script.php @@ -1,5 +1,4 @@ $this->_script, - ); + ]; if (!empty($this->_params)) { $array['params'] = $this->_convertArrayable($this->_params); diff --git a/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFields.php b/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFields.php index f60f325..bb075dc 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFields.php +++ b/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFields.php @@ -1,5 +1,4 @@ setScripts($scripts); @@ -49,7 +48,7 @@ public function addScript($name, AbstractScript $script) */ public function setScripts(array $scripts) { - $this->_params = array(); + $this->_params = []; foreach ($scripts as $name => $script) { $this->addScript($name, $script); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFile.php b/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFile.php index eecd951..22e6415 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFile.php +++ b/vendor/ruflin/elastica/lib/Elastica/Script/ScriptFile.php @@ -1,5 +1,4 @@ $this->_scriptFile, - ); + ]; if (!empty($this->_params)) { $array['params'] = $this->_params; diff --git a/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php b/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php index 0ce748d..2c73903 100644 --- a/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php +++ b/vendor/ruflin/elastica/lib/Elastica/ScriptFields.php @@ -1,5 +1,4 @@ @@ -38,7 +37,7 @@ class Scroll implements \Iterator * * @var array */ - protected $_options = array(null, null, null); + protected $_options = [null, null, null]; /** * Constructor. @@ -117,7 +116,7 @@ public function rewind() { // reset state $this->_nextScrollId = null; - $this->_options = array(null, null, null); + $this->_options = [null, null, null]; // initial search $this->_saveOptions(); diff --git a/vendor/ruflin/elastica/lib/Elastica/Search.php b/vendor/ruflin/elastica/lib/Elastica/Search.php index eec9d4f..6fa449d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Search.php +++ b/vendor/ruflin/elastica/lib/Elastica/Search.php @@ -1,9 +1,10 @@ _builder = $builder ?: new DefaultBuilder(); $this->_client = $client; } @@ -111,7 +119,7 @@ public function addIndex($index) * * @return $this */ - public function addIndices(array $indices = array()) + public function addIndices(array $indices = []) { foreach ($indices as $index) { $this->addIndex($index); @@ -151,7 +159,7 @@ public function addType($type) * * @return $this */ - public function addTypes(array $types = array()) + public function addTypes(array $types = []) { foreach ($types as $type) { $this->addType($type); @@ -212,7 +220,7 @@ public function setOptions(array $options) */ public function clearOptions() { - $this->_options = array(); + $this->_options = []; return $this; } @@ -227,10 +235,6 @@ public function addOption($key, $value) { $this->_validateOption($key); - if (!isset($this->_options[$key])) { - $this->_options[$key] = array(); - } - $this->_options[$key][] = $value; return $this; @@ -462,7 +466,7 @@ public function search($query = '', $options = null) $params ); - return ResultSet::create($response, $query); + return $this->_builder->buildResultSet($response, $query); } /** @@ -482,9 +486,9 @@ public function count($query = '', $fullResult = false) $path, Request::GET, $query->toArray(), - array(self::OPTION_SEARCH_TYPE => self::OPTION_SEARCH_TYPE_COUNT) + [self::OPTION_SEARCH_TYPE => self::OPTION_SEARCH_TYPE_COUNT] ); - $resultSet = ResultSet::create($response, $query); + $resultSet = $this->_builder->buildResultSet($response, $query); return $fullResult ? $resultSet : $resultSet->getTotalHits(); } @@ -525,7 +529,7 @@ public function setOptionsAndQuery($options = null, $query = '') */ public function setSuggest(Suggest $suggest) { - return $this->setOptionsAndQuery(array(self::OPTION_SEARCH_TYPE_SUGGEST => 'suggest'), $suggest); + return $this->setOptionsAndQuery([self::OPTION_SEARCH_TYPE_SUGGEST => 'suggest'], $suggest); } /** @@ -556,4 +560,12 @@ public function scanAndScroll($expiryTime = '1m', $sizePerShard = 1000) { return new ScanAndScroll($this, $expiryTime, $sizePerShard); } + + /** + * @return BuilderInterface + */ + public function getResultSetBuilder() + { + return $this->_builder; + } } diff --git a/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php b/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php index ef1a1cd..03f162a 100644 --- a/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php +++ b/vendor/ruflin/elastica/lib/Elastica/SearchableInterface.php @@ -1,5 +1,4 @@ $type, 'settings' => $settings, - ); + ]; return $this->request($name, Request::PUT, $data); } @@ -89,9 +88,9 @@ public function getAllRepositories() * * @return Response */ - public function createSnapshot($repository, $name, $options = array(), $waitForCompletion = false) + public function createSnapshot($repository, $name, $options = [], $waitForCompletion = false) { - return $this->request($repository.'/'.$name, Request::PUT, $options, array('wait_for_completion' => $waitForCompletion)); + return $this->request($repository.'/'.$name, Request::PUT, $options, ['wait_for_completion' => $waitForCompletion]); } /** @@ -155,9 +154,9 @@ public function deleteSnapshot($repository, $name) * * @return Response */ - public function restoreSnapshot($repository, $name, $options = array(), $waitForCompletion = false) + public function restoreSnapshot($repository, $name, $options = [], $waitForCompletion = false) { - return $this->request($repository.'/'.$name.'/_restore', Request::POST, $options, array('wait_for_completion' => $waitForCompletion)); + return $this->request($repository.'/'.$name.'/_restore', Request::POST, $options, ['wait_for_completion' => $waitForCompletion]); } /** @@ -170,7 +169,7 @@ public function restoreSnapshot($repository, $name, $options = array(), $waitFor * * @return Response */ - public function request($path, $method = Request::GET, $data = array(), array $query = array()) + public function request($path, $method = Request::GET, $data = [], array $query = []) { return $this->_client->request('/_snapshot/'.$path, $method, $data, $query); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Status.php b/vendor/ruflin/elastica/lib/Elastica/Status.php index c3e4a7c..b6333cb 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Status.php +++ b/vendor/ruflin/elastica/lib/Elastica/Status.php @@ -1,5 +1,4 @@ getResponse()->getTransferInfo(); // 404 means the index alias doesn't exist which means no indexes have it. if ($transferInfo['http_code'] === 404) { - return array(); + return []; } // If we don't have a 404 then this is still unexpected so rethrow the exception. throw $e; } - $indices = array(); + $indices = []; foreach ($response->getData() as $name => $unused) { $indices[] = new Index($this->_client, $name); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest.php b/vendor/ruflin/elastica/lib/Elastica/Suggest.php index 91f15a0..e367e38 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest.php @@ -1,5 +1,4 @@ setParam('highlight', array( + return $this->setParam('highlight', [ 'pre_tag' => $preTag, 'post_tag' => $postTag, - )); + ]); } /** @@ -103,9 +102,9 @@ public function setHighlight($preTag, $postTag) */ public function setStupidBackoffSmoothing($discount = 0.4) { - return $this->setSmoothingModel('stupid_backoff', array( + return $this->setSmoothingModel('stupid_backoff', [ 'discount' => $discount, - )); + ]); } /** @@ -115,9 +114,9 @@ public function setStupidBackoffSmoothing($discount = 0.4) */ public function setLaplaceSmoothing($alpha = 0.5) { - return $this->setSmoothingModel('laplace', array( + return $this->setSmoothingModel('laplace', [ 'alpha' => $alpha, - )); + ]); } /** @@ -129,11 +128,11 @@ public function setLaplaceSmoothing($alpha = 0.5) */ public function setLinearInterpolationSmoothing($trigramLambda, $bigramLambda, $unigramLambda) { - return $this->setSmoothingModel('linear_interpolation', array( + return $this->setSmoothingModel('linear_interpolation', [ 'trigram_lambda' => $trigramLambda, 'bigram_lambda' => $bigramLambda, 'unigram_lambda' => $unigramLambda, - )); + ]); } /** @@ -144,9 +143,9 @@ public function setLinearInterpolationSmoothing($trigramLambda, $bigramLambda, $ */ public function setSmoothingModel($model, array $params) { - return $this->setParam('smoothing', array( + return $this->setParam('smoothing', [ $model => $params, - )); + ]); } /** @@ -175,10 +174,6 @@ public function toArray() $keys = array_keys($generator); $values = array_values($generator); - if (!isset($array[$baseName][$keys[0]])) { - $array[$baseName][$keys[0]] = array(); - } - $array[$baseName][$keys[0]][] = $values[0]; } diff --git a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php index dc51a3a..5af824b 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php +++ b/vendor/ruflin/elastica/lib/Elastica/Suggest/Term.php @@ -1,5 +1,4 @@ getClient()); + $search = $oldIndex->createSearch(); $options = array_merge( - array( + [ self::OPTION_TYPE => null, self::OPTION_QUERY => new MatchAll(), self::OPTION_EXPIRY_TIME => '1m', self::OPTION_SIZE_PER_SHARD => 1000, - ), + ], $options ); - $search->addIndex($oldIndex); if (isset($options[self::OPTION_TYPE])) { $type = $options[self::OPTION_TYPE]; - $search->addTypes(is_array($type) ? $type : array($type)); + $search->addTypes(is_array($type) ? $type : [$type]); } $search->setQuery($options[self::OPTION_QUERY]); @@ -125,13 +123,13 @@ public static function reindex( public static function copy( Index $oldIndex, Index $newIndex, - array $options = array() + array $options = [] ) { // normalize types to array of string - $types = array(); + $types = []; if (isset($options[self::OPTION_TYPE])) { $types = $options[self::OPTION_TYPE]; - $types = is_array($types) ? $types : array($types); + $types = is_array($types) ? $types : [$types]; $types = array_map( function ($type) { diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php b/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php index 88b6319..7fdaa6f 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/AbstractTransport.php @@ -1,5 +1,4 @@ 'HttpAdapter', 'nulltransport' => 'NullTransport', - ); + ]; if (isset($specialTransports[strtolower($transport)])) { $transport = $specialTransports[strtolower($transport)]; diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/AwsAuthV4.php b/vendor/ruflin/elastica/lib/Elastica/Transport/AwsAuthV4.php index 39ee74a..862207f 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/AwsAuthV4.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/AwsAuthV4.php @@ -1,5 +1,4 @@ push($this->getSigningMiddleware(), 'sign'); - self::$_guzzleClientConnection = new Client(array( + self::$_guzzleClientConnection = new Client([ 'base_uri' => $baseUrl, 'handler' => $stack, - )); + ]); } return self::$_guzzleClientConnection; diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php index 8702bca..67f4d36 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Guzzle.php @@ -1,5 +1,4 @@ _getGuzzleClient($this->_getBaseUrl($connection), $connection->isPersistent()); - $options = array( + $options = [ 'exceptions' => false, // 4xx and 5xx is expected and NOT an exceptions in this context - ); + ]; if ($connection->getTimeout()) { $options['timeout'] = $connection->getTimeout(); } @@ -90,10 +89,10 @@ public function exec(Request $request, array $params) } $response->setTransferInfo( - array( + [ 'request_header' => $request->getMethod(), 'http_code' => $res->getStatusCode(), - ) + ] ); if ($response->hasError()) { @@ -120,7 +119,7 @@ protected function _createPsr7Request(Request $request, Connection $connection) $this->_getActionPath($request), $connection->hasConfig('headers') && is_array($connection->getConfig('headers')) ? $connection->getConfig('headers') - : array() + : [] ); $data = $request->getData(); @@ -148,14 +147,15 @@ protected function _createPsr7Request(Request $request, Connection $connection) /** * Return Guzzle resource. * - * @param bool $persistent False if not persistent connection + * @param string $baseUrl + * @param bool $persistent False if not persistent connection * * @return Client */ protected function _getGuzzleClient($baseUrl, $persistent = true) { if (!$persistent || !self::$_guzzleClientConnection) { - self::$_guzzleClientConnection = new Client(array('base_uri' => $baseUrl)); + self::$_guzzleClientConnection = new Client(['base_uri' => $baseUrl]); } return self::$_guzzleClientConnection; @@ -176,12 +176,12 @@ protected function _getBaseUrl(Connection $connection) if (!empty($url)) { $baseUri = $url; } else { - $baseUri = (string) Uri::fromParts(array( + $baseUri = (string) Uri::fromParts([ 'scheme' => $this->_scheme, 'host' => $connection->getHost(), 'port' => $connection->getPort(), 'path' => ltrim('/', $connection->getPath()), - )); + ]); } return rtrim($baseUri, '/'); diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php index c605b30..45ed1ed 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Http.php @@ -1,5 +1,4 @@ getUsername(); $password = $connection->getPassword(); - if (!is_null($username) and !is_null($password)) { + if (!is_null($username) && !is_null($password)) { curl_setopt($conn, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($conn, CURLOPT_USERPWD, "$username:$password"); } $this->_setupCurl($conn); - $headersConfig = $connection->hasConfig('headers') ? $connection->getConfig('headers') : array(); + $headersConfig = $connection->hasConfig('headers') ? $connection->getConfig('headers') : []; + + $headers = []; if (!empty($headersConfig)) { - $headers = array(); + $headers = []; while (list($header, $headerValue) = each($headersConfig)) { array_push($headers, $header.': '.$headerValue); } - - curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); } // TODO: REFACTOR @@ -136,7 +135,7 @@ public function exec(Request $request, array $params) curl_setopt($conn, CURLOPT_POSTFIELDS, gzencode($content)); // ... and tell ES that it is compressed - curl_setopt($conn, CURLOPT_HTTPHEADER, array('Content-Encoding: gzip')); + array_push($headers, 'Content-Encoding: gzip'); } else { curl_setopt($conn, CURLOPT_POSTFIELDS, $content); } @@ -144,6 +143,8 @@ public function exec(Request $request, array $params) curl_setopt($conn, CURLOPT_POSTFIELDS, ''); } + curl_setopt($conn, CURLOPT_HTTPHEADER, $headers); + curl_setopt($conn, CURLOPT_NOBODY, $httpMethod == 'HEAD'); curl_setopt($conn, CURLOPT_CUSTOMREQUEST, $httpMethod); diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php b/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php index f88aebe..9b88373 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/HttpAdapter.php @@ -1,5 +1,4 @@ httpAdapter->sendRequest($httpAdapterRequest); $end = microtime(true); - $elasticaResponse = $this->_createElasticaResponse($httpAdapterResponse, $connection); + $elasticaResponse = $this->_createElasticaResponse($httpAdapterResponse); $elasticaResponse->setQueryTime($end - $start); $elasticaResponse->setTransferInfo( - array( + [ 'request_header' => $httpAdapterRequest->getMethod(), 'http_code' => $httpAdapterResponse->getStatusCode(), - ) + ] ); if ($elasticaResponse->hasError()) { @@ -107,7 +106,7 @@ protected function _createHttpAdapterRequest(ElasticaRequest $elasticaRequest, C $data = $elasticaRequest->getData(); $body = null; $method = $elasticaRequest->getMethod(); - $headers = $connection->hasConfig('headers') ?: array(); + $headers = $connection->hasConfig('headers') ?: []; if (!empty($data) || '0' === $data) { if ($method == ElasticaRequest::GET) { $method = ElasticaRequest::POST; diff --git a/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php b/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php index 996bb21..b2b489d 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php +++ b/vendor/ruflin/elastica/lib/Elastica/Transport/Https.php @@ -1,5 +1,4 @@ 0, 'timed_out' => false, - '_shards' => array( + '_shards' => [ 'total' => 0, 'successful' => 0, 'failed' => 0, - ), - 'hits' => array( + ], + 'hits' => [ 'total' => 0, 'max_score' => null, - 'hits' => array(), - ), + 'hits' => [], + ], 'params' => $params, - ); + ]; return new Response(JSON::stringify($response)); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Type.php b/vendor/ruflin/elastica/lib/Elastica/Type.php index 2a6bb8c..6e8cf88 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Type.php +++ b/vendor/ruflin/elastica/lib/Elastica/Type.php @@ -1,11 +1,11 @@ getOptions( - array( + [ 'version', 'version_type', 'routing', @@ -83,7 +83,7 @@ public function addDocument(Document $doc) 'replication', 'refresh', 'timeout', - ) + ] ); $response = $this->request($path, $type, $doc->getData(), $options); @@ -91,7 +91,7 @@ public function addDocument(Document $doc) $data = $response->getData(); // set autogenerated id to document if (($doc->isAutoPopulate() - || $this->getIndex()->getClient()->getConfigValue(array('document', 'autoPopulate'), false)) + || $this->getIndex()->getClient()->getConfigValue(['document', 'autoPopulate'], false)) && $response->isOk() ) { if (!$doc->hasId()) { @@ -142,7 +142,7 @@ public function addObject($object, Document $doc = null) * * @return \Elastica\Response */ - public function updateDocument($data, array $options = array()) + public function updateDocument($data, array $options = []) { if (!($data instanceof Document) && !($data instanceof AbstractScript)) { throw new \InvalidArgumentException('Data should be a Document or Script'); @@ -214,7 +214,7 @@ public function addObjects(array $objects) throw new RuntimeException('No serializer defined'); } - $docs = array(); + $docs = []; foreach ($objects as $object) { $data = call_user_func($this->_serializer, $object); $doc = new Document(); @@ -237,11 +237,11 @@ public function addObjects(array $objects) * * @return \Elastica\Document */ - public function getDocument($id, $options = array()) + public function getDocument($id, $options = []) { $path = urlencode($id); - $response = $this->request($path, Request::GET, array(), $options); + $response = $this->request($path, Request::GET, [], $options); $result = $response->getData(); if (!isset($result['found']) || $result['found'] === false) { @@ -253,7 +253,7 @@ public function getDocument($id, $options = array()) } elseif (isset($result['_source'])) { $data = $result['_source']; } else { - $data = array(); + $data = []; } $document = new Document($id, $data, $this->getName(), $this->getIndex()); @@ -268,7 +268,7 @@ public function getDocument($id, $options = array()) * * @return Document */ - public function createDocument($id = '', $data = array()) + public function createDocument($id = '', $data = []) { $document = new Document($id, $data); $document->setType($this); @@ -318,7 +318,7 @@ public function getMapping() return $mapping['mappings']; } - return array(); + return []; } /** @@ -326,15 +326,14 @@ public function getMapping() * * @param string|array|\Elastica\Query $query Array with all query data inside or a Elastica\Query object * @param int|array $options OPTIONAL Limit or associative array of options (option=>value) + * @param BuilderInterface $builder * - * @return \Elastica\Search + * @return Search */ - public function createSearch($query = '', $options = null) + public function createSearch($query = '', $options = null, BuilderInterface $builder = null) { - $search = new Search($this->getIndex()->getClient()); - $search->addIndex($this->getIndex()); + $search = $this->getIndex()->createSearch($query, $options, $builder); $search->addType($this); - $search->setOptionsAndQuery($options, $query); return $search; } @@ -390,7 +389,7 @@ public function getIndex() public function deleteDocument(Document $document) { $options = $document->getOptions( - array( + [ 'version', 'version_type', 'routing', @@ -399,7 +398,7 @@ public function deleteDocument(Document $document) 'consistency', 'refresh', 'timeout', - ) + ] ); return $this->deleteById($document->getId(), $options); @@ -436,7 +435,7 @@ public function deleteDocuments(array $docs) * * @return \Elastica\Response Response object */ - public function deleteById($id, array $options = array()) + public function deleteById($id, array $options = []) { if (empty($id) || !trim($id)) { throw new \InvalidArgumentException(); @@ -444,7 +443,7 @@ public function deleteById($id, array $options = array()) $id = urlencode($id); - $response = $this->request($id, Request::DELETE, array(), $options); + $response = $this->request($id, Request::DELETE, [], $options); $responseData = $response->getData(); @@ -478,17 +477,17 @@ public function deleteIds(array $ids, $routing = false) * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html */ - public function deleteByQuery($query, array $options = array()) + public function deleteByQuery($query, array $options = []) { if (is_string($query)) { // query_string queries are not supported for delete by query operations $options['q'] = $query; - return $this->request('_query', Request::DELETE, array(), $options); + return $this->request('_query', Request::DELETE, [], $options); } $query = Query::create($query); - return $this->request('_query', Request::DELETE, array('query' => $query->getQuery()->toArray()), $options); + return $this->request('_query', Request::DELETE, ['query' => is_array($query) ? $query : $query->toArray()], $options); } /** @@ -513,7 +512,7 @@ public function delete() * * @return \Elastica\Response Response object */ - public function request($path, $method, $data = array(), array $query = array()) + public function request($path, $method, $data = [], array $query = []) { $path = $this->getName().'/'.$path; @@ -546,6 +545,6 @@ public function exists() $response = $this->getIndex()->request($this->getName(), Request::HEAD); $info = $response->getTransferInfo(); - return (bool) ($info['http_code'] == 200); + return $info['http_code'] == 200; } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php b/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php index 15f3682..de6ff8c 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php +++ b/vendor/ruflin/elastica/lib/Elastica/Type/AbstractType.php @@ -1,5 +1,4 @@ getType()); $mapping->setProperties($this->_mapping); - $mapping->setSource(array('enabled' => $this->_source)); + $mapping->setSource(['enabled' => $this->_source]); $mapping->send(); } diff --git a/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php b/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php index 8603c06..9cbaeed 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php +++ b/vendor/ruflin/elastica/lib/Elastica/Type/Mapping.php @@ -1,5 +1,4 @@ setType($type); @@ -135,7 +134,7 @@ public function setSource(array $source) */ public function disableSource($enabled = false) { - return $this->setSource(array('enabled' => $enabled)); + return $this->setSource(['enabled' => $enabled]); } /** @@ -202,7 +201,7 @@ public function setAllField(array $params) */ public function enableAllField($enabled = true) { - return $this->setAllField(array('enabled' => $enabled)); + return $this->setAllField(['enabled' => $enabled]); } /** @@ -226,7 +225,7 @@ public function setTtl(array $params) */ public function enableTtl($enabled = true) { - return $this->setTTL(array('enabled' => $enabled)); + return $this->setTTL(['enabled' => $enabled]); } /** @@ -238,7 +237,7 @@ public function enableTtl($enabled = true) */ public function setParent($type) { - return $this->setParam('_parent', array('type' => $type)); + return $this->setParam('_parent', ['type' => $type]); } /** @@ -256,7 +255,7 @@ public function toArray() throw new InvalidException('Type has to be set'); } - return array($type->getName() => $this->_mapping); + return [$type->getName() => $this->_mapping]; } /** @@ -266,7 +265,7 @@ public function toArray() * * @return \Elastica\Response Response object */ - public function send(array $query = array()) + public function send(array $query = []) { $path = '_mapping'; @@ -287,14 +286,14 @@ public static function create($mapping) if (is_array($mapping)) { $mappingObject = new self(); $mappingObject->setProperties($mapping); - } else { - $mappingObject = $mapping; + + return $mappingObject; } - if (!$mappingObject instanceof self) { - throw new InvalidException('Invalid object type'); + if ($mapping instanceof self) { + return $mapping; } - return $mappingObject; + throw new InvalidException('Invalid object type'); } } diff --git a/vendor/ruflin/elastica/lib/Elastica/Util.php b/vendor/ruflin/elastica/lib/Elastica/Util.php index a1ba71c..cd6df2f 100644 --- a/vendor/ruflin/elastica/lib/Elastica/Util.php +++ b/vendor/ruflin/elastica/lib/Elastica/Util.php @@ -1,5 +1,4 @@ '); + $chars = ['\\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '/', '<', '>']; foreach ($chars as $char) { $result = str_replace($char, '\\'.$char, $result); @@ -68,7 +67,7 @@ public static function escapeTerm($term) */ public static function replaceBooleanWords($term) { - $replacementMap = array(' AND ' => ' && ', ' OR ' => ' || ', ' NOT ' => ' !'); + $replacementMap = [' AND ' => ' && ', ' OR ' => ' || ', ' NOT ' => ' !']; $result = strtr($term, $replacementMap); return $result; @@ -109,7 +108,7 @@ public static function toSnakeCase($string) * * This is the lucene date format * - * @param int $date Date input (could be string etc.) -> must be supported by strtotime + * @param int|string $date Date input (could be string etc.) -> must be supported by strtotime * * @return string Converted date string */ diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AbstractSimpleAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AbstractSimpleAggregationTest.php index 4a4ded6..13f12a1 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AbstractSimpleAggregationTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AbstractSimpleAggregationTest.php @@ -1,5 +1,4 @@ aggregation = $this->getMockForAbstractClass( 'Elastica\Aggregation\AbstractSimpleAggregation', - array('whatever') + ['whatever'] ); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php index 599a167..9b7c34f 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php index 60062e9..48003d7 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('color' => 'blue')), - new Document(2, array('color' => 'blue')), - new Document(3, array('color' => 'red')), - new Document(4, array('color' => 'green')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['color' => 'blue']), + new Document(2, ['color' => 'blue']), + new Document(3, ['color' => 'red']), + new Document(4, ['color' => 'green']), + ]); $index->refresh(); @@ -69,23 +68,23 @@ public function testPrecisionThreshold($threshold) public function invalidPrecisionThresholdProvider() { - return array( - 'string' => array('100'), - 'float' => array(7.8), - 'boolean' => array(true), - 'array' => array(array()), - 'object' => array(new \StdClass()), - ); + return [ + 'string' => ['100'], + 'float' => [7.8], + 'boolean' => [true], + 'array' => [[]], + 'object' => [new \StdClass()], + ]; } public function validPrecisionThresholdProvider() { - return array( - 'negative-int' => array(-140), - 'zero' => array(0), - 'positive-int' => array(150), - 'more-than-max' => array(40001), - ); + return [ + 'negative-int' => [-140], + 'zero' => [0], + 'positive-int' => [150], + 'more-than-max' => [40001], + ]; } /** @@ -118,20 +117,20 @@ public function testInvalidRehash($rehash) public function invalidRehashProvider() { - return array( - 'string' => array('100'), - 'int' => array(100), - 'float' => array(7.8), - 'array' => array(array()), - 'object' => array(new \StdClass()), - ); + return [ + 'string' => ['100'], + 'int' => [100], + 'float' => [7.8], + 'array' => [[]], + 'object' => [new \StdClass()], + ]; } public function validRehashProvider() { - return array( - 'true' => array(true), - 'false' => array(false), - ); + return [ + 'true' => [true], + 'false' => [false], + ]; } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ChildrenTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ChildrenTest.php new file mode 100644 index 0000000..acc61ac --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ChildrenTest.php @@ -0,0 +1,106 @@ +_createIndex(); + + // add employee type - child + $employeeType = $index->getType('employee'); + $employeeMapping = new Mapping($employeeType, + [ + 'name' => ['type' => 'string'], + ] + ); + $employeeMapping->setParent('company'); + $employeeType->setMapping($employeeMapping); + + // add company type - parent + $companyType = $index->getType('company'); + $companyMapping = new Mapping($companyType, + [ + 'name' => ['type' => 'string'], + ] + ); + $companyType->setMapping($companyMapping); + + // add company documents + $companyType->addDocuments([ + new Document(1, ['name' => 'Company1']), + new Document(2, ['name' => 'Company2']), + ]); + + $employee1 = new Document(1, [ + 'name' => 'foo', + ]); + $employee2 = new Document(2, [ + 'name' => 'bar', + ]); + $employee3 = new Document(3, [ + 'name' => 'foo', + ]); + $employee4 = new Document(4, [ + 'name' => 'baz', + ]); + $employee5 = new Document(5, [ + 'name' => 'foo', + ]); + + // add employee documents and set parent + $employeeType->addDocuments([ + $employee1->setParent(1), + $employee2->setParent(1), + $employee3->setParent(1), + $employee4->setParent(2), + $employee5->setParent(2), + ]); + $index->refresh(); + + return $index; + } + + /** + * @group functional + */ + public function testChildrenAggregation() + { + $agg = new Children('children'); + $agg->setType('employee'); + + $names = new Terms('name'); + $names->setField('name'); + + $agg->addAggregation($names); + + $query = new Query(); + $query->addAggregation($agg); + + $companyType = $this->_getIndexForTest()->getType('company'); + $aggregations = $companyType->search($query)->getAggregations(); + + // check children aggregation exists + $this->assertArrayHasKey('children', $aggregations); + + $childrenAggregations = $aggregations['children']; + + // check names aggregation exists inside children aggregation + $this->assertArrayHasKey('name', $childrenAggregations); + $this->assertCount(3, $childrenAggregations['name']['buckets']); + + // check names aggregation works inside children aggregation + $names = [ + ['key' => 'foo', 'doc_count' => 3], + ['key' => 'bar', 'doc_count' => 1], + ['key' => 'baz', 'doc_count' => 1], + ]; + $this->assertEquals($names, $childrenAggregations['name']['buckets']); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php index 44aa591..852e076 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'created' => array('type' => 'date'), - ))); + $type->setMapping(new Mapping(null, [ + 'created' => ['type' => 'date'], + ])); - $type->addDocuments(array( - new Document(1, array('created' => '2014-01-29T00:20:00')), - new Document(2, array('created' => '2014-01-29T02:20:00')), - new Document(3, array('created' => '2014-01-29T03:20:00')), - )); + $type->addDocuments([ + new Document(1, ['created' => '2014-01-29T00:20:00']), + new Document(2, ['created' => '2014-01-29T02:20:00']), + new Document(3, ['created' => '2014-01-29T03:20:00']), + ]); $index->refresh(); @@ -64,13 +63,13 @@ public function testSetOffset() $agg->setOffset('3m'); - $expected = array( - 'date_histogram' => array( + $expected = [ + 'date_histogram' => [ 'field' => 'created', 'interval' => '1h', 'offset' => '3m', - ), - ); + ], + ]; $this->assertEquals($expected, $agg->toArray()); @@ -103,13 +102,13 @@ public function testSetTimezone() $agg->setTimezone('-02:30'); - $expected = array( - 'date_histogram' => array( + $expected = [ + 'date_histogram' => [ 'field' => 'created', 'interval' => '1h', 'time_zone' => '-02:30', - ), - ); + ], + ]; $this->assertEquals($expected, $agg->toArray()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php index 611246a..166d2cf 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'created' => array('type' => 'date'), - ))); + $type->setMapping(new Mapping(null, [ + 'created' => ['type' => 'date'], + ])); - $type->addDocuments(array( - new Document(1, array('created' => 1390962135000)), - new Document(2, array('created' => 1390965735000)), - new Document(3, array('created' => 1390954935000)), - )); + $type->addDocuments([ + new Document(1, ['created' => 1390962135000]), + new Document(2, ['created' => 1390965735000]), + new Document(3, ['created' => 1390954935000]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php index f58bbba..25ce921 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php index d526596..728db4d 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5, 'color' => 'blue')), - new Document(2, array('price' => 8, 'color' => 'blue')), - new Document(3, array('price' => 1, 'color' => 'red')), - new Document(4, array('price' => 3, 'color' => 'green')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5, 'color' => 'blue']), + new Document(2, ['price' => 8, 'color' => 'blue']), + new Document(3, ['price' => 1, 'color' => 'red']), + new Document(4, ['price' => 3, 'color' => 'green']), + ]); $index->refresh(); @@ -53,10 +52,10 @@ public function testConstructorWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Aggregation\Filter passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', 'Deprecated: Elastica\Aggregation\Filter\setFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -86,9 +85,9 @@ public function testSetFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Aggregation\Filter\setFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -97,15 +96,15 @@ public function testSetFilterWithLegacyFilterDeprecated() */ public function testToArray() { - $expected = array( - 'filter' => array('range' => array('stock' => array('gt' => 0))), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filter' => ['range' => ['stock' => ['gt' => 0]]], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filter('in_stock_products'); - $agg->setFilter(new RangeQuery('stock', array('gt' => 0))); + $agg->setFilter(new RangeQuery('stock', ['gt' => 0])); $avg = new Avg('avg_price'); $avg->setField('price'); $agg->addAggregation($avg); @@ -118,16 +117,16 @@ public function testToArray() */ public function testToArrayWithLegacy() { - $expected = array( - 'filter' => array('range' => array('stock' => array('gt' => 0))), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filter' => ['range' => ['stock' => ['gt' => 0]]], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filter('in_stock_products'); $this->hideDeprecated(); - $agg->setFilter(new Range('stock', array('gt' => 0))); + $agg->setFilter(new Range('stock', ['gt' => 0])); $this->showDeprecated(); $avg = new Avg('avg_price'); $avg->setField('price'); @@ -142,7 +141,7 @@ public function testToArrayWithLegacy() public function testFilterAggregation() { $agg = new Filter('filter'); - $agg->setFilter(new TermQuery(array('color' => 'blue'))); + $agg->setFilter(new TermQuery(['color' => 'blue'])); $avg = new Avg('price'); $avg->setField('price'); $agg->addAggregation($avg); @@ -163,7 +162,7 @@ public function testFilterAggregationWithLegacyFilter() { $agg = new Filter('filter'); $this->hideDeprecated(); - $agg->setFilter(new Term(array('color' => 'blue'))); + $agg->setFilter(new Term(['color' => 'blue'])); $this->showDeprecated(); $avg = new Avg('price'); $avg->setField('price'); @@ -200,15 +199,15 @@ public function testFilterNoSubAggregation() */ public function testConstruct() { - $agg = new Filter('foo', new TermQuery(array('color' => 'blue'))); + $agg = new Filter('foo', new TermQuery(['color' => 'blue'])); - $expected = array( - 'filter' => array( - 'term' => array( + $expected = [ + 'filter' => [ + 'term' => [ 'color' => 'blue', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $agg->toArray()); } @@ -219,16 +218,16 @@ public function testConstruct() public function testConstructWithLegacyFilter() { $this->hideDeprecated(); - $agg = new Filter('foo', new Term(array('color' => 'blue'))); + $agg = new Filter('foo', new Term(['color' => 'blue'])); $this->showDeprecated(); - $expected = array( - 'filter' => array( - 'term' => array( + $expected = [ + 'filter' => [ + 'term' => [ 'color' => 'blue', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $agg->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php index 4408170..f696de2 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php @@ -1,5 +1,4 @@ _createIndex('filter'); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5, 'color' => 'blue')), - new Document(2, array('price' => 8, 'color' => 'blue')), - new Document(3, array('price' => 1, 'color' => 'red')), - new Document(4, array('price' => 3, 'color' => 'green')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5, 'color' => 'blue']), + new Document(2, ['price' => 8, 'color' => 'blue']), + new Document(3, ['price' => 1, 'color' => 'red']), + new Document(4, ['price' => 3, 'color' => 'green']), + ]); $index->refresh(); @@ -53,9 +52,9 @@ public function testSetFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Aggregation\Filters\addFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -64,34 +63,34 @@ public function testSetFilterWithLegacyFilterDeprecated() */ public function testToArrayUsingNamedFilters() { - $expected = array( - 'filters' => array( - 'filters' => array( - '' => array( - 'term' => array('color' => ''), - ), - '0' => array( - 'term' => array('color' => '0'), - ), - 'blue' => array( - 'term' => array('color' => 'blue'), - ), - 'red' => array( - 'term' => array('color' => 'red'), - ), - ), - ), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filters' => [ + 'filters' => [ + '' => [ + 'term' => ['color' => ''], + ], + '0' => [ + 'term' => ['color' => '0'], + ], + 'blue' => [ + 'term' => ['color' => 'blue'], + ], + 'red' => [ + 'term' => ['color' => 'red'], + ], + ], + ], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filters('by_color'); - $agg->addFilter(new Query\Term(array('color' => '')), ''); - $agg->addFilter(new Query\Term(array('color' => '0')), '0'); - $agg->addFilter(new Query\Term(array('color' => 'blue')), 'blue'); - $agg->addFilter(new Query\Term(array('color' => 'red')), 'red'); + $agg->addFilter(new Query\Term(['color' => '']), ''); + $agg->addFilter(new Query\Term(['color' => '0']), '0'); + $agg->addFilter(new Query\Term(['color' => 'blue']), 'blue'); + $agg->addFilter(new Query\Term(['color' => 'red']), 'red'); $avg = new Avg('avg_price'); $avg->setField('price'); @@ -105,35 +104,35 @@ public function testToArrayUsingNamedFilters() */ public function testToArrayUsingNamedFiltersWithLegacyFilters() { - $expected = array( - 'filters' => array( - 'filters' => array( - '' => array( - 'term' => array('color' => ''), - ), - '0' => array( - 'term' => array('color' => '0'), - ), - 'blue' => array( - 'term' => array('color' => 'blue'), - ), - 'red' => array( - 'term' => array('color' => 'red'), - ), - ), - ), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filters' => [ + 'filters' => [ + '' => [ + 'term' => ['color' => ''], + ], + '0' => [ + 'term' => ['color' => '0'], + ], + 'blue' => [ + 'term' => ['color' => 'blue'], + ], + 'red' => [ + 'term' => ['color' => 'red'], + ], + ], + ], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => '')), ''); - $agg->addFilter(new Term(array('color' => '0')), '0'); - $agg->addFilter(new Term(array('color' => 'blue')), 'blue'); - $agg->addFilter(new Term(array('color' => 'red')), 'red'); + $agg->addFilter(new Term(['color' => '']), ''); + $agg->addFilter(new Term(['color' => '0']), '0'); + $agg->addFilter(new Term(['color' => 'blue']), 'blue'); + $agg->addFilter(new Term(['color' => 'red']), 'red'); $this->showDeprecated(); $avg = new Avg('avg_price'); @@ -152,7 +151,7 @@ public function testWrongName() { $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Query\Term(array('color' => '0')), 0); + $agg->addFilter(new Query\Term(['color' => '0']), 0); $this->showDeprecated(); } @@ -165,7 +164,7 @@ public function testWrongNameWithLegacyFilter() { $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => '0')), 0); + $agg->addFilter(new Term(['color' => '0']), 0); $this->showDeprecated(); } @@ -177,8 +176,8 @@ public function testWrongNameWithLegacyFilter() public function testMixNamedAndAnonymousFilters() { $agg = new Filters('by_color'); - $agg->addFilter(new Query\Term(array('color' => '0')), '0'); - $agg->addFilter(new Query\Term(array('color' => '0'))); + $agg->addFilter(new Query\Term(['color' => '0']), '0'); + $agg->addFilter(new Query\Term(['color' => '0'])); } /** @@ -190,8 +189,8 @@ public function testMixNamedAndAnonymousFiltersWithLegacyFilters() { $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => '0')), '0'); - $agg->addFilter(new Term(array('color' => '0'))); + $agg->addFilter(new Term(['color' => '0']), '0'); + $agg->addFilter(new Term(['color' => '0'])); $this->showDeprecated(); } @@ -204,8 +203,8 @@ public function testMixAnonymousAndNamedFilters() { $agg = new Filters('by_color'); - $agg->addFilter(new Query\Term(array('color' => '0'))); - $agg->addFilter(new Query\Term(array('color' => '0')), '0'); + $agg->addFilter(new Query\Term(['color' => '0'])); + $agg->addFilter(new Query\Term(['color' => '0']), '0'); } /** @@ -218,8 +217,8 @@ public function testMixAnonymousAndNamedFiltersWithLegacyFilters() $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => '0'))); - $agg->addFilter(new Term(array('color' => '0')), '0'); + $agg->addFilter(new Term(['color' => '0'])); + $agg->addFilter(new Term(['color' => '0']), '0'); $this->showDeprecated(); } @@ -228,26 +227,26 @@ public function testMixAnonymousAndNamedFiltersWithLegacyFilters() */ public function testToArrayUsingAnonymousFilters() { - $expected = array( - 'filters' => array( - 'filters' => array( - array( - 'term' => array('color' => 'blue'), - ), - array( - 'term' => array('color' => 'red'), - ), - ), - ), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filters' => [ + 'filters' => [ + [ + 'term' => ['color' => 'blue'], + ], + [ + 'term' => ['color' => 'red'], + ], + ], + ], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filters('by_color'); - $agg->addFilter(new Query\Term(array('color' => 'blue'))); - $agg->addFilter(new Query\Term(array('color' => 'red'))); + $agg->addFilter(new Query\Term(['color' => 'blue'])); + $agg->addFilter(new Query\Term(['color' => 'red'])); $avg = new Avg('avg_price'); $avg->setField('price'); @@ -261,27 +260,27 @@ public function testToArrayUsingAnonymousFilters() */ public function testToArrayUsingAnonymousFiltersWithLegacyFilters() { - $expected = array( - 'filters' => array( - 'filters' => array( - array( - 'term' => array('color' => 'blue'), - ), - array( - 'term' => array('color' => 'red'), - ), - ), - ), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + $expected = [ + 'filters' => [ + 'filters' => [ + [ + 'term' => ['color' => 'blue'], + ], + [ + 'term' => ['color' => 'red'], + ], + ], + ], + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => 'blue'))); - $agg->addFilter(new Term(array('color' => 'red'))); + $agg->addFilter(new Term(['color' => 'blue'])); + $agg->addFilter(new Term(['color' => 'red'])); $this->showDeprecated(); $avg = new Avg('avg_price'); @@ -297,8 +296,8 @@ public function testToArrayUsingAnonymousFiltersWithLegacyFilters() public function testFilterAggregation() { $agg = new Filters('by_color'); - $agg->addFilter(new Query\Term(array('color' => 'blue')), 'blue'); - $agg->addFilter(new Query\Term(array('color' => 'red')), 'red'); + $agg->addFilter(new Query\Term(['color' => 'blue']), 'blue'); + $agg->addFilter(new Query\Term(['color' => 'red']), 'red'); $avg = new Avg('avg_price'); $avg->setField('price'); @@ -326,8 +325,8 @@ public function testFilterAggregationWithLegacyFilters() { $agg = new Filters('by_color'); $this->hideDeprecated(); - $agg->addFilter(new Term(array('color' => 'blue')), 'blue'); - $agg->addFilter(new Term(array('color' => 'red')), 'red'); + $agg->addFilter(new Term(['color' => 'blue']), 'blue'); + $agg->addFilter(new Term(['color' => 'red']), 'red'); $this->showDeprecated(); $avg = new Avg('avg_price'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php index 3416c30..8accdd5 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'location' => array('type' => 'geo_point'), - ))); + $type->setMapping(new Mapping(null, [ + 'location' => ['type' => 'geo_point'], + ])); - $type->addDocuments(array( - new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))), - new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))), - new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))), - )); + $type->addDocuments([ + new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), + new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), + new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), + ]); $index->refresh(); @@ -34,7 +33,7 @@ protected function _getIndexForTest() */ public function testGeoDistanceAggregation() { - $agg = new GeoDistance('geo', 'location', array('lat' => 32.804654, 'lon' => -117.242594)); + $agg = new GeoDistance('geo', 'location', ['lat' => 32.804654, 'lon' => -117.242594]); $agg->addRange(null, 100); $agg->setUnit('mi'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php index 541622e..347d6f1 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'location' => array('type' => 'geo_point'), - ))); + $type->setMapping(new Mapping(null, [ + 'location' => ['type' => 'geo_point'], + ])); - $type->addDocuments(array( - new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))), - new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))), - new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))), - )); + $type->addDocuments([ + new Document(1, ['location' => ['lat' => 32.849437, 'lon' => -117.271732]]), + new Document(2, ['location' => ['lat' => 32.798320, 'lon' => -117.246648]]), + new Document(3, ['location' => ['lat' => 37.782439, 'lon' => -122.392560]]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php index 2560954..b8f5f05 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php @@ -1,5 +1,4 @@ new \stdClass(), - 'aggs' => array( - 'avg_price' => array('avg' => array('field' => 'price')), - ), - ); + 'aggs' => [ + 'avg_price' => ['avg' => ['field' => 'price']], + ], + ]; $agg = new GlobalAggregation('all_products'); $avg = new Avg('avg_price'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php index eb6f633..9bdbbd5 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5, 'color' => 'blue')), - new Document(2, array('price' => 8, 'color' => 'blue')), - new Document(3, array('price' => 1, 'color' => 'red')), - new Document(4, array('price' => 30, 'color' => 'green')), - new Document(5, array('price' => 40, 'color' => 'red')), - new Document(6, array('price' => 35, 'color' => 'green')), - new Document(7, array('price' => 42, 'color' => 'red')), - new Document(8, array('price' => 41, 'color' => 'blue')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5, 'color' => 'blue']), + new Document(2, ['price' => 8, 'color' => 'blue']), + new Document(3, ['price' => 1, 'color' => 'red']), + new Document(4, ['price' => 30, 'color' => 'green']), + new Document(5, ['price' => 40, 'color' => 'red']), + new Document(6, ['price' => 35, 'color' => 'green']), + new Document(7, ['price' => 42, 'color' => 'red']), + new Document(8, ['price' => 41, 'color' => 'blue']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php index d974618..8ba8ef3 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'address' => array('type' => 'ip'), - ))); + $type->setMapping(new Mapping(null, [ + 'address' => ['type' => 'ip'], + ])); - $type->addDocuments(array( - new Document(1, array('address' => '192.168.1.100')), - new Document(2, array('address' => '192.168.1.150')), - new Document(3, array('address' => '192.168.1.200')), - )); + $type->addDocuments([ + new Document(1, ['address' => '192.168.1.100']), + new Document(2, ['address' => '192.168.1.150']), + new Document(3, ['address' => '192.168.1.200']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php index 757407e..532eb92 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); @@ -30,22 +29,22 @@ protected function _getIndexForTest() */ public function testToArray() { - $expected = array( - 'max' => array( + $expected = [ + 'max' => [ 'field' => 'price', 'script' => '_value * conversion_rate', - 'params' => array( + 'params' => [ 'conversion_rate' => 1.2, - ), - ), - 'aggs' => array( - 'subagg' => array('max' => array('field' => 'foo')), - ), - ); + ], + ], + 'aggs' => [ + 'subagg' => ['max' => ['field' => 'foo']], + ], + ]; $agg = new Max('min_price_in_euros'); $agg->setField('price'); - $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2))); + $agg->setScript(new Script('_value * conversion_rate', ['conversion_rate' => 1.2])); $max = new Max('subagg'); $max->setField('foo'); $agg->addAggregation($max); @@ -71,7 +70,7 @@ public function testMaxAggregation() $this->assertEquals(8, $results['value']); // test using a script - $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2))); + $agg->setScript(new Script('_value * conversion_rate', ['conversion_rate' => 1.2])); $query = new Query(); $query->addAggregation($agg); $results = $index->search($query)->getAggregation('min_price'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php index 63638d0..0b19923 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php index c3aa45f..23c8300 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5, 'color' => 'blue')), - new Document(2, array('price' => 8, 'color' => 'blue')), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3, 'color' => 'green')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5, 'color' => 'blue']), + new Document(2, ['price' => 8, 'color' => 'blue']), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3, 'color' => 'green']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php index 33e269f..4da458f 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'resellers' => array( + $type->setMapping(new Mapping(null, [ + 'resellers' => [ 'type' => 'nested', - 'properties' => array( - 'name' => array('type' => 'string'), - 'price' => array('type' => 'double'), - ), - ), - ))); + 'properties' => [ + 'name' => ['type' => 'string'], + 'price' => ['type' => 'double'], + ], + ], + ])); - $type->addDocuments(array( - new Document(1, array( - 'resellers' => array( + $type->addDocuments([ + new Document(1, [ + 'resellers' => [ 'name' => 'spacely sprockets', 'price' => 5.55, - ), - )), - new Document(2, array( - 'resellers' => array( + ], + ]), + new Document(2, [ + 'resellers' => [ 'name' => 'cogswell cogs', 'price' => 4.98, - ), - )), - )); + ], + ]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php index 715931c..f57b383 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php @@ -1,5 +1,4 @@ setPercents($percents); $this->assertEquals($percents, $aggr->getParam('percents')); @@ -60,7 +59,7 @@ public function testSetPercents() */ public function testAddPercent() { - $percents = array(1, 2, 3); + $percents = [1, 2, 3]; $aggr = new Percentiles('price_percentile'); $aggr->setPercents($percents); $this->assertEquals($percents, $aggr->getParam('percents')); @@ -90,18 +89,18 @@ public function testActualWork() // prepare $index = $this->_createIndex(); $type = $index->getType('offer'); - $type->addDocuments(array( - new Document(1, array('price' => 100)), - new Document(2, array('price' => 200)), - new Document(3, array('price' => 300)), - new Document(4, array('price' => 400)), - new Document(5, array('price' => 500)), - new Document(6, array('price' => 600)), - new Document(7, array('price' => 700)), - new Document(8, array('price' => 800)), - new Document(9, array('price' => 900)), - new Document(10, array('price' => 1000)), - )); + $type->addDocuments([ + new Document(1, ['price' => 100]), + new Document(2, ['price' => 200]), + new Document(3, ['price' => 300]), + new Document(4, ['price' => 400]), + new Document(5, ['price' => 500]), + new Document(6, ['price' => 600]), + new Document(7, ['price' => 700]), + new Document(8, ['price' => 800]), + new Document(9, ['price' => 900]), + new Document(10, ['price' => 1000]), + ]); $index->refresh(); // execute diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php index 09b2ef2..9cb9ca1 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - new Document(5, array('price' => 1.5)), - new Document(6, array('price' => 2)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + new Document(5, ['price' => 1.5]), + new Document(6, ['price' => 2]), + ]); $index->refresh(); @@ -53,26 +52,26 @@ public function testRangeAggregationWithKey() $agg->addRange(50, 100, 'average'); $agg->addRange(100, null, 'expensive'); - $expected = array( - 'range' => array( + $expected = [ + 'range' => [ 'field' => 'price', - 'ranges' => array( - array( + 'ranges' => [ + [ 'to' => 50, 'key' => 'cheap', - ), - array( + ], + [ 'from' => 50, 'to' => 100, 'key' => 'average', - ), - array( + ], + [ 'from' => 100, 'key' => 'expensive', - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $agg->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php index 5cb8949..96a6f8b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php @@ -1,5 +1,4 @@ _createIndex(); $mapping = new Mapping(); - $mapping->setProperties(array( - 'comments' => array( + $mapping->setProperties([ + 'comments' => [ 'type' => 'nested', - 'properties' => array( - 'name' => array('type' => 'string'), - 'body' => array('type' => 'string'), - ), - ), - )); + 'properties' => [ + 'name' => ['type' => 'string'], + 'body' => ['type' => 'string'], + ], + ], + ]); $type = $index->getType('test'); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array( - 'comments' => array( - array( + $type->addDocuments([ + new Document(1, [ + 'comments' => [ + [ 'name' => 'bob', 'body' => 'this is bobs comment', - ), - array( + ], + [ 'name' => 'john', 'body' => 'this is johns comment', - ), - ), - 'tags' => array('foo', 'bar'), - )), - new Document(2, array( - 'comments' => array( - array( + ], + ], + 'tags' => ['foo', 'bar'], + ]), + new Document(2, [ + 'comments' => [ + [ 'name' => 'bob', 'body' => 'this is another comment from bob', - ), - array( + ], + [ 'name' => 'susan', 'body' => 'this is susans comment', - ), - ), - 'tags' => array('foo', 'baz'), - )), - )); + ], + ], + 'tags' => ['foo', 'baz'], + ]), + ]); $index->refresh(); @@ -109,27 +108,27 @@ public function testReverseNestedAggregation() // bob $this->assertEquals('bob', $nameResults['buckets'][0]['key']); - $tags = array( - array('key' => 'foo', 'doc_count' => 2), - array('key' => 'bar', 'doc_count' => 1), - array('key' => 'baz', 'doc_count' => 1), - ); + $tags = [ + ['key' => 'foo', 'doc_count' => 2], + ['key' => 'bar', 'doc_count' => 1], + ['key' => 'baz', 'doc_count' => 1], + ]; $this->assertEquals($tags, $nameResults['buckets'][0]['main']['tags']['buckets']); // john $this->assertEquals('john', $nameResults['buckets'][1]['key']); - $tags = array( - array('key' => 'bar', 'doc_count' => 1), - array('key' => 'foo', 'doc_count' => 1), - ); + $tags = [ + ['key' => 'bar', 'doc_count' => 1], + ['key' => 'foo', 'doc_count' => 1], + ]; $this->assertEquals($tags, $nameResults['buckets'][1]['main']['tags']['buckets']); // susan $this->assertEquals('susan', $nameResults['buckets'][2]['key']); - $tags = array( - array('key' => 'baz', 'doc_count' => 1), - array('key' => 'foo', 'doc_count' => 1), - ); + $tags = [ + ['key' => 'baz', 'doc_count' => 1], + ['key' => 'foo', 'doc_count' => 1], + ]; $this->assertEquals($tags, $nameResults['buckets'][2]['main']['tags']['buckets']); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php index 66e5a60..7ccb884 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document('1', array('price' => 5)), - new Document('2', array('price' => 8)), - new Document('3', array('price' => 1)), - new Document('4', array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document('1', ['price' => 5]), + new Document('2', ['price' => 8]), + new Document('3', ['price' => 1]), + new Document('4', ['price' => 3]), + ]); $index->refresh(); @@ -66,10 +65,10 @@ public function testSetScript() { $aggregation = 'sum'; $string = "doc['price'].value"; - $params = array( + $params = [ 'param1' => 'one', 'param2' => 1, - ); + ]; $lang = 'groovy'; $agg = new Sum($aggregation); @@ -78,13 +77,13 @@ public function testSetScript() $array = $agg->toArray(); - $expected = array( - $aggregation => array( + $expected = [ + $aggregation => [ 'script' => $string, 'params' => $params, 'lang' => $lang, - ), - ); + ], + ]; $this->assertEquals($expected, $array); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php index 466a165..ce6f9a3 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'start' => array('type' => 'long'), - 'end' => array('type' => 'long'), - ))); + $type->setMapping(new Mapping(null, [ + 'start' => ['type' => 'long'], + 'end' => ['type' => 'long'], + ])); - $type->addDocuments(array( - new Document(1, array('start' => 100, 'end' => 200)), - new Document(2, array('start' => 200, 'end' => 250)), - new Document(3, array('start' => 300, 'end' => 450)), - )); + $type->addDocuments([ + new Document(1, ['start' => 100, 'end' => 200]), + new Document(2, ['start' => 200, 'end' => 250]), + new Document(3, ['start' => 300, 'end' => 450]), + ]); $index->refresh(); @@ -47,6 +46,6 @@ public function testScriptedMetricAggregation() $query->addAggregation($agg); $results = $this->_getIndexForTest()->search($query)->getAggregation('scripted'); - $this->assertEquals(array(100, 50, 150), $results['value'][0]); + $this->assertEquals([100, 50, 150], $results['value'][0]); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php index a9a9c53..041da80 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php @@ -1,5 +1,4 @@ _createIndex(); - $colors = array('blue', 'blue', 'red', 'red', 'green', 'yellow', 'white', 'cyan', 'magenta'); - $temperatures = array(1500, 1500, 1500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 7500, 8500, 9500); - $docs = array(); + $colors = ['blue', 'blue', 'red', 'red', 'green', 'yellow', 'white', 'cyan', 'magenta']; + $temperatures = [1500, 1500, 1500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 7500, 8500, 9500]; + $docs = []; for ($i = 0;$i < 250;++$i) { - $docs[] = new Document($i, array('color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)])); + $docs[] = new Document($i, ['color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)]]); } $index->getType('test')->addDocuments($docs); $index->refresh(); @@ -52,9 +51,9 @@ public function testSetBackgroundFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Aggregation\SignificantTerms::setBackgroundFilter passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -68,7 +67,7 @@ public function testSignificantTermsAggregation() $agg->setSize(1); $termsQuery = new Terms(); - $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white')); + $termsQuery->setTerms('color', ['blue', 'red', 'green', 'yellow', 'white']); $query = new Query($termsQuery); $query->addAggregation($agg); @@ -89,11 +88,11 @@ public function testSignificantTermsAggregationWithBackgroundFilter() $agg->setField('temperature'); $agg->setSize(1); $termsFilter = new Terms(); - $termsFilter->setTerms('color', array('blue', 'red', 'green', 'yellow')); + $termsFilter->setTerms('color', ['blue', 'red', 'green', 'yellow']); $agg->setBackgroundFilter($termsFilter); $termsQuery = new Terms(); - $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white')); + $termsQuery->setTerms('color', ['blue', 'red', 'green', 'yellow', 'white']); $query = new Query($termsQuery); $query->addAggregation($agg); @@ -115,11 +114,11 @@ public function testSignificantTermsAggregationWithBackgroundFilterWithLegacyFil $agg->setField('temperature'); $agg->setSize(1); $termsFilter = new TermsFilter(); - $termsFilter->setTerms('color', array('blue', 'red', 'green', 'yellow')); + $termsFilter->setTerms('color', ['blue', 'red', 'green', 'yellow']); $agg->setBackgroundFilter($termsFilter); $termsQuery = new Terms(); - $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white')); + $termsQuery->setTerms('color', ['blue', 'red', 'green', 'yellow', 'white']); $query = new Query($termsQuery); $query->addAggregation($agg); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php index 119c5c2..f368a97 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php index 5b456da..407f395 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php index 628d7c2..d401410 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('color' => 'blue')), - new Document(2, array('color' => 'blue')), - new Document(3, array('color' => 'red')), - new Document(4, array('color' => 'green')), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['color' => 'blue']), + new Document(2, ['color' => 'blue']), + new Document(3, ['color' => 'red']), + new Document(4, ['color' => 'green']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php index f159138..9a01a90 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('questions')->addDocuments(array( - new Document(1, array( - 'tags' => array('linux'), + $index->getType('questions')->addDocuments([ + new Document(1, [ + 'tags' => ['linux'], 'last_activity_date' => '2015-01-05', 'title' => 'Question about linux #1', - )), - new Document(2, array( - 'tags' => array('linux'), + ]), + new Document(2, [ + 'tags' => ['linux'], 'last_activity_date' => '2014-12-23', 'title' => 'Question about linux #2', - )), - new Document(3, array( - 'tags' => array('windows'), + ]), + new Document(3, [ + 'tags' => ['windows'], 'last_activity_date' => '2015-01-05', 'title' => 'Question about windows #1', - )), - new Document(4, array( - 'tags' => array('windows'), + ]), + new Document(4, [ + 'tags' => ['windows'], 'last_activity_date' => '2014-12-23', 'title' => 'Question about windows #2', - )), - new Document(5, array( - 'tags' => array('osx', 'apple'), + ]), + new Document(5, [ + 'tags' => ['osx', 'apple'], 'last_activity_date' => '2014-12-23', 'title' => 'Question about osx', - )), - )); + ]), + ]); $index->refresh(); @@ -77,7 +76,7 @@ public function testSetFrom() */ public function testSetSort() { - $sort = array('last_activity_date' => array('order' => 'desc')); + $sort = ['last_activity_date' => ['order' => 'desc']]; $agg = new TopHits('agg_name'); $returnValue = $agg->setSort($sort); $this->assertEquals($sort, $agg->getParam('sort')); @@ -89,7 +88,7 @@ public function testSetSort() */ public function testSetSource() { - $fields = array('title', 'tags'); + $fields = ['title', 'tags']; $agg = new TopHits('agg_name'); $returnValue = $agg->setSource($fields); $this->assertEquals($fields, $agg->getParam('_source')); @@ -129,11 +128,11 @@ public function testSetExplain() */ public function testSetHighlight() { - $highlight = array( - 'fields' => array( + $highlight = [ + 'fields' => [ 'title', - ), - ); + ], + ]; $agg = new TopHits('agg_name'); $returnValue = $agg->setHighlight($highlight); $this->assertEquals($highlight, $agg->getParam('highlight')); @@ -145,7 +144,7 @@ public function testSetHighlight() */ public function testSetFieldDataFields() { - $fields = array('title', 'tags'); + $fields = ['title', 'tags']; $agg = new TopHits('agg_name'); $returnValue = $agg->setFieldDataFields($fields); $this->assertEquals($fields, $agg->getParam('fielddata_fields')); @@ -158,7 +157,7 @@ public function testSetFieldDataFields() public function testSetScriptFields() { $script = new Script('1 + 2'); - $scriptFields = new ScriptFields(array('three' => $script)); + $scriptFields = new ScriptFields(['three' => $script]); $agg = new TopHits('agg_name'); $returnValue = $agg->setScriptFields($scriptFields); @@ -174,7 +173,7 @@ public function testAddScriptField() $script = new Script('2+3'); $agg = new TopHits('agg_name'); $returnValue = $agg->addScriptField('five', $script); - $this->assertEquals(array('five' => $script->toArray()), $agg->getParam('script_fields')->toArray()); + $this->assertEquals(['five' => $script->toArray()], $agg->getParam('script_fields')->toArray()); $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue); } @@ -198,16 +197,16 @@ public function testAggregateUpdatedRecently() { $aggr = new TopHits('top_tag_hits'); $aggr->setSize(1); - $aggr->setSort(array('last_activity_date' => array('order' => 'desc'))); + $aggr->setSort(['last_activity_date' => ['order' => 'desc']]); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { $resultDocs[] = $doc['_id']; } } - $this->assertEquals(array(1, 3), $resultDocs); + $this->assertEquals([1, 3], $resultDocs); } /** @@ -217,16 +216,16 @@ public function testAggregateUpdatedFarAgo() { $aggr = new TopHits('top_tag_hits'); $aggr->setSize(1); - $aggr->setSort(array('last_activity_date' => array('order' => 'asc'))); + $aggr->setSort(['last_activity_date' => ['order' => 'asc']]); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { $resultDocs[] = $doc['_id']; } } - $this->assertEquals(array(2, 4), $resultDocs); + $this->assertEquals([2, 4], $resultDocs); } /** @@ -237,14 +236,14 @@ public function testAggregateTwoDocumentPerTag() $aggr = new TopHits('top_tag_hits'); $aggr->setSize(2); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { $resultDocs[] = $doc['_id']; } } - $this->assertEquals(array(1, 2, 3, 4), $resultDocs); + $this->assertEquals([1, 2, 3, 4], $resultDocs); } /** @@ -255,16 +254,16 @@ public function testAggregateTwoDocumentPerTagWithOffset() $aggr = new TopHits('top_tag_hits'); $aggr->setSize(2); $aggr->setFrom(1); - $aggr->setSort(array('last_activity_date' => array('order' => 'desc'))); + $aggr->setSort(['last_activity_date' => ['order' => 'desc']]); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { $resultDocs[] = $doc['_id']; } } - $this->assertEquals(array(2, 4), $resultDocs); + $this->assertEquals([2, 4], $resultDocs); } /** @@ -273,9 +272,9 @@ public function testAggregateTwoDocumentPerTagWithOffset() public function testAggregateWithLimitedSource() { $aggr = new TopHits('top_tag_hits'); - $aggr->setSource(array('title')); + $aggr->setSource(['title']); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { @@ -294,7 +293,7 @@ public function testAggregateWithVersion() $aggr = new TopHits('top_tag_hits'); $aggr->setVersion(true); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { @@ -311,7 +310,7 @@ public function testAggregateWithExplain() $aggr = new TopHits('top_tag_hits'); $aggr->setExplain(true); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { @@ -328,10 +327,10 @@ public function testAggregateWithScriptFields() $this->_checkScriptInlineSetting(); $aggr = new TopHits('top_tag_hits'); $aggr->setSize(1); - $aggr->setScriptFields(array('three' => new Script('1 + 2'))); + $aggr->setScriptFields(['three' => new Script('1 + 2')]); $aggr->addScriptField('five', new Script('3 + 2')); - $resultDocs = array(); + $resultDocs = []; $outerAggrResult = $this->getOuterAggregationResult($aggr); foreach ($outerAggrResult['buckets'] as $bucket) { foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) { @@ -346,10 +345,10 @@ public function testAggregateWithScriptFields() */ public function testAggregateWithHighlight() { - $queryString = new SimpleQueryString('linux', array('title')); + $queryString = new SimpleQueryString('linux', ['title']); $aggr = new TopHits('top_tag_hits'); - $aggr->setHighlight(array('fields' => array('title' => new \stdClass()))); + $aggr->setHighlight(['fields' => ['title' => new \stdClass()]]); $query = new Query($queryString); $query->addAggregation($aggr); @@ -369,7 +368,7 @@ public function testAggregateWithHighlight() public function testAggregateWithFieldData() { $aggr = new TopHits('top_tag_hits'); - $aggr->setFieldDataFields(array('title')); + $aggr->setFieldDataFields(['title']); $query = new Query(new MatchAll()); $query->addAggregation($aggr); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php index 11a4068..53d7745 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php @@ -1,5 +1,4 @@ _createIndex(); - $index->getType('test')->addDocuments(array( - new Document(1, array('price' => 5)), - new Document(2, array('price' => 8)), - new Document(3, array('price' => 1)), - new Document(4, array('price' => 3)), - new Document(5, array('price' => 3)), - )); + $index->getType('test')->addDocuments([ + new Document(1, ['price' => 5]), + new Document(2, ['price' => 8]), + new Document(3, ['price' => 1]), + new Document(4, ['price' => 3]), + new Document(5, ['price' => 3]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php index 37dbb3d..c496017 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php @@ -1,10 +1,10 @@ $this->_getHost(), 'port' => $this->_getPort(), - ); + ]; $config = array_merge($config, $params); - return new Client($config, $callback); + return new Client($config, $callback, $logger); } /** @@ -122,7 +123,7 @@ protected function _createIndex($name = null, $delete = true, $shards = 1) $client = $this->_getClient(); $index = $client->getIndex('elastica_'.$name); - $index->create(array('index' => array('number_of_shards' => $shards, 'number_of_replicas' => 0)), $delete); + $index->create(['index' => ['number_of_shards' => $shards, 'number_of_replicas' => 0]], $delete); return $index; } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php index 10a602c..75e9674 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php @@ -1,5 +1,4 @@ assertEquals($expected, $action->toString()); - $action->setSource(array('user' => 'name')); + $action->setSource(['user' => 'name']); $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n"; $expected .= '{"user":"name"}'."\n"; diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php index 2dcd51b..7d95ffb 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php @@ -1,5 +1,4 @@ _getFixture(); - $return = array(); - $return[] = array($responseData, $actions, true); + $return = []; + $return[] = [$responseData, $actions, true]; $responseData['items'][2]['index']['ok'] = false; - $return[] = array($responseData, $actions, false); + $return[] = [$responseData, $actions, false]; return $return; } @@ -140,7 +139,7 @@ public function isOkDataProvider() */ protected function _createResponseSet(array $responseData, array $actions) { - $client = $this->getMock('Elastica\\Client', array('request')); + $client = $this->getMock('Elastica\\Client', ['request']); $client->expects($this->once()) ->method('request') @@ -158,44 +157,44 @@ protected function _createResponseSet(array $responseData, array $actions) */ protected function _getFixture() { - $responseData = array( + $responseData = [ 'took' => 5, - 'items' => array( - array( - 'index' => array( + 'items' => [ + [ + 'index' => [ '_index' => 'index', '_type' => 'type', '_id' => '1', '_version' => 1, 'ok' => true, - ), - ), - array( - 'index' => array( + ], + ], + [ + 'index' => [ '_index' => 'index', '_type' => 'type', '_id' => '2', '_version' => 1, 'ok' => true, - ), - ), - array( - 'index' => array( + ], + ], + [ + 'index' => [ '_index' => 'index', '_type' => 'type', '_id' => '3', '_version' => 1, 'ok' => true, - ), - ), - ), - ); - $bulkResponses = array( + ], + ], + ], + ]; + $bulkResponses = [ new Action(), new Action(), new Action(), - ); + ]; - return array($responseData, $bulkResponses); + return [$responseData, $bulkResponses]; } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php index e4df64a..dcbd1aa 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php @@ -1,5 +1,4 @@ getType('bulk_test2'); $client = $index->getClient(); - $newDocument1 = $type->createDocument(1, array('name' => 'Mister Fantastic')); - $newDocument2 = new Document(2, array('name' => 'Invisible Woman')); - $newDocument3 = $type->createDocument(3, array('name' => 'The Human Torch')); - $newDocument4 = $type->createDocument(null, array('name' => 'The Thing')); + $newDocument1 = $type->createDocument(1, ['name' => 'Mister Fantastic']); + $newDocument2 = new Document(2, ['name' => 'Invisible Woman']); + $newDocument3 = $type->createDocument(3, ['name' => 'The Human Torch']); + $newDocument4 = $type->createDocument(null, ['name' => 'The Thing']); $newDocument3->setOpType(Document::OP_TYPE_CREATE); - $documents = array( + $documents = [ $newDocument1, $newDocument2, $newDocument3, $newDocument4, - ); + ]; $bulk = new Bulk($client); $bulk->setType($type2); @@ -62,16 +61,16 @@ public function testSend() $data = $bulk->toArray(); - $expected = array( - array('index' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 1)), - array('name' => 'Mister Fantastic'), - array('index' => array('_id' => 2)), - array('name' => 'Invisible Woman'), - array('create' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)), - array('name' => 'The Human Torch'), - array('index' => array('_index' => $indexName, '_type' => 'bulk_test')), - array('name' => 'The Thing'), - ); + $expected = [ + ['index' => ['_index' => $indexName, '_type' => 'bulk_test', '_id' => 1]], + ['name' => 'Mister Fantastic'], + ['index' => ['_id' => 2]], + ['name' => 'Invisible Woman'], + ['create' => ['_index' => $indexName, '_type' => 'bulk_test', '_id' => 3]], + ['name' => 'The Human Torch'], + ['index' => ['_index' => $indexName, '_type' => 'bulk_test']], + ['name' => 'The Thing'], + ]; $this->assertEquals($expected, $data); $expected = '{"index":{"_index":"'.$indexName.'","_type":"bulk_test","_id":1}} @@ -112,9 +111,9 @@ public function testSend() $data = $bulk->toArray(); - $expected = array( - array('delete' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)), - ); + $expected = [ + ['delete' => ['_index' => $indexName, '_type' => 'bulk_test', '_id' => 3]], + ]; $this->assertEquals($expected, $data); $bulk->send(); @@ -141,15 +140,15 @@ public function testUnicodeBulkSend() $type2 = $index->getType('bulk_test2'); $client = $index->getClient(); - $newDocument1 = $type->createDocument(1, array('name' => 'Сегодня, я вижу, особенно грустен твой взгляд,')); - $newDocument2 = new Document(2, array('name' => 'И руки особенно тонки, колени обняв.')); - $newDocument3 = $type->createDocument(3, array('name' => 'Послушай: далеко, далеко, на озере Чад / Изысканный бродит жираф.')); + $newDocument1 = $type->createDocument(1, ['name' => 'Сегодня, я вижу, особенно грустен твой взгляд,']); + $newDocument2 = new Document(2, ['name' => 'И руки особенно тонки, колени обняв.']); + $newDocument3 = $type->createDocument(3, ['name' => 'Послушай: далеко, далеко, на озере Чад / Изысканный бродит жираф.']); - $documents = array( + $documents = [ $newDocument1, $newDocument2, $newDocument3, - ); + ]; $bulk = new Bulk($client); $bulk->setType($type2); @@ -220,12 +219,12 @@ public function testAddActions() $action2->setIndex('index'); $action2->setType('type'); $action2->setId(1); - $action2->setSource(array('name' => 'Batman')); + $action2->setSource(['name' => 'Batman']); - $actions = array( + $actions = [ $action1, $action2, - ); + ]; $bulk->addActions($actions); @@ -242,15 +241,15 @@ public function testAddRawData() { $bulk = new Bulk($this->_getClient()); - $rawData = array( - array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), - array('user' => array('name' => 'hans')), - array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '2')), - array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '3')), - array('create' => array('_index' => 'test', '_type' => 'user', '_id' => '4')), - array('user' => array('name' => 'mans')), - array('delete' => array('_index' => 'test', '_type' => 'user', '_id' => '5')), - ); + $rawData = [ + ['index' => ['_index' => 'test', '_type' => 'user', '_id' => '1']], + ['user' => ['name' => 'hans']], + ['delete' => ['_index' => 'test', '_type' => 'user', '_id' => '2']], + ['delete' => ['_index' => 'test', '_type' => 'user', '_id' => '3']], + ['create' => ['_index' => 'test', '_type' => 'user', '_id' => '4']], + ['user' => ['name' => 'mans']], + ['delete' => ['_index' => 'test', '_type' => 'user', '_id' => '5']], + ]; $bulk->addRawData($rawData); @@ -303,42 +302,42 @@ public function testInvalidRawData($rawData, $failMessage) public function invalidRawDataProvider() { - return array( - array( - array( - array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), - array('user' => array('name' => 'hans')), - array('user' => array('name' => 'mans')), - ), + return [ + [ + [ + ['index' => ['_index' => 'test', '_type' => 'user', '_id' => '1']], + ['user' => ['name' => 'hans']], + ['user' => ['name' => 'mans']], + ], 'Two sources for one action', - ), - array( - array( - array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), - array('user' => array('name' => 'hans')), - array('upsert' => array('_index' => 'test', '_type' => 'user', '_id' => '2')), - ), + ], + [ + [ + ['index' => ['_index' => 'test', '_type' => 'user', '_id' => '1']], + ['user' => ['name' => 'hans']], + ['upsert' => ['_index' => 'test', '_type' => 'user', '_id' => '2']], + ], 'Invalid optype for action', - ), - array( - array( - array('user' => array('name' => 'mans')), - ), + ], + [ + [ + ['user' => ['name' => 'mans']], + ], 'Source without action', - ), - array( - array( - array(), - ), + ], + [ + [ + [], + ], 'Empty array', - ), - array( - array( + ], + [ + [ 'dummy', - ), + ], 'String as data', - ), - ); + ], + ]; } /** @@ -374,11 +373,11 @@ public function testErrorRequest() $type = $index->getType('bulk_test'); $client = $index->getClient(); - $documents = array( - $type->createDocument(1, array('name' => 'Mister Fantastic')), - $type->createDocument(2, array('name' => 'Invisible Woman')), - $type->createDocument(2, array('name' => 'The Human Torch')), - ); + $documents = [ + $type->createDocument(1, ['name' => 'Mister Fantastic']), + $type->createDocument(2, ['name' => 'Invisible Woman']), + $type->createDocument(2, ['name' => 'The Human Torch']), + ]; $documents[2]->setOpType(Document::OP_TYPE_CREATE); @@ -406,11 +405,11 @@ public function testRawDocumentDataRequest() $type = $index->getType('bulk_test'); $client = $index->getClient(); - $documents = array( + $documents = [ new Document(null, '{"name":"Mister Fantastic"}'), new Document(null, '{"name":"Invisible Woman"}'), new Document(null, '{"name":"The Human Torch"}'), - ); + ]; $bulk = new Bulk($client); $bulk->addDocuments($documents); @@ -434,7 +433,7 @@ public function testRawDocumentDataRequest() $response = $type->search(); $this->assertEquals(3, $response->count()); - foreach (array('Mister', 'Invisible', 'Torch') as $name) { + foreach (['Mister', 'Invisible', 'Torch'] as $name) { $result = $type->search($name); $this->assertEquals(1, count($result->getResults())); } @@ -450,11 +449,11 @@ public function testUpdate() $type = $index->getType('bulk_test'); $client = $index->getClient(); - $doc1 = $type->createDocument(1, array('name' => 'John')); - $doc2 = $type->createDocument(2, array('name' => 'Paul')); - $doc3 = $type->createDocument(3, array('name' => 'George')); - $doc4 = $type->createDocument(4, array('name' => 'Ringo')); - $documents = array($doc1, $doc2, $doc3, $doc4); + $doc1 = $type->createDocument(1, ['name' => 'John']); + $doc2 = $type->createDocument(2, ['name' => 'Paul']); + $doc3 = $type->createDocument(3, ['name' => 'George']); + $doc4 = $type->createDocument(4, ['name' => 'Ringo']); + $documents = [$doc1, $doc2, $doc3, $doc4]; //index some documents $bulk = new Bulk($client); @@ -468,7 +467,7 @@ public function testUpdate() $index->refresh(); //test updating via document - $doc2 = $type->createDocument(2, array('name' => 'The Walrus')); + $doc2 = $type->createDocument(2, ['name' => 'The Walrus']); $bulk = new Bulk($client); $bulk->setType($type); $updateAction = new \Elastica\Bulk\Action\UpdateDocument($doc2); @@ -485,7 +484,7 @@ public function testUpdate() $this->assertEquals('The Walrus', $docData['name']); //test updating via script - $script = new \Elastica\Script\Script('ctx._source.name += param1;', array('param1' => ' was Paul'), null, 2); + $script = new \Elastica\Script\Script('ctx._source.name += param1;', ['param1' => ' was Paul'], null, 2); $doc2 = new Document(); $script->setUpsert($doc2); $updateAction = Action\AbstractDocument::create($script, Action::OP_TYPE_UPDATE); @@ -503,8 +502,8 @@ public function testUpdate() $this->assertEquals('The Walrus was Paul', $doc2->name); //test upsert - $script = new \Elastica\Script\Script('ctx._scource.counter += count', array('count' => 1), null, 5); - $doc = new Document('', array('counter' => 1)); + $script = new \Elastica\Script\Script('ctx._scource.counter += count', ['count' => 1], null, 5); + $doc = new Document('', ['counter' => 1]); $script->setUpsert($doc); $updateAction = Action\AbstractDocument::create($script, Action::OP_TYPE_UPDATE); $bulk = new Bulk($client); @@ -520,7 +519,7 @@ public function testUpdate() $this->assertEquals(1, $doc->counter); //test doc_as_upsert - $doc = new \Elastica\Document(6, array('test' => 'test')); + $doc = new \Elastica\Document(6, ['test' => 'test']); $doc->setDocAsUpsert(true); $updateAction = Action\AbstractDocument::create($doc, Action::OP_TYPE_UPDATE); $bulk = new Bulk($client); @@ -536,11 +535,11 @@ public function testUpdate() $this->assertEquals('test', $doc->test); //test doc_as_upsert with set of documents (use of addDocuments) - $doc1 = new \Elastica\Document(7, array('test' => 'test1')); + $doc1 = new \Elastica\Document(7, ['test' => 'test1']); $doc1->setDocAsUpsert(true); - $doc2 = new \Elastica\Document(8, array('test' => 'test2')); + $doc2 = new \Elastica\Document(8, ['test' => 'test2']); $doc2->setDocAsUpsert(true); - $docs = array($doc1, $doc2); + $docs = [$doc1, $doc2]; $bulk = new Bulk($client); $bulk->setType($type); $bulk->addDocuments($docs, \Elastica\Bulk\Action::OP_TYPE_UPDATE); @@ -605,7 +604,7 @@ public function testRetry() $type = $index->getType('bulk_test'); $client = $index->getClient(); - $doc1 = $type->createDocument(1, array('name' => 'Mister Fantastic')); + $doc1 = $type->createDocument(1, ['name' => 'Mister Fantastic']); $doc1->setOpType(Action::OP_TYPE_UPDATE); $doc1->setRetryOnConflict(5); @@ -654,23 +653,23 @@ public function testMemoryUsage() { $type = $this->_createIndex()->getType('test'); - $data = array( + $data = [ 'text1' => 'Very long text for a string', 'text2' => 'But this is not very long', 'text3' => 'random or not random?', - ); + ]; $startMemory = memory_get_usage(); for ($n = 1; $n < 10; ++$n) { - $docs = array(); + $docs = []; for ($i = 1; $i <= 3000; ++$i) { $docs[] = new Document(uniqid(), $data); } $type->addDocuments($docs); - $docs = array(); + $docs = []; } unset($docs); @@ -680,4 +679,30 @@ public function testMemoryUsage() $this->markTestIncomplete('Failed asserting that 2.2414096568375803 is less than 1.3.'); $this->assertLessThan(1.3, $endMemory / $startMemory); } + + /** + * @group unit + */ + public function testHasIndex() + { + $client = $this->_getClient(); + $bulk = new Bulk($client); + + $this->assertFalse($bulk->hasIndex()); + $bulk->setIndex('unittest'); + $this->assertTrue($bulk->hasIndex()); + } + + /** + * @group unit + */ + public function testHasType() + { + $client = $this->_getClient(); + $bulk = new Bulk($client); + + $this->assertFalse($bulk->hasType()); + $bulk->setType('unittest'); + $this->assertTrue($bulk->hasType()); + } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php index 31f400b..ac27d28 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php @@ -1,5 +1,4 @@ _getClient(array('connections' => array(array('host' => $this->_getHost(), 'port' => 9200)))); + $client = $this->_getClient(['connections' => [['host' => $this->_getHost(), 'port' => 9200]]]); $index = $client->getIndex('elastica_test1'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index $doc1 = new Document(1, - array('username' => 'hans', 'test' => array('2', '3', '5')) + ['username' => 'hans', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); // Adds a list of documents with _bulk upload to the index - $docs = array(); + $docs = []; $docs[] = new Document(2, - array('username' => 'john', 'test' => array('1', '3', '6')) + ['username' => 'john', 'test' => ['1', '3', '6']] ); $docs[] = new Document(3, - array('username' => 'rolf', 'test' => array('2', '3', '7')) + ['username' => 'rolf', 'test' => ['2', '3', '7']] ); $type->addDocuments($docs); @@ -64,28 +63,28 @@ public function testConnectionsArray() public function testTwoServersSame() { // Creates a new index 'xodoa' and a type 'user' inside this index - $client = $this->_getClient(array('connections' => array( - array('host' => $this->_getHost(), 'port' => 9200), - array('host' => $this->_getHost(), 'port' => 9200), - ))); + $client = $this->_getClient(['connections' => [ + ['host' => $this->_getHost(), 'port' => 9200], + ['host' => $this->_getHost(), 'port' => 9200], + ]]); $index = $client->getIndex('elastica_test1'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index $doc1 = new Document(1, - array('username' => 'hans', 'test' => array('2', '3', '5')) + ['username' => 'hans', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); // Adds a list of documents with _bulk upload to the index - $docs = array(); + $docs = []; $docs[] = new Document(2, - array('username' => 'john', 'test' => array('1', '3', '6')) + ['username' => 'john', 'test' => ['1', '3', '6']] ); $docs[] = new Document(3, - array('username' => 'rolf', 'test' => array('2', '3', '7')) + ['username' => 'rolf', 'test' => ['2', '3', '7']] ); $type->addDocuments($docs); @@ -101,7 +100,7 @@ public function testTwoServersSame() public function testConnectionParamsArePreparedForConnectionsOption() { $url = 'https://'.$this->_getHost().':9200'; - $client = $this->_getClient(array('connections' => array(array('url' => $url)))); + $client = $this->_getClient(['connections' => [['url' => $url]]]); $connection = $client->getConnection(); $this->assertEquals($url, $connection->getConfig('url')); @@ -113,7 +112,7 @@ public function testConnectionParamsArePreparedForConnectionsOption() public function testConnectionParamsArePreparedForServersOption() { $url = 'https://'.$this->_getHost().':9200'; - $client = $this->_getClient(array('servers' => array(array('url' => $url)))); + $client = $this->_getClient(['servers' => [['url' => $url]]]); $connection = $client->getConnection(); $this->assertEquals($url, $connection->getConfig('url')); @@ -125,7 +124,7 @@ public function testConnectionParamsArePreparedForServersOption() public function testConnectionParamsArePreparedForDefaultOptions() { $url = 'https://'.$this->_getHost().':9200'; - $client = $this->_getClient(array('url' => $url)); + $client = $this->_getClient(['url' => $url]); $connection = $client->getConnection(); $this->assertEquals($url, $connection->getConfig('url')); @@ -138,12 +137,12 @@ public function testBulk() { $client = $this->_getClient(); - $params = array( - array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '1')), - array('user' => array('name' => 'hans')), - array('index' => array('_index' => 'test', '_type' => 'user', '_id' => '2')), - array('user' => array('name' => 'peter')), - ); + $params = [ + ['index' => ['_index' => 'test', '_type' => 'user', '_id' => '1']], + ['user' => ['name' => 'hans']], + ['index' => ['_index' => 'test', '_type' => 'user', '_id' => '2']], + ['user' => ['name' => 'peter']], + ]; $client->bulk($params); } @@ -166,7 +165,7 @@ public function testOptimizeAll() public function testAddDocumentsEmpty() { $client = $this->_getClient(); - $client->addDocuments(array()); + $client->addDocuments([]); } /** @@ -178,24 +177,24 @@ public function testBulkIndex() { $index = $this->_getClient()->getIndex('cryptocurrencies'); - $anonCoin = new Document(1, array('name' => 'anoncoin'), 'altcoin'); - $ixCoin = new Document(2, array('name' => 'ixcoin'), 'altcoin'); + $anonCoin = new Document(1, ['name' => 'anoncoin'], 'altcoin'); + $ixCoin = new Document(2, ['name' => 'ixcoin'], 'altcoin'); - $index->addDocuments(array($anonCoin, $ixCoin)); + $index->addDocuments([$anonCoin, $ixCoin]); $this->assertEquals('anoncoin', $index->getType('altcoin')->getDocument(1)->get('name')); $this->assertEquals('ixcoin', $index->getType('altcoin')->getDocument(2)->get('name')); - $index->updateDocuments(array( - new Document(1, array('name' => 'AnonCoin'), 'altcoin'), - new Document(2, array('name' => 'iXcoin'), 'altcoin'), - )); + $index->updateDocuments([ + new Document(1, ['name' => 'AnonCoin'], 'altcoin'), + new Document(2, ['name' => 'iXcoin'], 'altcoin'), + ]); $this->assertEquals('AnonCoin', $index->getType('altcoin')->getDocument(1)->get('name')); $this->assertEquals('iXcoin', $index->getType('altcoin')->getDocument(2)->get('name')); $ixCoin->setIndex(null); // Make sure the index gets set properly if missing - $index->deleteDocuments(array($anonCoin, $ixCoin)); + $index->deleteDocuments([$anonCoin, $ixCoin]); $this->setExpectedException('Elastica\Exception\NotFoundException'); $index->getType('altcoin')->getDocument(1); @@ -211,24 +210,24 @@ public function testBulkType() { $type = $this->_getClient()->getIndex('cryptocurrencies')->getType('altcoin'); - $liteCoin = new Document(1, array('name' => 'litecoin')); - $nameCoin = new Document(2, array('name' => 'namecoin')); + $liteCoin = new Document(1, ['name' => 'litecoin']); + $nameCoin = new Document(2, ['name' => 'namecoin']); - $type->addDocuments(array($liteCoin, $nameCoin)); + $type->addDocuments([$liteCoin, $nameCoin]); $this->assertEquals('litecoin', $type->getDocument(1)->get('name')); $this->assertEquals('namecoin', $type->getDocument(2)->get('name')); - $type->updateDocuments(array( - new Document(1, array('name' => 'LiteCoin')), - new Document(2, array('name' => 'NameCoin')), - )); + $type->updateDocuments([ + new Document(1, ['name' => 'LiteCoin']), + new Document(2, ['name' => 'NameCoin']), + ]); $this->assertEquals('LiteCoin', $type->getDocument(1)->get('name')); $this->assertEquals('NameCoin', $type->getDocument(2)->get('name')); $nameCoin->setType(null); // Make sure the type gets set properly if missing - $type->deleteDocuments(array($liteCoin, $nameCoin)); + $type->deleteDocuments([$liteCoin, $nameCoin]); $this->setExpectedException('Elastica\Exception\NotFoundException'); $type->getDocument(1); @@ -251,17 +250,17 @@ public function testUpdateDocuments() $doc1 = new Document( 1, - array('name' => 'hans', 'age' => $initialValue), + ['name' => 'hans', 'age' => $initialValue], $typeName, $indexName ); $doc2 = new Document( 2, - array('name' => 'anna', 'age' => $initialValue), + ['name' => 'anna', 'age' => $initialValue], $typeName, $indexName ); - $data = array($doc1, $doc2); + $data = [$doc1, $doc2]; $client->addDocuments($data); foreach ($data as $i => $doc) { @@ -296,13 +295,13 @@ public function testUpdateDocuments() */ public function testDeleteIdsIdxStringTypeString() { - $data = array('username' => 'hans'); + $data = ['username' => 'hans']; $userSearch = 'username:hans'; $index = $this->_createIndex(null, true, 2); // Create the index, deleting it first if it already exists - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index @@ -314,7 +313,7 @@ public function testDeleteIdsIdxStringTypeString() $index->refresh(); $resultData = $result->getData(); - $ids = array($resultData['_id']); + $ids = [$resultData['_id']]; // Check to make sure the document is in the index $resultSet = $type->search($userSearch); @@ -374,13 +373,13 @@ public function testDeleteIdsIdxStringTypeString() */ public function testDeleteIdsIdxStringTypeObject() { - $data = array('username' => 'hans'); + $data = ['username' => 'hans']; $userSearch = 'username:hans'; $index = $this->_createIndex(); // Create the index, deleting it first if it already exists - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index @@ -391,7 +390,7 @@ public function testDeleteIdsIdxStringTypeObject() $index->refresh(); $resultData = $result->getData(); - $ids = array($resultData['_id']); + $ids = [$resultData['_id']]; // Check to make sure the document is in the index $resultSet = $type->search($userSearch); @@ -438,13 +437,13 @@ public function testDeleteIdsIdxStringTypeObject() */ public function testDeleteIdsIdxObjectTypeString() { - $data = array('username' => 'hans'); + $data = ['username' => 'hans']; $userSearch = 'username:hans'; $index = $this->_createIndex(); // Create the index, deleting it first if it already exists - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index @@ -455,7 +454,7 @@ public function testDeleteIdsIdxObjectTypeString() $index->refresh(); $resultData = $result->getData(); - $ids = array($resultData['_id']); + $ids = [$resultData['_id']]; // Check to make sure the document is in the index $resultSet = $type->search($userSearch); @@ -502,13 +501,13 @@ public function testDeleteIdsIdxObjectTypeString() */ public function testDeleteIdsIdxObjectTypeObject() { - $data = array('username' => 'hans'); + $data = ['username' => 'hans']; $userSearch = 'username:hans'; $index = $this->_createIndex(); // Create the index, deleting it first if it already exists - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index @@ -519,7 +518,7 @@ public function testDeleteIdsIdxObjectTypeObject() $index->refresh(); $resultData = $result->getData(); - $ids = array($resultData['_id']); + $ids = [$resultData['_id']]; // Check to make sure the document is in the index $resultSet = $type->search($userSearch); @@ -552,10 +551,10 @@ public function testOneInvalidConnection() $client = $this->_getClient(); // First connection work, second should not work - $connection1 = new Connection(array('port' => '9100', 'timeout' => 2, 'host' => $this->_getHost())); - $connection2 = new Connection(array('port' => '9200', 'timeout' => 2, 'host' => $this->_getHost())); + $connection1 = new Connection(['port' => '9100', 'timeout' => 2, 'host' => $this->_getHost()]); + $connection2 = new Connection(['port' => '9200', 'timeout' => 2, 'host' => $this->_getHost()]); - $client->setConnections(array($connection1, $connection2)); + $client->setConnections([$connection1, $connection2]); $client->request('_stats', Request::GET); @@ -576,10 +575,10 @@ public function testTwoInvalidConnection() $client = $this->_getClient(); // First connection work, second should not work - $connection1 = new Connection(array('port' => '9101', 'timeout' => 2)); - $connection2 = new Connection(array('port' => '9102', 'timeout' => 2)); + $connection1 = new Connection(['port' => '9101', 'timeout' => 2]); + $connection2 = new Connection(['port' => '9102', 'timeout' => 2]); - $client->setConnections(array($connection1, $connection2)); + $client->setConnections([$connection1, $connection2]); try { $client->request('_stats', Request::GET); @@ -615,13 +614,13 @@ public function testCallback() ++$count; }; - $client = $this->_getClient(array(), $callback); + $client = $this->_getClient([], $callback); // First connection work, second should not work - $connection1 = new Connection(array('port' => '9101', 'timeout' => 2)); - $connection2 = new Connection(array('port' => '9102', 'timeout' => 2)); + $connection1 = new Connection(['port' => '9101', 'timeout' => 2]); + $connection2 = new Connection(['port' => '9102', 'timeout' => 2]); - $client->setConnections(array($connection1, $connection2)); + $client->setConnections([$connection1, $connection2]); $this->assertEquals(0, $count); @@ -644,7 +643,7 @@ public function testUrlConstructor() $url = 'http://'.$this->_getHost().':9200/'; // Url should overwrite invalid host - $client = $this->_getClient(array('url' => $url, 'port' => '9101', 'timeout' => 2)); + $client = $this->_getClient(['url' => $url, 'port' => '9101', 'timeout' => 2]); $response = $client->request('_stats'); $this->assertInstanceOf('Elastica\Response', $response); @@ -659,10 +658,10 @@ public function testUpdateDocumentByDocument() $type = $index->getType('test'); $client = $index->getClient(); - $newDocument = new Document(1, array('field1' => 'value1', 'field2' => 'value2')); + $newDocument = new Document(1, ['field1' => 'value1', 'field2' => 'value2']); $type->addDocument($newDocument); - $updateDocument = new Document(1, array('field2' => 'value2changed', 'field3' => 'value3added')); + $updateDocument = new Document(1, ['field2' => 'value2changed', 'field3' => 'value3added']); $client->updateDocument(1, $updateDocument, $index->getName(), $type->getName()); $document = $type->getDocument(1); @@ -687,7 +686,7 @@ public function testUpdateDocumentByScript() $type = $index->getType('test'); $client = $index->getClient(); - $newDocument = new Document(1, array('field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'should be changed')); + $newDocument = new Document(1, ['field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'should be changed']); $type->addDocument($newDocument); $script = new Script('ctx._source.field2 += 5; ctx._source.remove("field3"); ctx._source.field4 = "changed"'); @@ -718,10 +717,10 @@ public function testUpdateDocumentByScriptWithUpsert() $script = new Script('ctx._source.field2 += count; ctx._source.remove("field3"); ctx._source.field4 = "changed"'); $script->setParam('count', 5); - $script->setUpsert(array('field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'value4')); + $script->setUpsert(['field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'value4']); // should use document fields because document does not exist, script is avoided - $client->updateDocument(1, $script, $index->getName(), $type->getName(), array('fields' => '_source')); + $client->updateDocument(1, $script, $index->getName(), $type->getName(), ['fields' => '_source']); $document = $type->getDocument(1); @@ -737,7 +736,7 @@ public function testUpdateDocumentByScriptWithUpsert() $this->assertEquals('value4', $data['field4']); // should use script because document exists, document values are ignored - $client->updateDocument(1, $script, $index->getName(), $type->getName(), array('fields' => '_source')); + $client->updateDocument(1, $script, $index->getName(), $type->getName(), ['fields' => '_source']); $document = $type->getDocument(1); @@ -761,16 +760,16 @@ public function testUpdateDocumentByRawData() $type = $index->getType('test'); $client = $index->getClient(); - $newDocument = new Document(1, array('field1' => 'value1')); + $newDocument = new Document(1, ['field1' => 'value1']); $type->addDocument($newDocument); - $rawData = array( - 'doc' => array( + $rawData = [ + 'doc' => [ 'field2' => 'value2', - ), - ); + ], + ]; - $response = $client->updateDocument(1, $rawData, $index->getName(), $type->getName(), array('retry_on_conflict' => 1)); + $response = $client->updateDocument(1, $rawData, $index->getName(), $type->getName(), ['retry_on_conflict' => 1]); $this->assertTrue($response->isOk()); $document = $type->getDocument(1); @@ -792,10 +791,10 @@ public function testUpdateDocumentByDocumentWithUpsert() $type = $index->getType('test'); $client = $index->getClient(); - $newDocument = new Document(1, array('field1' => 'value1updated', 'field2' => 'value2updated')); - $upsert = new Document(1, array('field1' => 'value1', 'field2' => 'value2')); + $newDocument = new Document(1, ['field1' => 'value1updated', 'field2' => 'value2updated']); + $upsert = new Document(1, ['field1' => 'value1', 'field2' => 'value2']); $newDocument->setUpsert($upsert); - $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), array('fields' => '_source')); + $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), ['fields' => '_source']); $document = $type->getDocument(1); $this->assertInstanceOf('Elastica\Document', $document); @@ -806,7 +805,7 @@ public function testUpdateDocumentByDocumentWithUpsert() $this->assertEquals('value2', $data['field2']); // should use update document because document exists, upsert document values are ignored - $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), array('fields' => '_source')); + $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), ['fields' => '_source']); $document = $type->getDocument(1); $this->assertInstanceOf('Elastica\Document', $document); @@ -834,9 +833,9 @@ public function testDocAsUpsert() //Ignore the exception because we expect the document to not exist. } - $newDocument = new Document(1, array('field1' => 'value1', 'field2' => 'value2')); + $newDocument = new Document(1, ['field1' => 'value1', 'field2' => 'value2']); $newDocument->setDocAsUpsert(true); - $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), array('fields' => '_source')); + $client->updateDocument(1, $newDocument, $index->getName(), $type->getName(), ['fields' => '_source']); $document = $type->getDocument(1); $this->assertInstanceOf('Elastica\Document', $document); @@ -876,11 +875,11 @@ public function testDeleteDocuments() $type = $index->getType('test'); $client = $index->getClient(); - $docs = array( - new Document(1, array('field' => 'value1'), $type, $index), - new Document(2, array('field' => 'value2'), $type, $index), - new Document(3, array('field' => 'value3'), $type, $index), - ); + $docs = [ + new Document(1, ['field' => 'value1'], $type, $index), + new Document(2, ['field' => 'value2'], $type, $index), + new Document(3, ['field' => 'value3'], $type, $index), + ]; $response = $client->addDocuments($docs); @@ -894,10 +893,10 @@ public function testDeleteDocuments() $this->assertEquals(3, $type->count()); - $deleteDocs = array( + $deleteDocs = [ $docs[0], $docs[2], - ); + ]; $response = $client->deleteDocuments($deleteDocs); @@ -942,7 +941,7 @@ public function testUpdateDocumentPopulateFields() $type = $index->getType('test'); $client = $index->getClient(); - $newDocument = new Document(1, array('field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'value4')); + $newDocument = new Document(1, ['field1' => 'value1', 'field2' => 10, 'field3' => 'should be removed', 'field4' => 'value4']); $newDocument->setAutoPopulate(); $type->addDocument($newDocument); @@ -955,7 +954,7 @@ public function testUpdateDocumentPopulateFields() $script, $index->getName(), $type->getName(), - array('fields' => '_source') + ['fields' => '_source'] ); $data = $type->getDocument(1)->getData(); @@ -977,7 +976,7 @@ public function testUpdateDocumentPopulateFields() $script, $index->getName(), $type->getName(), - array('fields' => 'field2,field4') + ['fields' => 'field2,field4'] ); $document = $type->getDocument(1); @@ -997,9 +996,9 @@ public function testUpdateDocumentPopulateFields() */ public function testAddDocumentsWithoutIds() { - $docs = array(); + $docs = []; for ($i = 0; $i < 10; ++$i) { - $docs[] = new Document(null, array('pos' => $i)); + $docs[] = new Document(null, ['pos' => $i]); } foreach ($docs as $doc) { @@ -1009,7 +1008,7 @@ public function testAddDocumentsWithoutIds() $index = $this->_createIndex(); $client = $index->getClient(); - $client->setConfigValue('document', array('autoPopulate' => true)); + $client->setConfigValue('document', ['autoPopulate' => true]); $type = $index->getType('pos'); $type->addDocuments($docs); @@ -1026,15 +1025,15 @@ public function testAddDocumentsWithoutIds() */ public function testConfigValue() { - $config = array( - 'level1' => array( - 'level2' => array( + $config = [ + 'level1' => [ + 'level2' => [ 'level3' => 'value3', - ), + ], 'level21' => 'value21', - ), + ], 'level11' => 'value11', - ); + ]; $client = $this->_getClient($config); $this->assertNull($client->getConfigValue('level12')); @@ -1046,8 +1045,8 @@ public function testConfigValue() $this->assertNotEquals(false, $client->getConfigValue('level11', false)); $this->assertNotEquals(10, $client->getConfigValue('level11', 10)); - $this->assertEquals('value3', $client->getConfigValue(array('level1', 'level2', 'level3'))); - $this->assertInternalType('array', $client->getConfigValue(array('level1', 'level2'))); + $this->assertEquals('value3', $client->getConfigValue(['level1', 'level2', 'level3'])); + $this->assertInternalType('array', $client->getConfigValue(['level1', 'level2'])); } /** @@ -1058,18 +1057,18 @@ public function testArrayQuery() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('username' => 'ruflin'))); + $type->addDocument(new Document(1, ['username' => 'ruflin'])); $index->refresh(); - $query = array( - 'query' => array( - 'query_string' => array( + $query = [ + 'query' => [ + 'query_string' => [ 'query' => 'ruflin', - ), - ), - ); + ], + ], + ]; $path = $index->getName().'/'.$type->getName().'/_search'; @@ -1087,9 +1086,9 @@ public function testJSONQuery() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('username' => 'ruflin'))); + $type->addDocument(new Document(1, ['username' => 'ruflin'])); $index->refresh(); $query = '{"query":{"query_string":{"query":"ruflin"}}}'; @@ -1111,7 +1110,7 @@ public function testAddHeader() // add one header $client->addHeader('foo', 'bar'); - $this->assertEquals(array('foo' => 'bar'), $client->getConfigValue('headers')); + $this->assertEquals(['foo' => 'bar'], $client->getConfigValue('headers')); // check class $this->assertInstanceOf('Elastica\Client', $client->addHeader('foo', 'bar')); @@ -1138,10 +1137,10 @@ public function testRemoveHeader() $client = $this->_getClient(); // set headers - $headers = array( + $headers = [ 'first' => 'first value', 'second' => 'second value', - ); + ]; foreach ($headers as $key => $value) { $client->addHeader($key, $value); } @@ -1168,8 +1167,74 @@ public function testRemoveHeader() */ public function testPassBigIntSettingsToConnectionConfig() { - $client = new Client(array('bigintConversion' => true)); + $client = new Client(['bigintConversion' => true]); $this->assertTrue($client->getConnection()->getConfig('bigintConversion')); } + + /** + * @group unit + */ + public function testClientConnectWithConfigSetByMethod() + { + $client = new Client(); + $client->setConfigValue('host', $this->_getHost()); + $client->setConfigValue('port', $this->_getPort()); + + $client->connect(); + $this->assertTrue($client->hasConnection()); + + $connection = $client->getConnection(); + $this->assertInstanceOf('\Elastica\Connection', $connection); + $this->assertEquals($this->_getHost(), $connection->getHost()); + $this->assertEquals($this->_getPort(), $connection->getPort()); + } + + /** + * @group functional + */ + public function testLogger() + { + $logger = $this->getMock('Psr\\Log\\LoggerInterface'); + $client = $this->_getClient([], null, $logger); + + $logger->expects($this->once()) + ->method('debug') + ->with( + 'Elastica Request', + $this->logicalAnd( + $this->arrayHasKey('request'), + $this->arrayHasKey('response'), + $this->arrayHasKey('responseStatus') + ) + ); + + $client->request('_stats', Request::GET); + } + + /** + * @expectedException \Elastica\Exception\Connection\HttpException + * @group functional + */ + public function testLoggerOnFailure() + { + $logger = $this->getMock('Psr\\Log\\LoggerInterface'); + $client = $this->_getClient(['connections' => [ + ['host' => $this->_getHost(), 'port' => 9201], + ]], null, $logger); + + $logger->expects($this->once()) + ->method('error') + ->with( + 'Elastica Request Failure', + $this->logicalAnd( + $this->arrayHasKey('exception'), + $this->arrayHasKey('request'), + $this->arrayHasKey('retry'), + $this->logicalNot($this->arrayHasKey('response')) + ) + ); + + $client->request('_stats', Request::GET); + } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php index b243c60..6f6d107 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php @@ -1,5 +1,4 @@ 'yellow', 'number_of_shards' => 1, 'number_of_replicas' => 2, @@ -25,33 +24,33 @@ public function setUp() 'relocating_shards' => 5, 'initializing_shards' => 6, 'unassigned_shards' => 7, - 'shards' => array( - '0' => array( + 'shards' => [ + '0' => [ 'status' => 'yellow', 'primary_active' => false, 'active_shards' => 0, 'relocating_shards' => 1, 'initializing_shards' => 0, 'unassigned_shards' => 1, - ), - '1' => array( + ], + '1' => [ 'status' => 'yellow', 'primary_active' => true, 'active_shards' => 1, 'relocating_shards' => 0, 'initializing_shards' => 0, 'unassigned_shards' => 1, - ), - '2' => array( + ], + '2' => [ 'status' => 'green', 'primary_active' => true, 'active_shards' => 1, 'relocating_shards' => 0, 'initializing_shards' => 0, 'unassigned_shards' => 0, - ), - ), - ); + ], + ], + ]; $this->_index = new HealthIndex('test', $data); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php index 3b52d04..9c993e8 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php @@ -1,5 +1,4 @@ 'red', 'primary_active' => true, 'active_shards' => 1, 'relocating_shards' => 0, 'initializing_shards' => 0, 'unassigned_shards' => 1, - ); + ]; $this->_shard = new HealthShard(2, $shardData); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php index 84ab44c..e57b94a 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php @@ -1,5 +1,4 @@ 'test_cluster', 'status' => 'green', 'timed_out' => false, @@ -26,18 +25,18 @@ protected function setUp() 'relocating_shards' => 2, 'initializing_shards' => 7, 'unassigned_shards' => 5, - 'indices' => array( - 'index_one' => array( - ), - 'index_two' => array( - ), - ), - ); + 'indices' => [ + 'index_one' => [ + ], + 'index_two' => [ + ], + ], + ]; $health = $this ->getMockBuilder('Elastica\Cluster\Health') - ->setConstructorArgs(array($this->_getClient())) - ->setMethods(array('_retrieveHealthData')) + ->setConstructorArgs([$this->_getClient()]) + ->setMethods(['_retrieveHealthData']) ->getMock(); $health diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php index 131af4f..04d7800 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php @@ -1,5 +1,4 @@ _createIndex(); $index2 = $this->_createIndex(); - $doc1 = new Document(null, array('hello' => 'world')); - $doc2 = new Document(null, array('hello' => 'world')); - $doc3 = new Document(null, array('hello' => 'world')); - $doc4 = new Document(null, array('hello' => 'world')); - $doc5 = new Document(null, array('hello' => 'world')); - $doc6 = new Document(null, array('hello' => 'world')); + $doc1 = new Document(null, ['hello' => 'world']); + $doc2 = new Document(null, ['hello' => 'world']); + $doc3 = new Document(null, ['hello' => 'world']); + $doc4 = new Document(null, ['hello' => 'world']); + $doc5 = new Document(null, ['hello' => 'world']); + $doc6 = new Document(null, ['hello' => 'world']); // Check that adding documents work $index1->getType('test')->addDocument($doc1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php index 72e5f04..4351a5a 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php @@ -1,5 +1,4 @@ request('/_nodes')->getData(); $rawNodes = $data['nodes']; - $rawNodeNames = array(); + $rawNodeNames = []; foreach ($rawNodes as $rawNode) { $rawNodeNames[] = $rawNode['name']; diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php index a5c9d16..7102b7c 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php @@ -1,5 +1,4 @@ createPool(); - $pool->setConnections(array()); + $pool->setConnections([]); $connections = $this->getConnections(5); @@ -74,7 +73,7 @@ public function testFailHasConnections() { $pool = $this->createPool(); - $pool->setConnections(array()); + $pool->setConnections([]); $this->assertFalse($pool->hasConnection()); } @@ -91,8 +90,8 @@ public function testGetConnection() protected function getConnections($quantity = 1) { - $params = array(); - $connections = array(); + $params = []; + $connections = []; for ($i = 0; $i < $quantity; ++$i) { $connections[] = new Connection($params); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php index 2f38bb2..be0f6fb 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php @@ -1,5 +1,4 @@ getConnection(array()); + $strategy->getConnection([]); $this->assertEquals(1, $count); } @@ -47,11 +46,11 @@ public function testIsValid() $this->assertTrue($isValid); // static method as array - $isValid = CallbackStrategy::isValid(array('Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper', 'getFirstConnectionStatic')); + $isValid = CallbackStrategy::isValid(['Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper', 'getFirstConnectionStatic']); $this->assertTrue($isValid); // object method - $isValid = CallbackStrategy::isValid(array(new CallbackStrategyTestHelper(), 'getFirstConnectionStatic')); + $isValid = CallbackStrategy::isValid([new CallbackStrategyTestHelper(), 'getFirstConnectionStatic']); $this->assertTrue($isValid); // function name @@ -78,11 +77,11 @@ public function testConnection() { $count = 0; - $config = array('connectionStrategy' => function ($connections) use (&$count) { + $config = ['connectionStrategy' => function ($connections) use (&$count) { ++$count; return current($connections); - }); + }]; $client = $this->_getClient($config); $response = $client->request('/_aliases'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php index 2f79cc7..b15efe9 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php @@ -1,5 +1,4 @@ 'RoundRobin'); + $config = ['connectionStrategy' => 'RoundRobin']; $client = $this->_getClient($config); $response = $client->request('/_aliases'); /* @var $response Response */ @@ -40,7 +39,7 @@ public function testConnection() */ public function testOldStrategySetted() { - $config = array('roundRobin' => true); + $config = ['roundRobin' => true]; $client = $this->_getClient($config); $this->_checkStrategy($client); @@ -52,7 +51,7 @@ public function testOldStrategySetted() */ public function testFailConnection() { - $config = array('connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0', 'timeout' => $this->_timeout); + $config = ['connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0', 'timeout' => $this->_timeout]; $client = $this->_getClient($config); $this->_checkStrategy($client); @@ -65,17 +64,17 @@ public function testFailConnection() */ public function testWithOneFailConnection() { - $connections = array( - new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), - new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)), - ); + $connections = [ + new Connection(['host' => '255.255.255.0', 'timeout' => $this->_timeout]), + new Connection(['host' => $this->_getHost(), 'timeout' => $this->_timeout]), + ]; $count = 0; $callback = function ($connection, $exception, $client) use (&$count) { ++$count; }; - $client = $this->_getClient(array('connectionStrategy' => 'RoundRobin'), $callback); + $client = $this->_getClient(['connectionStrategy' => 'RoundRobin'], $callback); $client->setConnections($connections); $response = $client->request('/_aliases'); @@ -93,14 +92,14 @@ public function testWithOneFailConnection() */ public function testWithNoValidConnection() { - $connections = array( - new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), - new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)), - new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)), - ); + $connections = [ + new Connection(['host' => '255.255.255.0', 'timeout' => $this->_timeout]), + new Connection(['host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout]), + new Connection(['host' => '10.123.213.123', 'timeout' => $this->_timeout]), + ]; $count = 0; - $client = $this->_getClient(array('roundRobin' => true), function () use (&$count) { + $client = $this->_getClient(['roundRobin' => true], function () use (&$count) { ++$count; }); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php index 5ab052c..8ddf57d 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php @@ -1,5 +1,4 @@ '255.255.255.0', 'timeout' => $this->_timeout); + $config = ['host' => '255.255.255.0', 'timeout' => $this->_timeout]; $client = $this->_getClient($config); $this->_checkStrategy($client); @@ -51,17 +50,17 @@ public function testFailConnection() */ public function testWithOneFailConnection() { - $connections = array( - new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), - new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)), - ); + $connections = [ + new Connection(['host' => '255.255.255.0', 'timeout' => $this->_timeout]), + new Connection(['host' => $this->_getHost(), 'timeout' => $this->_timeout]), + ]; $count = 0; $callback = function ($connection, $exception, $client) use (&$count) { ++$count; }; - $client = $this->_getClient(array(), $callback); + $client = $this->_getClient([], $callback); $client->setConnections($connections); $response = $client->request('/_aliases'); @@ -79,14 +78,14 @@ public function testWithOneFailConnection() */ public function testWithNoValidConnection() { - $connections = array( - new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), - new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)), - new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)), - ); + $connections = [ + new Connection(['host' => '255.255.255.0', 'timeout' => $this->_timeout]), + new Connection(['host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout]), + new Connection(['host' => '10.123.213.123', 'timeout' => $this->_timeout]), + ]; $count = 0; - $client = $this->_getClient(array(), function () use (&$count) { + $client = $this->_getClient([], function () use (&$count) { ++$count; }); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php index dc857e5..978f8fd 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php @@ -1,5 +1,4 @@ assertInstanceOf('Elastica\Transport\AbstractTransport', $connection->getTransportObject()); $this->assertEquals(Connection::TIMEOUT, $connection->getTimeout()); $this->assertEquals(Connection::CONNECT_TIMEOUT, $connection->getConnectTimeout()); - $this->assertEquals(array(), $connection->getConfig()); + $this->assertEquals([], $connection->getConfig()); $this->assertTrue($connection->isEnabled()); } @@ -43,7 +42,7 @@ public function testEnabledDisable() */ public function testInvalidConnection() { - $connection = new Connection(array('port' => 9999)); + $connection = new Connection(['port' => 9999]); $request = new Request('_stats', Request::GET); $request->setConnection($connection); @@ -60,11 +59,11 @@ public function testCreate() $connection = Connection::create(); $this->assertInstanceOf('Elastica\Connection', $connection); - $connection = Connection::create(array()); + $connection = Connection::create([]); $this->assertInstanceOf('Elastica\Connection', $connection); $port = 9999; - $connection = Connection::create(array('port' => $port)); + $connection = Connection::create(['port' => $port]); $this->assertInstanceOf('Elastica\Connection', $connection); $this->assertEquals($port, $connection->getPort()); } @@ -85,7 +84,7 @@ public function testCreateInvalid() public function testGetConfig() { $url = 'test'; - $connection = new Connection(array('config' => array('url' => $url))); + $connection = new Connection(['config' => ['url' => $url]]); $this->assertTrue($connection->hasConfig('url')); $this->assertEquals($url, $connection->getConfig('url')); } @@ -95,7 +94,7 @@ public function testGetConfig() */ public function testGetConfigWithArrayUsedForTransport() { - $connection = new Connection(array('transport' => array('type' => 'Http'))); + $connection = new Connection(['transport' => ['type' => 'Http']]); $this->assertInstanceOf('Elastica\Transport\Http', $connection->getTransportObject()); } @@ -106,7 +105,7 @@ public function testGetConfigWithArrayUsedForTransport() */ public function testGetInvalidConfigWithArrayUsedForTransport() { - $connection = new Connection(array('transport' => array('type' => 'invalidtransport'))); + $connection = new Connection(['transport' => ['type' => 'invalidtransport']]); $connection->getTransportObject(); } @@ -147,7 +146,7 @@ public function testCompressionDefaultWithClient() */ public function testCompressionEnabledWithClient() { - $client = new \Elastica\Client(array('connections' => array(array('compression' => true)))); + $client = new \Elastica\Client(['connections' => [['compression' => true]]]); $connection = $client->getConnection(); $this->assertTrue($connection->hasCompression()); @@ -159,7 +158,7 @@ public function testCompressionEnabledWithClient() public function testUsernameFromClient() { $username = 'foo'; - $client = new \Elastica\Client(array('username' => $username)); + $client = new \Elastica\Client(['username' => $username]); $this->assertEquals($username, $client->getConnection()->getUsername('username')); } @@ -170,7 +169,7 @@ public function testUsernameFromClient() public function testPasswordFromClient() { $password = 'bar'; - $client = new \Elastica\Client(array('password' => $password)); + $client = new \Elastica\Client(['password' => $password]); $this->assertEquals($password, $client->getConnection()->getPassword('password')); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/DeprecatedClassBase.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/DeprecatedClassBase.php index 2d5a18f..787c2c6 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/DeprecatedClassBase.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/DeprecatedClassBase.php @@ -1,5 +1,4 @@ setData(array('data')); + $returnValue = $doc->setData(['data']); $this->assertInstanceOf('Elastica\Document', $returnValue); } @@ -50,13 +49,13 @@ public function testSetData() public function testToArray() { $id = 17; - $data = array('hello' => 'world'); + $data = ['hello' => 'world']; $type = 'testtype'; $index = 'textindex'; $doc = new Document($id, $data, $type, $index); - $result = array('_index' => $index, '_type' => $type, '_id' => $id, '_source' => $data); + $result = ['_index' => $index, '_type' => $type, '_id' => $id, '_source' => $data]; $this->assertEquals($result, $doc->toArray()); } @@ -128,7 +127,7 @@ public function testGetOptions() $document->setParent('2'); $document->setId(1); - $options = $document->getOptions(array('index', 'type', 'id', 'parent')); + $options = $document->getOptions(['index', 'type', 'id', 'parent']); $this->assertInternalType('array', $options); $this->assertEquals(3, count($options)); @@ -144,7 +143,7 @@ public function testGetOptions() $this->assertArrayNotHasKey('_id', $options); $this->assertArrayNotHasKey('_parent', $options); - $options = $document->getOptions(array('parent', 'op_type', 'percolate'), true); + $options = $document->getOptions(['parent', 'op_type', 'percolate'], true); $this->assertInternalType('array', $options); $this->assertEquals(2, count($options)); @@ -162,7 +161,7 @@ public function testGetOptions() */ public function testGetSetHasRemove() { - $document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null)); + $document = new Document(1, ['field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null]); $this->assertEquals('value1', $document->get('field1')); $this->assertEquals('value2', $document->get('field2')); @@ -216,7 +215,7 @@ public function testGetSetHasRemove() */ public function testDataPropertiesOverloading() { - $document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null)); + $document = new Document(1, ['field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null]); $this->assertEquals('value1', $document->field1); $this->assertEquals('value2', $document->field2); @@ -326,7 +325,7 @@ public function testUpsert() $document = new Document(); $upsert = new Document(); - $upsert->setData(array('someproperty' => 'somevalue')); + $upsert->setData(['someproperty' => 'somevalue']); $this->assertFalse($document->hasUpsert()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ErrorsCollector.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ErrorsCollector.php index 905074f..700730e 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ErrorsCollector.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ErrorsCollector.php @@ -1,5 +1,4 @@ getType('users'); $id = 2; - $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin'); + $data = ['firstname' => 'Nicolas', 'lastname' => 'Ruflin']; $doc = new Document($id, $data); $type->addDocument($doc); @@ -34,23 +33,23 @@ public function testExample() // Creates a new index 'xodoa' and a type 'user' inside this index $client = $this->_getClient(); $index = $client->getIndex('elastica_test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('user'); // Adds 1 document to the index $doc1 = new Document(1, - array('username' => 'hans', 'test' => array('2', '3', '5')) + ['username' => 'hans', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); // Adds a list of documents with _bulk upload to the index - $docs = array(); + $docs = []; $docs[] = new Document(2, - array('username' => 'john', 'test' => array('1', '3', '6')) + ['username' => 'john', 'test' => ['1', '3', '6']] ); $docs[] = new Document(3, - array('username' => 'rolf', 'test' => array('2', '3', '7')) + ['username' => 'rolf', 'test' => ['2', '3', '7']] ); $type->addDocuments($docs); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php index ec6f828..ea84218 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php @@ -1,5 +1,4 @@ _checkScriptInlineSetting(); $client = $this->_getClient(); $index = $client->getIndex('elastica_partial_failure'); - $index->create(array( - 'index' => array( + $index->create([ + 'index' => [ 'number_of_shards' => 5, 'number_of_replicas' => 0, - ), - ), true); + ], + ], true); $type = $index->getType('folks'); - $type->addDocument(new Document('', array('name' => 'ruflin'))); - $type->addDocument(new Document('', array('name' => 'bobrik'))); - $type->addDocument(new Document('', array('name' => 'kimchy'))); + $type->addDocument(new Document('', ['name' => 'ruflin'])); + $type->addDocument(new Document('', ['name' => 'bobrik'])); + $type->addDocument(new Document('', ['name' => 'kimchy'])); $index->refresh(); - $query = Query::create(array( - 'query' => array( - 'filtered' => array( - 'filter' => array( - 'script' => array( + $query = Query::create([ + 'query' => [ + 'filtered' => [ + 'filter' => [ + 'script' => [ 'script' => 'doc["undefined"] > 8', // compiles, but doesn't work - ), - ), - ), - ), - )); + ], + ], + ], + ], + ]); try { $index->search($query); $this->fail('PartialShardFailureException should have been thrown'); } catch (PartialShardFailureException $e) { - $resultSet = new ResultSet($e->getResponse(), $query); + $builder = new ResultSet\DefaultBuilder(); + $resultSet = $builder->buildResultSet($e->getResponse(), $query); $this->assertEquals(0, count($resultSet->getResults())); $message = JSON::parse($e->getMessage()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php index e38afa2..375731b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(array( - 'num' => array( + $type->setMapping([ + 'num' => [ 'type' => 'long', - ), - )); + ], + ]); try { - $type->addDocument(new Document('', array( + $type->addDocument(new Document('', [ 'num' => 'not number at all', - ))); + ])); $this->fail('Indexing with wrong type should fail'); } catch (ResponseException $ex) { $error = $ex->getResponse()->getFullError(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php index 2f08a38..9dd1895 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php @@ -1,5 +1,4 @@ assertEquals(array('and' => array()), $and->toArray()); + $this->assertEquals(['and' => []], $and->toArray()); $idsFilter = new Ids(); $idsFilter->setIds(12); @@ -32,12 +31,12 @@ public function testToArray() $and->addFilter($idsFilter); $and->addFilter($idsFilter); - $expectedArray = array( - 'and' => array( + $expectedArray = [ + 'and' => [ $idsFilter->toArray(), $idsFilter->toArray(), - ), - ); + ], + ]; $this->assertEquals($expectedArray, $and->toArray()); } @@ -49,14 +48,14 @@ public function testSetCache() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'hello world')), - new Document(2, array('name' => 'nicolas ruflin')), - new Document(3, array('name' => 'ruflin')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'hello world']), + new Document(2, ['name' => 'nicolas ruflin']), + new Document(3, ['name' => 'ruflin']), + ]); $and = new BoolAnd(); @@ -82,10 +81,10 @@ public function testSetCache() */ public function testConstruct() { - $ids1 = new Ids('foo', array(1, 2)); - $ids2 = new Ids('bar', array(3, 4)); + $ids1 = new Ids('foo', [1, 2]); + $ids2 = new Ids('bar', [3, 4]); - $and1 = new BoolAnd(array($ids1, $ids2)); + $and1 = new BoolAnd([$ids1, $ids2]); $and2 = new BoolAnd(); $and2->addFilter($ids1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php index 6674fd1..4621258 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php @@ -1,5 +1,4 @@ hideDeprecated(); - $out = array(); + $out = []; // case #0 $mainBool = new BoolFilter(); @@ -42,51 +41,51 @@ public function getTestToArrayData() $childBool = new BoolFilter(); - $childBool->addShould(array($idsFilter1, $idsFilter2)); - $mainBool->addShould(array($childBool, $idsFilter3)); - - $expectedArray = array( - 'bool' => array( - 'should' => array( - array( - array( - 'bool' => array( - 'should' => array( - array( + $childBool->addShould([$idsFilter1, $idsFilter2]); + $mainBool->addShould([$childBool, $idsFilter3]); + + $expectedArray = [ + 'bool' => [ + 'should' => [ + [ + [ + 'bool' => [ + 'should' => [ + [ $idsFilter1->toArray(), $idsFilter2->toArray(), - ), - ), - ), - ), + ], + ], + ], + ], $idsFilter3->toArray(), - ), - ), - ), - ); - $out[] = array($mainBool, $expectedArray); + ], + ], + ], + ]; + $out[] = [$mainBool, $expectedArray]; // case #1 _cache parameter should be supported $bool = new BoolFilter(); - $terms = new Terms('field1', array('value1', 'value2')); - $termsNot = new Terms('field2', array('value1', 'value2')); + $terms = new Terms('field1', ['value1', 'value2']); + $termsNot = new Terms('field2', ['value1', 'value2']); $bool->addMust($terms); $bool->addMustNot($termsNot); $bool->setCached(true); $bool->setCacheKey('my-cache-key'); - $expected = array( - 'bool' => array( - 'must' => array( + $expected = [ + 'bool' => [ + 'must' => [ $terms->toArray(), - ), - 'must_not' => array( + ], + 'must_not' => [ $termsNot->toArray(), - ), + ], '_cache' => true, '_cache_key' => 'my-cache-key', - ), - ); - $out[] = array($bool, $expected); + ], + ]; + $out[] = [$bool, $expected]; $this->showDeprecated(); @@ -114,13 +113,13 @@ public function testBoolFilter() $type = $index->getType('book'); //index some test data - $type->addDocuments(array( - new Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')), - new Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')), - new Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')), - new Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')), - new Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')), - )); + $type->addDocuments([ + new Document(1, ['author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson']), + new Document(2, ['author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage']), + new Document(3, ['author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin']), + new Document(4, ['author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford']), + new Document(5, ['author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin']), + ]); $index->refresh(); @@ -141,14 +140,14 @@ public function testBoolFilter() $authorFilter1->setTerm('author', 'jared'); $authorFilter2 = new Term(); $authorFilter2->setTerm('author', 'richard'); - $shouldFilter->addShould(array($authorFilter1, $authorFilter2)); + $shouldFilter->addShould([$authorFilter1, $authorFilter2]); $mustNotFilter = new BoolFilter(); $publisherFilter = new Term(); $publisherFilter->setTerm('publisher', 'penguin'); $mustNotFilter->addMustNot($publisherFilter); - $mainBoolFilter->addMust(array($shouldFilter, $mustNotFilter)); + $mainBoolFilter->addMust([$shouldFilter, $mustNotFilter]); $query->setPostFilter($mainBoolFilter); //execute the query $results = $index->search($query); @@ -157,12 +156,12 @@ public function testBoolFilter() $this->assertEquals($results->count(), 2, 'Bool filter with child Bool filters: number of results check'); //count compare the id's - $ids = array(); + $ids = []; /** @var \Elastica\Result $result **/ foreach ($results as $result) { $ids[] = $result->getId(); } - $this->assertEquals($ids, array('2', '4'), 'Bool filter with child Bool filters: result ID check'); + $this->assertEquals($ids, ['2', '4'], 'Bool filter with child Bool filters: result ID check'); $index->delete(); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php index 66a5e4b..8cd3c29 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php @@ -1,5 +1,4 @@ setIds(12); $filter = new BoolNot($idsFilter); - $expectedArray = array( - 'not' => array( + $expectedArray = [ + 'not' => [ 'filter' => $idsFilter->toArray(), - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php index dc1ffba..7610426 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php @@ -1,5 +1,4 @@ addFilter($filter1); $orFilter->addFilter($filter2); - $expectedArray = array( - 'or' => array( + $expectedArray = [ + 'or' => [ $filter1->toArray(), $filter2->toArray(), - ), - ); + ], + ]; $this->assertEquals($expectedArray, $orFilter->toArray()); } @@ -60,10 +59,10 @@ public function testToArray() */ public function testConstruct() { - $ids1 = new Ids('foo', array(1, 2)); - $ids2 = new Ids('bar', array(3, 4)); + $ids1 = new Ids('foo', [1, 2]); + $ids2 = new Ids('bar', [3, 4]); - $and1 = new BoolOr(array($ids1, $ids2)); + $and1 = new BoolOr([$ids1, $ids2]); $and2 = new BoolOr(); $and2->addFilter($ids1); @@ -80,9 +79,9 @@ public function testOrFilter() $index = $this->_createIndex(); $type = $index->getType('test'); - $doc1 = new Document('', array('categoryId' => 1)); - $doc2 = new Document('', array('categoryId' => 2)); - $doc3 = new Document('', array('categoryId' => 3)); + $doc1 = new Document('', ['categoryId' => 1]); + $doc2 = new Document('', ['categoryId' => 2]); + $doc3 = new Document('', ['categoryId' => 3]); $type->addDocument($doc1); $type->addDocument($doc2); @@ -91,8 +90,8 @@ public function testOrFilter() $index->refresh(); $boolOr = new \Elastica\Filter\BoolOr(); - $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '1'))); - $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '2'))); + $boolOr->addFilter(new \Elastica\Filter\Term(['categoryId' => '1'])); + $boolOr->addFilter(new \Elastica\Filter\Term(['categoryId' => '2'])); $resultSet = $type->search($boolOr); $this->assertEquals(2, $resultSet->count()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php index e0df9ba..f837a57 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php @@ -1,5 +1,4 @@ array('field' => $field)); + $expectedArray = ['exists' => ['field' => $field]]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php index b68f9fa..3effe0b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php @@ -1,5 +1,4 @@ assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -22,11 +21,11 @@ public function testDeprecated() public function testAddCoordinates() { $key = 'pin.location'; - $coords = array('40.73, -74.1', '40.01, -71.12'); - $filter = new GeoBoundingBox($key, array('1,2', '3,4')); + $coords = ['40.73, -74.1', '40.01, -71.12']; + $filter = new GeoBoundingBox($key, ['1,2', '3,4']); $filter->addCoordinates($key, $coords); - $expectedArray = array('top_left' => $coords[0], 'bottom_right' => $coords[1]); + $expectedArray = ['top_left' => $coords[0], 'bottom_right' => $coords[1]]; $this->assertEquals($expectedArray, $filter->getParam($key)); $returnValue = $filter->addCoordinates($key, $coords); @@ -39,7 +38,7 @@ public function testAddCoordinates() */ public function testAddCoordinatesInvalidException() { - $filter = new GeoBoundingBox('foo', array()); + $filter = new GeoBoundingBox('foo', []); } /** @@ -48,17 +47,17 @@ public function testAddCoordinatesInvalidException() public function testToArray() { $key = 'pin.location'; - $coords = array('40.73, -74.1', '40.01, -71.12'); + $coords = ['40.73, -74.1', '40.01, -71.12']; $filter = new GeoBoundingBox($key, $coords); - $expectedArray = array( - 'geo_bounding_box' => array( - $key => array( + $expectedArray = [ + 'geo_bounding_box' => [ + $key => [ 'top_left' => $coords[0], 'bottom_right' => $coords[1], - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php index f47ef5a..8860519 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php @@ -1,5 +1,4 @@ 30, 'lon' => 40))); + $reflection = new \ReflectionClass(new GeoDistanceRange('a', ['lat' => 30, 'lon' => 40])); $this->assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -28,13 +27,13 @@ public function testGeoPoint() $type = $index->getType('test'); // Set mapping - $type->setMapping(array('point' => array('type' => 'geo_point'))); + $type->setMapping(['point' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('point', 17, 19); @@ -42,9 +41,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('point', 30, 40); @@ -57,8 +56,8 @@ public function testGeoPoint() $query = new Query(); $geoFilter = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('from' => '0km', 'to' => '2km') + ['lat' => 30, 'lon' => 40], + ['from' => '0km', 'to' => '2km'] ); $query = new Query(new MatchAll()); @@ -69,8 +68,8 @@ public function testGeoPoint() $query = new Query(); $geoFilter = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('gte' => '0km', 'lte' => '4000km') + ['lat' => 30, 'lon' => 40], + ['gte' => '0km', 'lte' => '4000km'] ); $query = new Query(new MatchAll()); $query->setPostFilter($geoFilter); @@ -87,8 +86,8 @@ public function testInvalidRange() { $geoFilter = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('invalid' => '0km', 'lte' => '40000km') + ['lat' => 30, 'lon' => 40], + ['invalid' => '0km', 'lte' => '40000km'] ); } @@ -102,7 +101,7 @@ public function testInvalidLocation($location) $geoFilter = new GeoDistanceRange( 'point', $location, - array('gt' => '0km', 'lte' => '40000km') + ['gt' => '0km', 'lte' => '40000km'] ); } @@ -121,110 +120,110 @@ public function testConstruct($key, $location, $ranges, $expected) public function invalidLocationDataProvider() { - return array( - array( - array('lat' => 1.0), - ), - array( - array('lon' => 1.0), - ), - array( - array(), - ), - array( + return [ + [ + ['lat' => 1.0], + ], + [ + ['lon' => 1.0], + ], + [ + [], + ], + [ new \stdClass(), - ), - array( + ], + [ null, - ), - array( + ], + [ true, - ), - array( + ], + [ false, - ), - ); + ], + ]; } public function constructDataProvider() { - return array( - array( + return [ + [ 'location', 'u09tvqx', - array( + [ 'from' => '10km', 'to' => '20km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'from' => '10km', 'to' => '20km', 'location' => 'u09tvqx', - ), - ), - ), - array( + ], + ], + ], + [ 'location', 'u09tvqx', - array( + [ 'to' => '20km', 'include_upper' => 0, 'from' => '10km', 'include_lower' => 1, - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'to' => '20km', 'include_upper' => false, 'from' => '10km', 'include_lower' => true, 'location' => 'u09tvqx', - ), - ), - ), - array( + ], + ], + ], + [ 'location', - array( + [ 'lon' => 2.35, 'lat' => 48.86, - ), - array( + ], + [ 'lte' => '20km', 'gt' => '10km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'lte' => '20km', 'gt' => '10km', - 'location' => array( + 'location' => [ 'lat' => 48.86, 'lon' => 2.35, - ), - ), - ), - ), - array( + ], + ], + ], + ], + [ 'location', - array( + [ 'lat' => 48.86, 'lon' => 2.35, - ), - array( + ], + [ 'lt' => '20km', 'gte' => '10km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'lt' => '20km', 'gte' => '10km', - 'location' => array( + 'location' => [ 'lat' => 48.86, 'lon' => 2.35, - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php index e44b2c7..dc1367f 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php @@ -1,5 +1,4 @@ 30, 'lon' => 40), '40000km')); + $reflection = new \ReflectionClass(new GeoDistance('point', ['lat' => 30, 'lon' => 40], '40000km')); $this->assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -29,13 +28,13 @@ public function testGeoPoint() $type = $index->getType('test'); // Set mapping - $type->setMapping(array('point' => array('type' => 'geo_point'))); + $type->setMapping(['point' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('point', 17, 19); @@ -43,9 +42,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('point', 30, 40); @@ -56,7 +55,7 @@ public function testGeoPoint() // Only one point should be in radius $query = new Query(); - $geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '1km'); + $geoFilter = new GeoDistance('point', ['lat' => 30, 'lon' => 40], '1km'); $query = new Query(new MatchAll()); $query->setPostFilter($geoFilter); @@ -64,7 +63,7 @@ public function testGeoPoint() // Both points should be inside $query = new Query(); - $geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '40000km'); + $geoFilter = new GeoDistance('point', ['lat' => 30, 'lon' => 40], '40000km'); $query = new Query(new MatchAll()); $query->setPostFilter($geoFilter); $index->refresh(); @@ -78,20 +77,20 @@ public function testGeoPoint() public function testConstructLatlon() { $key = 'location'; - $location = array( + $location = [ 'lat' => 48.86, 'lon' => 2.35, - ); + ]; $distance = '10km'; $filter = new GeoDistance($key, $location, $distance); - $expected = array( - 'geo_distance' => array( + $expected = [ + 'geo_distance' => [ $key => $location, 'distance' => $distance, - ), - ); + ], + ]; $data = $filter->toArray(); @@ -109,12 +108,12 @@ public function testConstructGeohash() $filter = new GeoDistance($key, $location, $distance); - $expected = array( - 'geo_distance' => array( + $expected = [ + 'geo_distance' => [ $key => $location, 'distance' => $distance, - ), - ); + ], + ]; $data = $filter->toArray(); @@ -126,7 +125,7 @@ public function testConstructGeohash() */ public function testSetDistanceType() { - $filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km'); + $filter = new GeoDistance('location', ['lat' => 48.86, 'lon' => 2.35], '10km'); $distanceType = GeoDistance::DISTANCE_TYPE_ARC; $filter->setDistanceType($distanceType); @@ -140,7 +139,7 @@ public function testSetDistanceType() */ public function testSetOptimizeBbox() { - $filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km'); + $filter = new GeoDistance('location', ['lat' => 48.86, 'lon' => 2.35], '10km'); $optimizeBbox = GeoDistance::OPTIMIZE_BBOX_MEMORY; $filter->setOptimizeBbox($optimizeBbox); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php index ccec30a..fb804a5 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php @@ -1,5 +1,4 @@ assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -29,13 +28,13 @@ public function testGeoPoint() $type = $index->getType('test'); // Set mapping - $type->setMapping(array('location' => array('type' => 'geo_point'))); + $type->setMapping(['location' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('location', 17, 19); @@ -43,9 +42,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('location', 30, 40); @@ -55,7 +54,7 @@ public function testGeoPoint() // Only one point should be in polygon $query = new Query(); - $points = array(array(16, 16), array(16, 20), array(20, 20), array(20, 16), array(16, 16)); + $points = [[16, 16], [16, 20], [20, 20], [20, 16], [16, 16]]; $geoFilter = new GeoPolygon('location', $points); $query = new Query(new MatchAll()); @@ -64,7 +63,7 @@ public function testGeoPoint() // Both points should be inside $query = new Query(); - $points = array(array(16, 16), array(16, 40), array(40, 40), array(40, 16), array(16, 16)); + $points = [[16, 16], [16, 40], [40, 40], [40, 16], [16, 16]]; $geoFilter = new GeoPolygon('location', $points); $query = new Query(new MatchAll()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php index 22f2222..44104f1 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php @@ -1,5 +1,4 @@ getType('other_type'); // create mapping - $mapping = new \Elastica\Type\Mapping($type, array( - 'location' => array( + $mapping = new \Elastica\Type\Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $type->setMapping($mapping); // create other type mapping - $otherMapping = new \Elastica\Type\Mapping($type, array( - 'location' => array( + $otherMapping = new \Elastica\Type\Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $otherType->setMapping($otherMapping); // add type docs - $type->addDocument(new \Elastica\Document('1', array( - 'location' => array( + $type->addDocument(new \Elastica\Document('1', [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(0.0, 50.0), - array(50.0, 0.0), - ), - ), - ))); + 'coordinates' => [ + [0.0, 50.0], + [50.0, 0.0], + ], + ], + ])); // add other type docs - $otherType->addDocument(new \Elastica\Document('2', array( - 'location' => array( + $otherType->addDocument(new \Elastica\Document('2', [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(25.0, 75.0), - array(75.0, 25.0), - ), - ), - ))); + 'coordinates' => [ + [25.0, 75.0], + [75.0, 25.0], + ], + ], + ])); $index->optimize(); $index->refresh(); @@ -74,19 +73,19 @@ public function testGeoProvided() ); $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'indexed_shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'indexed_shape' => [ 'id' => '1', 'type' => 'type', 'index' => $indexName, 'path' => 'location', - ), + ], 'relation' => $gsp->getRelation(), - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php index 992c385..a296880 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php @@ -1,5 +1,4 @@ assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -29,44 +28,44 @@ public function testConstructEnvelope() $type = $index->getType('test'); // create mapping - $mapping = new Mapping($type, array( - 'location' => array( + $mapping = new Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $type->setMapping($mapping); // add docs - $type->addDocument(new Document(1, array( - 'location' => array( + $type->addDocument(new Document(1, [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(-50.0, 50.0), - array(50.0, -50.0), - ), - ), - ))); + 'coordinates' => [ + [-50.0, 50.0], + [50.0, -50.0], + ], + ], + ])); $index->optimize(); $index->refresh(); - $envelope = array( - array(25.0, 75.0), - array(75.0, 25.0), - ); + $envelope = [ + [25.0, 75.0], + [75.0, 25.0], + ]; $gsp = new GeoShapeProvided('location', $envelope); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'shape' => [ 'type' => GeoShapeProvided::TYPE_ENVELOPE, 'coordinates' => $envelope, 'relation' => AbstractGeoShape::RELATION_INTERSECT, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); @@ -82,20 +81,20 @@ public function testConstructEnvelope() */ public function testConstructPolygon() { - $polygon = array(array(102.0, 2.0), array(103.0, 2.0), array(103.0, 3.0), array(103.0, 3.0), array(102.0, 2.0)); + $polygon = [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [103.0, 3.0], [102.0, 2.0]]; $gsp = new GeoShapeProvided('location', $polygon, GeoShapeProvided::TYPE_POLYGON); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'shape' => [ 'type' => GeoShapeProvided::TYPE_POLYGON, 'coordinates' => $polygon, 'relation' => $gsp->getRelation(), - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); } @@ -105,7 +104,7 @@ public function testConstructPolygon() */ public function testSetRelation() { - $gsp = new GeoShapeProvided('location', array(array(25.0, 75.0), array(75.0, 25.0))); + $gsp = new GeoShapeProvided('location', [[25.0, 75.0], [75.0, 25.0]]); $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT); $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation()); $this->assertInstanceOf('Elastica\Filter\GeoShapeProvided', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT)); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php index 6fb21db..8dd6acb 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php @@ -1,5 +1,4 @@ 37.789018, 'lon' => -122.391506), '50m')); + $reflection = new \ReflectionClass(new GeohashCell('pin', ['lat' => 37.789018, 'lon' => -122.391506], '50m')); $this->assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -24,17 +23,17 @@ public function testDeprecated() */ public function testToArray() { - $filter = new GeohashCell('pin', array('lat' => 37.789018, 'lon' => -122.391506), '50m'); - $expected = array( - 'geohash_cell' => array( - 'pin' => array( + $filter = new GeohashCell('pin', ['lat' => 37.789018, 'lon' => -122.391506], '50m'); + $expected = [ + 'geohash_cell' => [ + 'pin' => [ 'lat' => 37.789018, 'lon' => -122.391506, - ), + ], 'precision' => '50m', 'neighbors' => false, - ), - ); + ], + ]; $this->assertEquals($expected, $filter->toArray()); } @@ -45,20 +44,20 @@ public function testFilter() { $index = $this->_createIndex(); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'pin' => array( + $mapping = new Mapping($type, [ + 'pin' => [ 'type' => 'geo_point', 'geohash' => true, 'geohash_prefix' => true, - ), - )); + ], + ]); $type->setMapping($mapping); - $type->addDocument(new Document(1, array('pin' => '9q8yyzm0zpw8'))); - $type->addDocument(new Document(2, array('pin' => '9mudgb0yued0'))); + $type->addDocument(new Document(1, ['pin' => '9q8yyzm0zpw8'])); + $type->addDocument(new Document(2, ['pin' => '9mudgb0yued0'])); $index->refresh(); - $filter = new GeohashCell('pin', array('lat' => 32.828326, 'lon' => -117.255854)); + $filter = new GeohashCell('pin', ['lat' => 32.828326, 'lon' => -117.255854]); $query = new Query(); $query->setPostFilter($filter); $results = $type->search($query); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php index 657f255..9e4fd91 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'has_child' => [ 'query' => $q->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -105,12 +104,12 @@ public function testFilterInsideHasChild() $filter = new HasChild($f, $type); - $expectedArray = array( - 'has_child' => array( + $expectedArray = [ + 'has_child' => [ 'filter' => $f->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -133,7 +132,7 @@ public function testFilterInsideHasChildSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'); + $expected = ['id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com']; $this->assertEquals($expected, $result); } @@ -156,7 +155,7 @@ public function testQueryInsideHasChildSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'); + $expected = ['id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com']; $this->assertEquals($expected, $result); } @@ -179,7 +178,7 @@ public function testTypeInsideHasChildSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'); + $expected = ['id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com']; $this->assertEquals($expected, $result); } @@ -188,7 +187,7 @@ private function prepareSearchData() { $client = $this->_getClient(); $index = $client->getIndex('has_child_test'); - $index->create(array(), true); + $index->create([], true); $parentType = $index->getType('parent'); @@ -198,21 +197,21 @@ private function prepareSearchData() $childMapping->send(); $altType = $index->getType('alt'); - $altDoc = new Document('alt1', array('name' => 'altname')); + $altDoc = new Document('alt1', ['name' => 'altname']); $altType->addDocument($altDoc); - $parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com')); + $parent1 = new Document('parent1', ['id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com']); $parentType->addDocument($parent1); - $parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com')); + $parent2 = new Document('parent2', ['id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com']); $parentType->addDocument($parent2); - $child1 = new Document('child1', array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com')); + $child1 = new Document('child1', ['id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com']); $child1->setParent('parent1'); $childType->addDocument($child1); - $child2 = new Document('child2', array('id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com')); + $child2 = new Document('child2', ['id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com']); $child2->setParent('parent2'); $childType->addDocument($child2); - $child3 = new Document('child3', array('id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => array(array('name' => 'testname')))); + $child3 = new Document('child3', ['id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => [['name' => 'testname']]]); $child3->setParent('parent2'); $childType->addDocument($child3); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php index 69ff036..90a2697 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'has_parent' => [ 'query' => $q->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -75,12 +74,12 @@ public function testFilterInsideHasParent() $filter = new HasParent($f, $type); - $expectedArray = array( - 'has_parent' => array( + $expectedArray = [ + 'has_parent' => [ 'filter' => $f->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -103,7 +102,7 @@ public function testFilterInsideHasParentSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com'); + $expected = ['id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com']; $this->assertEquals($expected, $result); } @@ -126,7 +125,7 @@ public function testQueryInsideHasParentSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com'); + $expected = ['id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com']; $this->assertEquals($expected, $result); } @@ -135,7 +134,7 @@ private function prepareSearchData() { $client = $this->_getClient(); $index = $client->getIndex('has_parent_test'); - $index->create(array(), true); + $index->create([], true); $parentType = $index->getType('parent'); @@ -144,15 +143,15 @@ private function prepareSearchData() $childMapping->setParent('parent'); $childMapping->send(); - $parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com')); + $parent1 = new Document('parent1', ['id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com']); $parentType->addDocument($parent1); - $parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com')); + $parent2 = new Document('parent2', ['id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com']); $parentType->addDocument($parent2); - $child1 = new Document('child1', array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com')); + $child1 = new Document('child1', ['id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com']); $child1->setParent('parent1'); $childType->addDocument($child1); - $child2 = new Document('child2', array('id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com')); + $child2 = new Document('child2', ['id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com']); $child2->setParent('parent2'); $childType->addDocument($child2); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php index b1deed7..bcf315b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php @@ -1,5 +1,4 @@ _createIndex(); // Add documents to first type - $docs = array(); + $docs = []; for ($i = 1; $i < 100; ++$i) { - $docs[] = new Document($i, array('name' => 'ruflin')); + $docs[] = new Document($i, ['name' => 'ruflin']); } $index->getType('helloworld1')->addDocuments($docs); // Add documents to second type - $docs = array(); + $docs = []; for ($i = 1; $i < 100; ++$i) { - $docs[] = new Document($i, array('name' => 'ruflin')); + $docs[] = new Document($i, ['name' => 'ruflin']); } // This is a special id that will only be in the second type - $docs[] = new Document(101, array('name' => 'ruflin')); + $docs[] = new Document(101, ['name' => 'ruflin']); $index->getType('helloworld2')->addDocuments($docs); $index->optimize(); @@ -70,7 +69,7 @@ public function testSetIdsSearchSingle() public function testSetIdsSearchArray() { $filter = new Ids(); - $filter->setIds(array(1, 7, 13)); + $filter->setIds([1, 7, 13]); $query = Query::create($filter); $resultSet = $this->_getTypeForTest()->search($query); @@ -115,7 +114,7 @@ public function testAddIdsSearchSingleNotInType() public function testComboIdsSearchArray() { $filter = new Ids(); - $filter->setIds(array(1, 7, 13)); + $filter->setIds([1, 7, 13]); $filter->addId('39'); $query = Query::create($filter); @@ -145,7 +144,7 @@ public function testSetTypeSingleSearchSingle() public function testSetTypeSingleSearchArray() { $filter = new Ids(); - $filter->setIds(array('1', '2')); + $filter->setIds(['1', '2']); $filter->setType('helloworld1'); $query = Query::create($filter); @@ -180,7 +179,7 @@ public function testSetTypeSingleSearchArrayDocInOtherType() $filter = new Ids(); // Doc 4 is in the second type... - $filter->setIds(array('1', '101')); + $filter->setIds(['1', '101']); $filter->setType('helloworld1'); $query = Query::create($filter); @@ -196,8 +195,8 @@ public function testSetTypeSingleSearchArrayDocInOtherType() public function testSetTypeArraySearchArray() { $filter = new Ids(); - $filter->setIds(array('1', '4')); - $filter->setType(array('helloworld1', 'helloworld2')); + $filter->setIds(['1', '4']); + $filter->setType(['helloworld1', 'helloworld2']); $query = Query::create($filter); $resultSet = $this->_getIndexForTest()->search($query); @@ -212,7 +211,7 @@ public function testSetTypeArraySearchSingle() { $filter = new Ids(); $filter->setIds('4'); - $filter->setType(array('helloworld1', 'helloworld2')); + $filter->setType(['helloworld1', 'helloworld2']); $query = Query::create($filter); $resultSet = $this->_getIndexForTest()->search($query); @@ -243,10 +242,10 @@ public function testAddType() $filter = new Ids(); $filter->addType('foo'); - $this->assertEquals(array('foo'), $filter->getParam('type')); + $this->assertEquals(['foo'], $filter->getParam('type')); $filter->addType($type); - $this->assertEquals(array('foo', $type->getName()), $filter->getParam('type')); + $this->assertEquals(['foo', $type->getName()], $filter->getParam('type')); $returnValue = $filter->addType('bar'); $this->assertInstanceOf('Elastica\Filter\Ids', $returnValue); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php index ce8777b..56041ee 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php @@ -1,5 +1,4 @@ assertFileDeprecated($reflection->getFileName(), 'Deprecated: Filters are deprecated. Use queries in filter context. See https://www.elastic.co/guide/en/elasticsearch/reference/2.0/query-dsl-filters.html'); } @@ -26,19 +25,19 @@ public function testDeprecated() */ public function testToArray() { - $expected = array( - 'indices' => array( - 'indices' => array('index1', 'index2'), - 'filter' => array( - 'term' => array('tag' => 'wow'), - ), - 'no_match_filter' => array( - 'term' => array('tag' => 'such filter'), - ), - ), - ); - $filter = new Indices(new Term(array('tag' => 'wow')), array('index1', 'index2')); - $filter->setNoMatchFilter(new Term(array('tag' => 'such filter'))); + $expected = [ + 'indices' => [ + 'indices' => ['index1', 'index2'], + 'filter' => [ + 'term' => ['tag' => 'wow'], + ], + 'no_match_filter' => [ + 'term' => ['tag' => 'such filter'], + ], + ], + ]; + $filter = new Indices(new Term(['tag' => 'wow']), ['index1', 'index2']); + $filter->setNoMatchFilter(new Term(['tag' => 'such filter'])); $this->assertEquals($expected, $filter->toArray()); } @@ -47,12 +46,12 @@ public function testToArray() */ public function testIndicesFilter() { - $docs = array( - new Document(1, array('color' => 'blue')), - new Document(2, array('color' => 'green')), - new Document(3, array('color' => 'blue')), - new Document(4, array('color' => 'yellow')), - ); + $docs = [ + new Document(1, ['color' => 'blue']), + new Document(2, ['color' => 'green']), + new Document(3, ['color' => 'blue']), + new Document(4, ['color' => 'yellow']), + ]; $index1 = $this->_createIndex(); $index1->addAlias('indices_filter'); @@ -64,8 +63,8 @@ public function testIndicesFilter() $index2->getType('test')->addDocuments($docs); $index2->refresh(); - $filter = new Indices(new BoolNot(new Term(array('color' => 'blue'))), array($index1->getName())); - $filter->setNoMatchFilter(new BoolNot(new Term(array('color' => 'yellow')))); + $filter = new Indices(new BoolNot(new Term(['color' => 'blue'])), [$index1->getName()]); + $filter->setNoMatchFilter(new BoolNot(new Term(['color' => 'yellow']))); $query = new Query(); $query->setPostFilter($filter); @@ -95,16 +94,16 @@ public function testSetIndices() $index1 = $client->getIndex('index1'); $index2 = $client->getIndex('index2'); - $indices = array('one', 'two'); - $filter = new Indices(new Term(array('color' => 'blue')), $indices); + $indices = ['one', 'two']; + $filter = new Indices(new Term(['color' => 'blue']), $indices); $this->assertEquals($indices, $filter->getParam('indices')); $indices[] = 'three'; $filter->setIndices($indices); $this->assertEquals($indices, $filter->getParam('indices')); - $filter->setIndices(array($index1, $index2)); - $expected = array($index1->getName(), $index2->getName()); + $filter->setIndices([$index1, $index2]); + $expected = [$index1->getName(), $index2->getName()]; $this->assertEquals($expected, $filter->getParam('indices')); $returnValue = $filter->setIndices($indices); @@ -119,14 +118,14 @@ public function testAddIndex() $client = $this->_getClient(); $index = $client->getIndex('someindex'); - $filter = new Indices(new Term(array('color' => 'blue')), array()); + $filter = new Indices(new Term(['color' => 'blue']), []); $filter->addIndex($index); - $expected = array($index->getName()); + $expected = [$index->getName()]; $this->assertEquals($expected, $filter->getParam('indices')); $filter->addIndex('foo'); - $expected = array($index->getName(), 'foo'); + $expected = [$index->getName(), 'foo']; $this->assertEquals($expected, $filter->getParam('indices')); $returnValue = $filter->addIndex('bar'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php index 48d2eb4..25be665 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php @@ -1,5 +1,4 @@ array('value' => 15), - ); + $expectedArray = [ + 'limit' => ['value' => 15], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php index b26585b..2fdd73a 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php @@ -1,5 +1,4 @@ new \stdClass()); + $expectedArray = ['match_all' => new \stdClass()]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php index 0846dc7..4e08810 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php @@ -1,5 +1,4 @@ array('field' => 'field_name')); + $expectedArray = ['missing' => ['field' => 'field_name']]; $this->assertEquals($expectedArray, $filter->toArray()); $filter = new Missing('field_name'); $filter->setExistence(true); - $expectedArray = array('missing' => array('field' => 'field_name', 'existence' => true)); + $expectedArray = ['missing' => ['field' => 'field_name', 'existence' => true]]; $this->assertEquals($expectedArray, $filter->toArray()); $filter = new Missing('field_name'); $filter->setNullValue(true); - $expectedArray = array('missing' => array('field' => 'field_name', 'null_value' => true)); + $expectedArray = ['missing' => ['field' => 'field_name', 'null_value' => true]]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php index 4a7a91a..8769980 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php @@ -1,5 +1,4 @@ addFilter($filter); - $expected = array( + $expected = [ $filter, - ); + ]; $this->assertSame($expected, $stub->getFilters()); } @@ -53,11 +52,11 @@ public function testSetFilters() $stub = $this->getStub(); $filter = new MatchAll(); - $stub->setFilters(array($filter)); + $stub->setFilters([$filter]); - $expected = array( + $expected = [ $filter, - ); + ]; $this->assertSame($expected, $stub->getFilters()); } @@ -72,11 +71,11 @@ public function testToArray() $filter = new MatchAll(); $stub->addFilter($filter); - $expected = array( - $stub->getBaseName() => array( + $expected = [ + $stub->getBaseName() => [ $filter->toArray(), - ), - ); + ], + ]; $this->assertEquals($expected, $stub->toArray()); } @@ -93,14 +92,14 @@ public function testToArrayWithParam() $filter = new MatchAll(); $stub->addFilter($filter); - $expected = array( - $stub->getBaseName() => array( + $expected = [ + $stub->getBaseName() => [ '_cache' => true, - 'filters' => array( + 'filters' => [ $filter->toArray(), - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $stub->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php index 3c396c3..89b2393 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('user'); - $type->setMapping(new Mapping(null, array( - 'firstname' => array('type' => 'string', 'store' => 'yes'), + $type->setMapping(new Mapping(null, [ + 'firstname' => ['type' => 'string', 'store' => 'yes'], // default is store => no expected - 'lastname' => array('type' => 'string'), - 'hobbies' => array( + 'lastname' => ['type' => 'string'], + 'hobbies' => [ 'type' => 'nested', 'include_in_parent' => true, - 'properties' => array('hobby' => array('type' => 'string')), - ), - ))); + 'properties' => ['hobby' => ['type' => 'string']], + ], + ])); - $type->addDocuments(array( - new Document(1, array( + $type->addDocuments([ + new Document(1, [ 'firstname' => 'Nicolas', 'lastname' => 'Ruflin', - 'hobbies' => array( - array('hobby' => 'opensource'), - ), - )), - new Document(2, array( + 'hobbies' => [ + ['hobby' => 'opensource'], + ], + ]), + new Document(2, [ 'firstname' => 'Nicolas', 'lastname' => 'Ippolito', - 'hobbies' => array( - array('hobby' => 'opensource'), - array('hobby' => 'guitar'), - ), - )), - )); + 'hobbies' => [ + ['hobby' => 'opensource'], + ['hobby' => 'guitar'], + ], + ]), + ]); $index->refresh(); @@ -58,20 +57,20 @@ public function testToArray() $this->hideDeprecated(); $filter = new Nested(); $this->showDeprecated(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobby', array('guitar')); + $query->setTerms('hobby', ['guitar']); $filter->setPath('hobbies'); $filter->setFilter($query); - $expectedArray = array( - 'nested' => array( + $expectedArray = [ + 'nested' => [ 'path' => 'hobbies', - 'filter' => array('terms' => array( - 'hobby' => array('guitar'), - )), - ), - ); + 'filter' => ['terms' => [ + 'hobby' => ['guitar'], + ]], + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -84,9 +83,9 @@ public function testShouldReturnTheRightNumberOfResult() $this->hideDeprecated(); $filter = new Nested(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobbies.hobby', array('guitar')); + $query->setTerms('hobbies.hobby', ['guitar']); $filter->setPath('hobbies'); $filter->setFilter($query); @@ -99,9 +98,9 @@ public function testShouldReturnTheRightNumberOfResult() $this->assertEquals(1, $resultSet->getTotalHits()); $filter = new Nested(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobbies.hobby', array('opensource')); + $query->setTerms('hobbies.hobby', ['opensource']); $filter->setPath('hobbies'); $filter->setFilter($query); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php index 9676427..53a11e6 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php @@ -1,5 +1,4 @@ getType('user'); $mapping = new Mapping(); $mapping->setProperties( - array( - 'firstname' => array('type' => 'string', 'store' => 'yes'), + [ + 'firstname' => ['type' => 'string', 'store' => 'yes'], // default is store => no expected - 'lastname' => array('type' => 'string'), - 'hobbies' => array( + 'lastname' => ['type' => 'string'], + 'hobbies' => [ 'type' => 'nested', 'include_in_parent' => true, - 'properties' => array('hobby' => array('type' => 'string')), - ), - ) + 'properties' => ['hobby' => ['type' => 'string']], + ], + ] ); $type->setMapping($mapping); - $response = $type->addDocuments(array( + $response = $type->addDocuments([ new Document(1, - array( + [ 'firstname' => 'Nicolas', 'lastname' => 'Ruflin', - 'hobbies' => array( - array('hobby' => 'opensource'), - ), - ) + 'hobbies' => [ + ['hobby' => 'opensource'], + ], + ] ), new Document(2, - array( + [ 'firstname' => 'Nicolas', 'lastname' => 'Ippolito', - 'hobbies' => array( - array('hobby' => 'opensource'), - array('hobby' => 'guitar'), - ), - ) + 'hobbies' => [ + ['hobby' => 'opensource'], + ['hobby' => 'guitar'], + ], + ] ), - )); + ]); $index->refresh(); @@ -72,20 +71,20 @@ protected function _getIndexForTest() public function testToArray() { $filter = new Nested(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobby', array('guitar')); + $query->setTerms('hobby', ['guitar']); $filter->setPath('hobbies'); $filter->setQuery($query); - $expectedArray = array( - 'nested' => array( + $expectedArray = [ + 'nested' => [ 'path' => 'hobbies', - 'query' => array('terms' => array( - 'hobby' => array('guitar'), - )), - ), - ); + 'query' => ['terms' => [ + 'hobby' => ['guitar'], + ]], + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -96,9 +95,9 @@ public function testToArray() public function testShouldReturnTheRightNumberOfResult() { $filter = new Nested(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobbies.hobby', array('guitar')); + $query->setTerms('hobbies.hobby', ['guitar']); $filter->setPath('hobbies'); $filter->setQuery($query); @@ -109,9 +108,9 @@ public function testShouldReturnTheRightNumberOfResult() $this->assertEquals(1, $resultSet->getTotalHits()); $filter = new Nested(); - $this->assertEquals(array('nested' => array()), $filter->toArray()); + $this->assertEquals(['nested' => []], $filter->toArray()); $query = new Terms(); - $query->setTerms('hobbies.hobby', array('opensource')); + $query->setTerms('hobbies.hobby', ['opensource']); $filter->setPath('hobbies'); $filter->setQuery($query); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php index c7710fb..91d90fb 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php @@ -1,5 +1,4 @@ addField('fieldName', array('to' => 'value')); + $returnValue = $rangeFilter->addField('fieldName', ['to' => 'value']); $this->assertInstanceOf('Elastica\Filter\NumericRange', $returnValue); } @@ -33,14 +32,14 @@ public function testToArray() { $filter = new NumericRange(); - $fromTo = array('from' => 'ra', 'to' => 'ru'); + $fromTo = ['from' => 'ra', 'to' => 'ru']; $filter->addField('name', $fromTo); - $expectedArray = array( - 'numeric_range' => array( + $expectedArray = [ + 'numeric_range' => [ 'name' => $fromTo, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php index 572afa8..1863222 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'prefix' => [ $field => $prefix, - ), - ); + ], + ]; $this->assertequals($expectedArray, $filter->toArray()); } @@ -45,21 +44,21 @@ public function testDifferentPrefixes() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed'), - ) + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'index' => 'not_analyzed'], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - new Document(5, array('name' => 'New Orleans')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + new Document(5, ['name' => 'New Orleans']), + ]); $index->refresh(); @@ -93,34 +92,34 @@ public function testDifferentPrefixesLowercase() $client = $this->_getClient(); $index = $client->getIndex('test'); - $indexParams = array( - 'analysis' => array( - 'analyzer' => array( - 'lw' => array( + $indexParams = [ + 'analysis' => [ + 'analyzer' => [ + 'lw' => [ 'type' => 'custom', 'tokenizer' => 'keyword', - 'filter' => array('lowercase'), - ), - ), - ), - ); + 'filter' => ['lowercase'], + ], + ], + ], + ]; $index->create($indexParams, true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'lw'), - ) + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'lw'], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - new Document(5, array('name' => 'New Orleans')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + new Document(5, ['name' => 'New Orleans']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php index 71646cf..29bf6fe 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php @@ -1,5 +1,4 @@ array( - 'query_string' => array( + $expected = [ + 'query' => [ + 'query_string' => [ 'query' => 'foo bar', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $filter->toArray()); } @@ -45,16 +44,16 @@ public function testExtended() $filter = new Query($query); $filter->setCached(true); - $expected = array( - 'fquery' => array( - 'query' => array( - 'query_string' => array( + $expected = [ + 'fquery' => [ + 'query' => [ + 'query_string' => [ 'query' => 'foo bar', - ), - ), + ], + ], '_cache' => true, - ), - ); + ], + ]; $this->assertEquals($expected, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php index 19a94d3..1caf4f7 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php @@ -1,5 +1,4 @@ addField('fieldName', array('to' => 'value')); + $returnValue = $rangeFilter->addField('fieldName', ['to' => 'value']); $this->assertInstanceOf('Elastica\Filter\Range', $returnValue); } @@ -32,11 +31,11 @@ public function testAddField() public function testToArray() { $field = 'field_name'; - $range = array('gte' => 10, 'lte' => 99); + $range = ['gte' => 10, 'lte' => 99]; $filter = new Range(); $filter->addField($field, $range); - $expectedArray = array('range' => array($field => $range)); + $expectedArray = ['range' => [$field => $range]]; $this->assertEquals($expectedArray, $filter->toArray()); } @@ -46,7 +45,7 @@ public function testToArray() public function testSetExecution() { $field = 'field_name'; - $range = array('gte' => 10, 'lte' => 99); + $range = ['gte' => 10, 'lte' => 99]; $filter = new Range('field_name', $range); $filter->setExecution('fielddata'); @@ -63,7 +62,7 @@ public function testSetExecution() */ public function testSetCachedNotOverwritten() { - $filter = new Range('field_name', array()); + $filter = new Range('field_name', []); $filter->setCached(true); $array = $filter->toArray(); $this->assertTrue($array['range']['_cache']); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php index 312c856..c8c6dbd 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'regexp' => [ $field => $regexp, - ), - ); + ], + ]; $this->assertequals($expectedArray, $filter->toArray()); } @@ -44,20 +43,20 @@ public function testToArrayWithOptions() { $field = 'name'; $regexp = 'ruf'; - $options = array( + $options = [ 'flags' => 'ALL', - ); + ]; $filter = new Regexp($field, $regexp, $options); - $expectedArray = array( - 'regexp' => array( - $field => array( + $expectedArray = [ + 'regexp' => [ + $field => [ 'value' => $regexp, 'flags' => 'ALL', - ), - ), - ); + ], + ], + ]; $this->assertequals($expectedArray, $filter->toArray()); } @@ -70,21 +69,21 @@ public function testDifferentRegexp() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'index' => 'not_analyzed'), - ) + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'index' => 'not_analyzed'], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - new Document(5, array('name' => 'New Orleans')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + new Document(5, ['name' => 'New Orleans']), + ]); $index->refresh(); @@ -118,33 +117,33 @@ public function testDifferentRegexpLowercase() $client = $this->_getClient(); $index = $client->getIndex('test'); - $indexParams = array( - 'analysis' => array( - 'analyzer' => array( - 'lw' => array( + $indexParams = [ + 'analysis' => [ + 'analyzer' => [ + 'lw' => [ 'type' => 'custom', 'tokenizer' => 'keyword', - 'filter' => array('lowercase'), - ), - ), - ), - ); + 'filter' => ['lowercase'], + ], + ], + ], + ]; $index->create($indexParams, true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'lw'), - ) + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'lw'], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - new Document(5, array('name' => 'New Orleans')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + new Document(5, ['name' => 'New Orleans']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php index d4dfa97..2a1f929 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php @@ -1,5 +1,4 @@ toArray(); $this->assertInternalType('array', $array); - $expected = array( - 'script' => array( + $expected = [ + 'script' => [ 'script' => $string, - ), - ); + ], + ]; $this->assertEquals($expected, $array); } @@ -43,10 +42,10 @@ public function testToArray() public function testSetScript() { $string = '_score * 2.0'; - $params = array( + $params = [ 'param1' => 'one', 'param2' => 1, - ); + ]; $lang = 'mvel'; $script = new Script($string, $params, $lang); @@ -55,13 +54,13 @@ public function testSetScript() $array = $filter->toArray(); - $expected = array( - 'script' => array( + $expected = [ + 'script' => [ 'script' => $string, 'params' => $params, 'lang' => $lang, - ), - ); + ], + ]; $this->assertEquals($expected, $array); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php index b81ca55..5809d52 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php @@ -1,5 +1,4 @@ toArray(); $this->assertInternalType('array', $data['term']); - $this->assertEquals(array($key => $value), $data['term']); + $this->assertEquals([$key => $value], $data['term']); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php index 3ceaaec..cbdba6a 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php @@ -1,5 +1,4 @@ getType('bands'); //index some test data - $type1->addDocuments(array( - new Document(1, array('name' => 'robert', 'lastName' => 'plant')), - new Document(2, array('name' => 'jimmy', 'lastName' => 'page')), - new Document(3, array('name' => 'john paul', 'lastName' => 'jones')), - new Document(4, array('name' => 'john', 'lastName' => 'bonham')), - new Document(5, array('name' => 'jimi', 'lastName' => 'hendrix')), - )); - - $type2->addDocument(new Document('led zeppelin', array('members' => array('plant', 'page', 'jones', 'bonham')))); + $type1->addDocuments([ + new Document(1, ['name' => 'robert', 'lastName' => 'plant']), + new Document(2, ['name' => 'jimmy', 'lastName' => 'page']), + new Document(3, ['name' => 'john paul', 'lastName' => 'jones']), + new Document(4, ['name' => 'john', 'lastName' => 'bonham']), + new Document(5, ['name' => 'jimi', 'lastName' => 'hendrix']), + ]); + + $type2->addDocument(new Document('led zeppelin', ['members' => ['plant', 'page', 'jones', 'bonham']])); $index->refresh(); //use the terms lookup feature to query for some data @@ -59,7 +58,7 @@ public function testLookup() $this->assertEquals($results->count(), 4, 'Terms lookup with index as string'); //Query with array of options - $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', array('index' => $index)); + $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', ['index' => $index]); $query->setPostFilter($termsFilter); $results = $index->search($query); $this->assertEquals($results->count(), 4, 'Terms lookup with options array'); @@ -72,7 +71,7 @@ public function testLookup() */ public function testSetExecution() { - $filter = new Terms('color', array('blue', 'green')); + $filter = new Terms('color', ['blue', 'green']); $filter->setExecution('bool'); $this->assertEquals('bool', $filter->getParam('execution')); @@ -87,11 +86,11 @@ public function testSetExecution() public function testSetTerms() { $field = 'color'; - $terms = array('blue', 'green'); + $terms = ['blue', 'green']; $filter = new Terms(); $filter->setTerms($field, $terms); - $expected = array('terms' => array($field => $terms)); + $expected = ['terms' => [$field => $terms]]; $this->assertEquals($expected, $filter->toArray()); $returnValue = $filter->setTerms($field, $terms); @@ -103,10 +102,10 @@ public function testSetTerms() */ public function testAddTerm() { - $filter = new Terms('color', array('blue')); + $filter = new Terms('color', ['blue']); $filter->addTerm('green'); - $expected = array('terms' => array('color' => array('blue', 'green'))); + $expected = ['terms' => ['color' => ['blue', 'green']]]; $this->assertEquals($expected, $filter->toArray()); $returnValue = $filter->addTerm('cyan'); @@ -118,12 +117,12 @@ public function testAddTerm() */ public function testToArray() { - $filter = new Terms('color', array()); - $expected = array('terms' => array('color' => array())); + $filter = new Terms('color', []); + $expected = ['terms' => ['color' => []]]; $this->assertEquals($expected, $filter->toArray()); - $filter = new Terms('color', array('cyan')); - $expected = array('terms' => array('color' => array('cyan'))); + $filter = new Terms('color', ['cyan']); + $expected = ['terms' => ['color' => ['cyan']]]; $this->assertEquals($expected, $filter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php index bbc0f9f..56b1e49 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php @@ -1,5 +1,4 @@ array('value' => 'type_name'), - ); + $expectedArray = [ + 'type' => ['value' => 'type_name'], + ]; $this->assertEquals($expectedArray, $typeFilter->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php index 4887f9a..a1ce8aa 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $index->refresh(); $settings = $index->getSettings(); @@ -41,7 +40,7 @@ public function testGetWithAlias() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $index->refresh(); $index->addAlias($aliasName); @@ -65,7 +64,7 @@ public function testSetNumberOfReplicas() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $settings = $index->getSettings(); $settings->setNumberOfReplicas(2); @@ -88,7 +87,7 @@ public function testSetRefreshInterval() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $settings = $index->getSettings(); @@ -112,7 +111,7 @@ public function testGetRefreshInterval() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $settings = $index->getSettings(); @@ -136,7 +135,7 @@ public function testSetMergePolicy() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); //wait for the shards to be allocated $this->_waitForAllocation($index); @@ -160,7 +159,7 @@ public function testSetMergeFactor() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); //wait for the shards to be allocated $this->_waitForAllocation($index); @@ -187,7 +186,7 @@ public function testSetMergePolicyType() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); //wait for the shards to be allocated $this->_waitForAllocation($index); @@ -216,9 +215,9 @@ public function testSetReadOnly() $index->getSettings()->setReadOnly(false); // Add document to normal index - $doc1 = new Document(null, array('hello' => 'world')); - $doc2 = new Document(null, array('hello' => 'world')); - $doc3 = new Document(null, array('hello' => 'world')); + $doc1 = new Document(null, ['hello' => 'world']); + $doc2 = new Document(null, ['hello' => 'world']); + $doc3 = new Document(null, ['hello' => 'world']); $type = $index->getType('test'); $type->addDocument($doc1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php index 9fbda5c..a564ae5 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $stats = $index->getStats(); $this->assertInstanceOf('Elastica\Index\Stats', $stats); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTemplateTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTemplateTest.php index 26448c2..a60e761 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTemplateTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTemplateTest.php @@ -1,5 +1,4 @@ getMock('\Elastica\Client', array('request')); + $clientMock = $this->getMock('\Elastica\Client', ['request']); $clientMock->expects($this->once()) ->method('request') - ->with('/_template/'.$name, Request::DELETE, array(), array()) + ->with('/_template/'.$name, Request::DELETE, [], []) ->willReturn($response); $indexTemplate = new IndexTemplate($clientMock, $name); $this->assertSame($response, $indexTemplate->delete()); @@ -60,14 +59,14 @@ public function testDelete() */ public function testCreate() { - $args = array(1); + $args = [1]; $response = new Response(''); $name = 'index_template1'; /** @var \PHPUnit_Framework_MockObject_MockObject|Client $clientMock */ - $clientMock = $this->getMock('\Elastica\Client', array('request')); + $clientMock = $this->getMock('\Elastica\Client', ['request']); $clientMock->expects($this->once()) ->method('request') - ->with('/_template/'.$name, Request::PUT, $args, array()) + ->with('/_template/'.$name, Request::PUT, $args, []) ->willReturn($response); $indexTemplate = new IndexTemplate($clientMock, $name); $this->assertSame($response, $indexTemplate->create($args)); @@ -80,12 +79,12 @@ public function testExists() { $name = 'index_template1'; $response = new Response(''); - $response->setTransferInfo(array('http_code' => 200)); + $response->setTransferInfo(['http_code' => 200]); /** @var \PHPUnit_Framework_MockObject_MockObject|Client $clientMock */ - $clientMock = $this->getMock('\Elastica\Client', array('request')); + $clientMock = $this->getMock('\Elastica\Client', ['request']); $clientMock->expects($this->once()) ->method('request') - ->with('/_template/'.$name, Request::HEAD, array(), array()) + ->with('/_template/'.$name, Request::HEAD, [], []) ->willReturn($response); $indexTemplate = new IndexTemplate($clientMock, $name); $this->assertTrue($indexTemplate->exists()); @@ -96,12 +95,12 @@ public function testExists() */ public function testCreateTemplate() { - $template = array( + $template = [ 'template' => 'te*', - 'settings' => array( + 'settings' => [ 'number_of_shards' => 1, - ), - ); + ], + ]; $name = 'index_template1'; $indexTemplate = new IndexTemplate($this->_getClient(), $name); $indexTemplate->create($template); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php index e01042c..ba94ba8 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php @@ -1,5 +1,4 @@ _createIndex(); - $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))); + $doc = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => ['2', '3', '5']]); $type = $index->getType('test'); - $mapping = array('id' => array('type' => 'integer', 'store' => true), 'email' => array('type' => 'string', 'store' => 'no'), - 'username' => array('type' => 'string', 'store' => 'no'), 'test' => array('type' => 'integer', 'store' => 'no'), ); + $mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'string', 'store' => 'no'], + 'username' => ['type' => 'string', 'store' => 'no'], 'test' => ['type' => 'integer', 'store' => 'no'], ]; $type->setMapping($mapping); $type->addDocument($doc); @@ -56,9 +55,9 @@ public function testGetMappingAlias() $index->addAlias($aliasName); $type = new Type($index, 'test'); - $mapping = new Mapping($type, array( - 'id' => array('type' => 'integer', 'store' => 'yes'), - )); + $mapping = new Mapping($type, [ + 'id' => ['type' => 'integer', 'store' => 'yes'], + ]); $type->setMapping($mapping); $client = $index->getClient(); @@ -88,7 +87,7 @@ public function testParent() $typeComment = new Type($index, 'comment'); $mapping = new Mapping(); - $mapping->setParam('_parent', array('type' => 'blog')); + $mapping->setParam('_parent', ['type' => 'blog']); $typeComment->setMapping($mapping); $entry1 = new Document(1); @@ -113,7 +112,7 @@ public function testParent() $query = new HasChild('Max', 'comment'); $resultSet = $typeBlog->search($query); $this->assertEquals(1, $resultSet->count()); - $this->assertEquals(array('title' => 'Foo bar'), $resultSet->current()->getData()); + $this->assertEquals(['title' => 'Foo bar'], $resultSet->current()->getData()); } /** @@ -122,9 +121,9 @@ public function testParent() public function testAddPdfFile() { $this->_checkPlugin('elasticsearch-mapper-attachments'); - $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => false)); + $indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => false]]; - $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)); + $indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]]; $index = $this->_createIndex(); $type = new Type($index, 'test'); @@ -164,9 +163,9 @@ public function testAddPdfFile() public function testAddPdfFileContent() { $this->_checkPlugin('elasticsearch-mapper-attachments'); - $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => false)); + $indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => false]]; - $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)); + $indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]]; $index = $this->_createIndex(); $type = new Type($index, 'test'); @@ -206,9 +205,9 @@ public function testAddPdfFileContent() public function testAddWordxFile() { $this->_checkPlugin('elasticsearch-mapper-attachments'); - $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => 'no')); + $indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => 'no']]; - $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)); + $indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]]; $index = $this->_createIndex(); $type = new Type($index, 'content'); @@ -247,16 +246,16 @@ public function testAddWordxFile() public function testExcludeFileSource() { $this->_checkPlugin('elasticsearch-mapper-attachments'); - $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => true), - 'title' => array('type' => 'string', 'store' => true), ); + $indexMapping = ['file' => ['type' => 'attachment'], 'text' => ['type' => 'string', 'store' => true], + 'title' => ['type' => 'string', 'store' => true], ]; - $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)); + $indexParams = ['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]]; $index = $this->_createIndex(); $type = new Type($index, 'content'); $mapping = Mapping::create($indexMapping); - $mapping->setSource(array('excludes' => array('file'))); + $mapping->setSource(['excludes' => ['file']]); $mapping->setType($type); @@ -295,9 +294,9 @@ public function testAddRemoveAlias() $typeName = 'test'; $index = $client->getIndex($indexName1); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); - $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin')); + $doc = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin']); $type = $index->getType($typeName); $type->addDocument($doc); @@ -330,8 +329,8 @@ public function testCount() $index = $this->_createIndex(); // Add document to normal index - $doc1 = new Document(null, array('name' => 'ruflin')); - $doc2 = new Document(null, array('name' => 'nicolas')); + $doc1 = new Document(null, ['name' => 'ruflin']); + $doc2 = new Document(null, ['name' => 'nicolas']); $type = $index->getType('test'); $type->addDocument($doc1); @@ -358,11 +357,11 @@ public function testDeleteByQueryWithQueryString() $index = $this->_createIndex(); $type1 = new Type($index, 'test1'); - $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type1->addDocument(new Document(2, array('name' => 'ruflin'))); + $type1->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type1->addDocument(new Document(2, ['name' => 'ruflin'])); $type2 = new Type($index, 'test2'); - $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type2->addDocument(new Document(2, array('name' => 'ruflin'))); + $type2->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type2->addDocument(new Document(2, ['name' => 'ruflin'])); $index->refresh(); $response = $index->search('ruflin*'); @@ -394,11 +393,11 @@ public function testDeleteByQueryWithQuery() $index = $this->_createIndex(); $type1 = new Type($index, 'test1'); - $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type1->addDocument(new Document(2, array('name' => 'ruflin'))); + $type1->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type1->addDocument(new Document(2, ['name' => 'ruflin'])); $type2 = new Type($index, 'test2'); - $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type2->addDocument(new Document(2, array('name' => 'ruflin'))); + $type2->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type2->addDocument(new Document(2, ['name' => 'ruflin'])); $index->refresh(); $response = $index->search('ruflin*'); @@ -430,11 +429,11 @@ public function testDeleteByQueryWithArrayQuery() $index = $this->_createIndex(); $type1 = new Type($index, 'test1'); - $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type1->addDocument(new Document(2, array('name' => 'ruflin'))); + $type1->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type1->addDocument(new Document(2, ['name' => 'ruflin'])); $type2 = new Type($index, 'test2'); - $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type2->addDocument(new Document(2, array('name' => 'ruflin'))); + $type2->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type2->addDocument(new Document(2, ['name' => 'ruflin'])); $index->refresh(); $response = $index->search('ruflin*'); @@ -444,7 +443,7 @@ public function testDeleteByQueryWithArrayQuery() $this->assertEquals(2, $response->count()); // Delete first document - $response = $index->deleteByQuery(array('query' => array('query_string' => array('query' => 'nicolas')))); + $response = $index->deleteByQuery(['query' => ['query_string' => ['query' => 'nicolas']]]); $this->assertTrue($response->isOk()); $index->refresh(); @@ -471,11 +470,11 @@ public function testDeleteByQueryWithQueryAndOptions() for ($i = 1; $i <= 2; ++$i) { $type = new Type($index, 'test'.$i); - $doc = new Document(1, array('name' => 'ruflin nicolas')); + $doc = new Document(1, ['name' => 'ruflin nicolas']); $doc->setRouting($routing1); $type->addDocument($doc); - $doc = new Document(2, array('name' => 'ruflin')); + $doc = new Document(2, ['name' => 'ruflin']); $doc->setRouting($routing1); $type->addDocument($doc); } @@ -485,14 +484,14 @@ public function testDeleteByQueryWithQueryAndOptions() $response = $index->search('ruflin*'); $this->assertEquals(4, $response->count()); - $response = $index->search('ruflin*', array('routing' => $routing2)); + $response = $index->search('ruflin*', ['routing' => $routing2]); $this->assertEquals(0, $response->count()); $response = $index->search('nicolas'); $this->assertEquals(2, $response->count()); // Route to the wrong document id; should not delete - $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => $routing2)); + $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), ['routing' => $routing2]); $this->assertTrue($response->isOk()); $index->refresh(); @@ -504,7 +503,7 @@ public function testDeleteByQueryWithQueryAndOptions() $this->assertEquals(2, $response->count()); // Delete first document - $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => $routing1)); + $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), ['routing' => $routing1]); $this->assertTrue($response->isOk()); $index->refresh(); @@ -528,7 +527,7 @@ public function testDeleteIndexDeleteAlias() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $index->addAlias($aliasName); $status = new Status($client); @@ -556,10 +555,10 @@ public function testAddAliasTwoIndices() $index1 = $client->getIndex($indexName1); $index2 = $client->getIndex($indexName2); - $index1->create(array(), true); + $index1->create([], true); $this->_waitForAllocation($index1); $index1->addAlias($aliasName); - $index2->create(array(), true); + $index2->create([], true); $this->_waitForAllocation($index2); $index1->refresh(); @@ -594,9 +593,9 @@ public function testReplaceAlias() $index1 = $client->getIndex($indexName1); $index2 = $client->getIndex($indexName2); - $index1->create(array(), true); + $index1->create([], true); $index1->addAlias($aliasName); - $index2->create(array(), true); + $index2->create([], true); $index1->refresh(); $index2->refresh(); @@ -621,7 +620,7 @@ public function testAddDocumentVersion() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = new Type($index, 'test'); $doc1 = new Document(1); @@ -705,8 +704,8 @@ public function testIndexGetMapping() $index = $this->_createIndex(); $type = $index->getType('test'); - $mapping = array('id' => array('type' => 'integer', 'store' => true), 'email' => array('type' => 'string', 'store' => false), - 'username' => array('type' => 'string', 'store' => false), 'test' => array('type' => 'integer', 'store' => false), ); + $mapping = ['id' => ['type' => 'integer', 'store' => true], 'email' => ['type' => 'string', 'store' => false], + 'username' => ['type' => 'string', 'store' => false], 'test' => ['type' => 'integer', 'store' => false], ]; $type->setMapping($mapping); $index->refresh(); @@ -741,21 +740,21 @@ public function testLimitDefaultIndex() { $client = $this->_getClient(); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); - - $docs = array(); - - $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); + + $docs = []; + + $docs[] = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); $type = $index->getType('zeroType'); $type->addDocuments($docs); @@ -782,21 +781,21 @@ public function testCreateArray() //Testing recreate (backward compatibility) $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $status = new Status($client); $this->assertTrue($status->indexExists($indexName)); //Testing create index with array options - $opts = array('recreate' => true, 'routing' => 'r1,r2'); - $index->create(array(), $opts); + $opts = ['recreate' => true, 'routing' => 'r1,r2']; + $index->create([], $opts); $this->_waitForAllocation($index); $status = new Status($client); $this->assertTrue($status->indexExists($indexName)); //Testing invalid options - $opts = array('recreate' => true, 'routing' => 'r1,r2', 'testing_invalid_option' => true); - $index->create(array(), $opts); + $opts = ['recreate' => true, 'routing' => 'r1,r2', 'testing_invalid_option' => true]; + $index->create([], $opts); $this->_waitForAllocation($index); $status = new Status($client); $this->assertTrue($status->indexExists($indexName)); @@ -815,20 +814,20 @@ public function testCreateSearch() $search = $index->createSearch($query, $options); - $expected = array( - 'query' => array( - 'query_string' => array( + $expected = [ + 'query' => [ + 'query_string' => [ 'query' => 'test', - ), - ), + ], + ], 'size' => 5, - ); + ]; $this->assertEquals($expected, $search->getQuery()->toArray()); - $this->assertEquals(array('test'), $search->getIndices()); + $this->assertEquals(['test'], $search->getIndices()); $this->assertTrue($search->hasIndices()); $this->assertTrue($search->hasIndex('test')); $this->assertTrue($search->hasIndex($index)); - $this->assertEquals(array(), $search->getTypes()); + $this->assertEquals([], $search->getTypes()); $this->assertFalse($search->hasTypes()); $this->assertFalse($search->hasType('test_type')); @@ -845,10 +844,10 @@ public function testSearch() $type = new Type($index, 'user'); - $docs = array(); - $docs[] = new Document(1, array('username' => 'hans', 'test' => array('2', '3', '5'))); - $docs[] = new Document(2, array('username' => 'john', 'test' => array('1', '3', '6'))); - $docs[] = new Document(3, array('username' => 'rolf', 'test' => array('2', '3', '7'))); + $docs = []; + $docs[] = new Document(1, ['username' => 'hans', 'test' => ['2', '3', '5']]); + $docs[] = new Document(2, ['username' => 'john', 'test' => ['1', '3', '6']]); + $docs[] = new Document(3, ['username' => 'rolf', 'test' => ['2', '3', '7']]); $type->addDocuments($docs); $index->refresh(); @@ -877,9 +876,9 @@ public function testOptimize() $type = new Type($index, 'optimize'); - $docs = array(); - $docs[] = new Document(1, array('foo' => 'bar')); - $docs[] = new Document(2, array('foo' => 'bar')); + $docs = []; + $docs[] = new Document(1, ['foo' => 'bar']); + $docs[] = new Document(2, ['foo' => 'bar']); $type->addDocuments($docs); $index->refresh(); @@ -892,7 +891,7 @@ public function testOptimize() $stats = $index->getStats()->getData(); $this->assertEquals(1, $stats['_all']['primaries']['docs']['deleted']); - $index->optimize(array('max_num_segments' => 1)); + $index->optimize(['max_num_segments' => 1]); $stats = $index->getStats()->getData(); $this->assertEquals(0, $stats['_all']['primaries']['docs']['deleted']); @@ -907,15 +906,15 @@ public function testAnalyze() $index->refresh(); $returnedTokens = $index->analyze('foo'); - $tokens = array( - array( + $tokens = [ + [ 'token' => 'foo', 'start_offset' => 0, 'end_offset' => 3, 'type' => '', 'position' => 0, - ), - ); + ], + ]; $this->assertEquals($tokens, $returnedTokens); } @@ -941,4 +940,22 @@ public function testConvertScalarsToString() $this->assertEquals('1', $index->getName()); $this->assertInternalType('string', $index->getName()); } + + /** + * @group functional + */ + public function testGetEmptyAliases() + { + $indexName = 'test-getaliases'; + + $client = $this->_getClient(); + $index = $client->getIndex($indexName); + + $index->create([], true); + $this->_waitForAllocation($index); + $index->refresh(); + $index->optimize(); + + $this->assertEquals([], $index->getAliases()); + } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFieldsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFieldsTest.php index 1214389..d0c8fc2 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFieldsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFieldsTest.php @@ -1,5 +1,4 @@ assertInstanceOf('Elastica\Script\ScriptFields', new LegacyScriptFields(array())); + $this->assertInstanceOf('Elastica\Script\ScriptFields', new LegacyScriptFields([])); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFileTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFileTest.php index a3cc504..2a865ba 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFileTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/LegacyScriptFileTest.php @@ -1,5 +1,4 @@ _getClient(array('log' => $logPath)); + $client = $this->_getClient(['log' => $logPath]); $this->assertEquals($logPath, $client->getConfig('log')); } @@ -42,7 +41,7 @@ public function testSetLogConfigPath() */ public function testSetLogConfigEnable() { - $client = $this->_getClient(array('log' => true)); + $client = $this->_getClient(['log' => true]); $this->assertTrue($client->getConfig('log')); } @@ -85,7 +84,7 @@ public function testGetLastMessage() */ public function testGetLastMessage2() { - $client = $this->_getClient(array('log' => true)); + $client = $this->_getClient(['log' => true]); $log = new Log($client); // Set log path temp path as otherwise test fails with output diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/MultiBuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/MultiBuilderTest.php new file mode 100644 index 0000000..085c70a --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/MultiBuilderTest.php @@ -0,0 +1,76 @@ +builder = $this->getMock('Elastica\\ResultSet\\BuilderInterface'); + $this->multiBuilder = new MultiBuilder($this->builder); + } + + public function testBuildEmptyMultiResultSet() + { + $this->builder->expects($this->never()) + ->method('buildResultSet'); + + $response = new Response([]); + $searches = []; + + $result = $this->multiBuilder->buildMultiResultSet($response, $searches); + + $this->assertInstanceOf('Elastica\\Multi\\ResultSet', $result); + } + + public function testBuildMultiResultSet() + { + $response = new Response([ + 'responses' => [ + [], + [], + ], + ]); + $searches = [ + $s1 = new Search($this->_getClient(), $this->builder), + $s2 = new Search($this->_getClient(), $this->builder), + ]; + $resultSet1 = new ResultSet(new Response([]), $s1->getQuery(), []); + $resultSet2 = new ResultSet(new Response([]), $s2->getQuery(), []); + + $this->builder->expects($this->exactly(2)) + ->method('buildResultSet') + ->withConsecutive( + [$this->isInstanceOf('Elastica\\Response'), $s1->getQuery()], + [$this->isInstanceOf('Elastica\\Response'), $s2->getQuery()] + ) + ->willReturnOnConsecutiveCalls($resultSet1, $resultSet2); + + $result = $this->multiBuilder->buildMultiResultSet($response, $searches); + + $this->assertInstanceOf('Elastica\\Multi\\ResultSet', $result); + $this->assertSame($resultSet1, $result[0]); + $this->assertSame($resultSet2, $result[1]); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php index 7d5a013..f1e8e12 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); - - $docs = array(); - $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'kate')); - $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'kate')); - $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); - $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); - $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); - $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); - $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); - $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); + + $docs = []; + $docs[] = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'kate']); + $docs[] = new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'kate']); + $docs[] = new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); + $docs[] = new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); + $docs[] = new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); + $docs[] = new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); + $docs[] = new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); + $docs[] = new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']); $type = $index->getType('zeroType'); $type->addDocuments($docs); $index->refresh(); @@ -65,7 +64,7 @@ public function testSetSearches() $search2 = new Search($client); $search3 = new Search($client); - $multiSearch->setSearches(array($search1, $search2, $search3)); + $multiSearch->setSearches([$search1, $search2, $search3]); $searches = $multiSearch->getSearches(); @@ -97,7 +96,7 @@ public function testSetSearchesByKeys() $search2 = new Search($client); $search3 = new Search($client); - $multiSearch->setSearches(array('search1' => $search1, 'search2' => $search2, $search3)); + $multiSearch->setSearches(['search1' => $search1, 'search2' => $search2, $search3]); $searches = $multiSearch->getSearches(); @@ -329,7 +328,7 @@ public function testSearchWithError() $searchBad = new Search($client); $searchBadQuery = new Range(); - $searchBadQuery->addField('bad', array('_id' => 0)); + $searchBadQuery->addField('bad', ['_id' => 0]); $searchBadQuery->setParam('_cache', true); $searchBad->setQuery($searchBadQuery); $searchBad->addIndex($index)->addType($type); @@ -378,7 +377,7 @@ public function testSearchWithErrorWithKeys() $searchBad = new Search($client); $searchBadQuery = new Range(); - $searchBadQuery->addField('bad', array('_id' => 0)); + $searchBadQuery->addField('bad', ['_id' => 0]); $searchBadQuery->setParam('_cache', true); $searchBad->setQuery($searchBadQuery); $searchBad->addIndex($index)->addType($type); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php index b8e8ef3..562a2c1 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php @@ -1,5 +1,4 @@ assertNull($info->get('os', 'mem', 'total')); // Load os infos - $info = new NodeInfo($node, array('os')); + $info = new NodeInfo($node, ['os']); $this->assertNotNull($info->get('os', 'name')); $this->assertNotNull($info->get('process', 'id')); @@ -62,7 +61,7 @@ public function testGetId() $client = $this->_getClient(); $nodes = $client->getCluster()->getNodes(); - $ids = array(); + $ids = []; foreach ($nodes as $node) { $id = $node->getInfo()->getId(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php index f0780a1..a6dc742 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php @@ -1,5 +1,4 @@ assertInstanceOf('Elastica\Param', $param); - $this->assertEquals(array($this->_getFilterName($param) => array()), $param->toArray()); + $this->assertEquals([$this->_getFilterName($param) => []], $param->toArray()); } /** @@ -24,11 +23,11 @@ public function testToArrayEmpty() public function testSetParams() { $param = new Param(); - $params = array('hello' => 'word', 'nicolas' => 'ruflin'); + $params = ['hello' => 'word', 'nicolas' => 'ruflin']; $param->setParams($params); $this->assertInstanceOf('Elastica\Param', $param); - $this->assertEquals(array($this->_getFilterName($param) => $params), $param->toArray()); + $this->assertEquals([$this->_getFilterName($param) => $params], $param->toArray()); } /** @@ -41,7 +40,7 @@ public function testSetGetParam() $key = 'name'; $value = 'nicolas ruflin'; - $params = array($key => $value); + $params = [$key => $value]; $param->setParam($key, $value); $this->assertEquals($params, $param->getParams()); @@ -60,8 +59,8 @@ public function testAddParam() $param->addParam($key, $value); - $this->assertEquals(array($key => array($value)), $param->getParams()); - $this->assertEquals(array($value), $param->getParam($key)); + $this->assertEquals([$key => [$value]], $param->getParams()); + $this->assertEquals([$value], $param->getParam($key)); } /** @@ -78,8 +77,8 @@ public function testAddParam2() $param->addParam($key, $value1); $param->addParam($key, $value2); - $this->assertEquals(array($key => array($value1, $value2)), $param->getParams()); - $this->assertEquals(array($value1, $value2), $param->getParam($key)); + $this->assertEquals([$key => [$value1, $value2]], $param->getParams()); + $this->assertEquals([$value1, $value2], $param->getParam($key)); } /** diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php index e6a1efd..eaf7832 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php @@ -1,5 +1,4 @@ 'value1')); + $query = new Term(['field1' => 'value1']); $response = $percolator->registerQuery($percolatorName, $query); $data = $response->getData(); - $expectedArray = array( + $expectedArray = [ '_type' => '.percolator', '_index' => $index->getName(), '_id' => $percolatorName, '_version' => 1, 'created' => true, - '_shards' => array( + '_shards' => [ 'total' => 1, 'successful' => 1, 'failed' => 0, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $data); @@ -56,7 +55,7 @@ public function testMatchDoc() $percolatorName = $index->getName(); - $query = new Term(array('name' => 'ruflin')); + $query = new Term(['name' => 'ruflin']); $response = $percolator->registerQuery($percolatorName, $query); $this->assertTrue($response->isOk()); @@ -97,8 +96,8 @@ public function testFilteredMatchDoc() // step one: register create index and setup the percolator query from the ES documentation. $index = $this->_createIndex(); $percolator = new Percolator($index); - $baseQuery = new Term(array('field1' => 'value1')); - $fields = array('color' => 'blue'); + $baseQuery = new Term(['field1' => 'value1']); + $fields = ['color' => 'blue']; $response = $percolator->registerQuery('kuku', $baseQuery, $fields); @@ -112,12 +111,12 @@ public function testFilteredMatchDoc() $doc = new Document(); $doc->set('field1', 'value1'); - $matches = $percolator->matchDoc($doc, new Term(array('color' => 'blue'))); + $matches = $percolator->matchDoc($doc, new Term(['color' => 'blue'])); $this->assertCount(1, $matches, 'No or too much registered query matched.'); $this->assertEquals('kuku', $matches[0]['_id'], 'A wrong registered query has matched.'); // step three: validate that using a different color, no registered query matches. - $matches = $percolator->matchDoc($doc, new Term(array('color' => 'green'))); + $matches = $percolator->matchDoc($doc, new Term(['color' => 'green'])); $this->assertCount(0, $matches, 'A registered query matched, although nothing should match at all.'); $index->delete(); @@ -133,8 +132,8 @@ public function testRegisterAndUnregisterPercolator() // step one: register create index and setup the percolator query from the ES documentation. $index = $this->_createIndex(); $percolator = new Percolator($index); - $baseQuery = new Term(array('field1' => 'value1')); - $fields = array('color' => 'blue'); + $baseQuery = new Term(['field1' => 'value1']); + $fields = ['color' => 'blue']; $response = $percolator->registerQuery('kuku', $baseQuery, $fields); @@ -148,12 +147,12 @@ public function testRegisterAndUnregisterPercolator() $doc = new Document(); $doc->set('field1', 'value1'); - $matches = $percolator->matchDoc($doc, new Term(array('color' => 'blue'))); + $matches = $percolator->matchDoc($doc, new Term(['color' => 'blue'])); $this->assertCount(1, $matches, 'No or too much registered query matched.'); $this->assertEquals('kuku', $matches[0]['_id'], 'A wrong registered query has matched.'); // step three: validate that using a different color, no registered query matches. - $matches = $percolator->matchDoc($doc, new Term(array('color' => 'green'))); + $matches = $percolator->matchDoc($doc, new Term(['color' => 'green'])); $this->assertCount(0, $matches, 'A registered query matched, although nothing should match at all.'); // unregister percolator query @@ -165,7 +164,7 @@ public function testRegisterAndUnregisterPercolator() // refreshing is required in order to ensure the query is really ready for execution. $index->refresh(); - $matches = $percolator->matchDoc($doc, new Term(array('color' => 'blue'))); + $matches = $percolator->matchDoc($doc, new Term(['color' => 'blue'])); $this->assertCount(0, $matches, 'Percolator query did not get deleted.'); $index->delete(); @@ -176,8 +175,8 @@ protected function _getDefaultPercolator($percolatorName = 'existingDoc') $index = $this->_createIndex(); $percolator = new Percolator($index); - $query = new Term(array('name' => 'foobar')); - $percolator->registerQuery($percolatorName, $query, array('field1' => array('tag1', 'tag2'))); + $query = new Term(['name' => 'foobar']); + $percolator->registerQuery($percolatorName, $query, ['field1' => ['tag1', 'tag2']]); return $percolator; } @@ -185,10 +184,10 @@ protected function _getDefaultPercolator($percolatorName = 'existingDoc') protected function _addDefaultDocuments($index, $type = 'testing') { $type = $index->getType('testing'); - $type->addDocuments(array( - new Document(1, array('name' => 'foobar')), - new Document(2, array('name' => 'barbaz')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'foobar']), + new Document(2, ['name' => 'barbaz']), + ]); $index->refresh(); return $type; @@ -219,7 +218,7 @@ public function testPercolateExistingDocWithPercolateFormatIds() $index = $percolator->getIndex(); $type = $this->_addDefaultDocuments($index); - $parameter = array('percolate_format' => 'ids'); + $parameter = ['percolate_format' => 'ids']; $matches = $percolator->matchExistingDoc(1, $type->getName(), null, $parameter); $this->assertCount(1, $matches); @@ -239,7 +238,7 @@ public function testPercolateExistingDocWithIdThatShouldBeUrlEncoded() // id with whitespace, should be urlencoded $id = 'foo bar 1'; - $type->addDocument(new Document($id, array('name' => 'foobar'))); + $type->addDocument(new Document($id, ['name' => 'foobar'])); $index->refresh(); $matches = $percolator->matchExistingDoc($id, $type->getName()); @@ -256,14 +255,14 @@ public function testPercolateWithAdditionalRequestBodyOptions() $index = $this->_createIndex(); $percolator = new Percolator($index); - $query = new Term(array('name' => 'foo')); - $response = $percolator->registerQuery('percotest', $query, array('field1' => array('tag1', 'tag2'))); + $query = new Term(['name' => 'foo']); + $response = $percolator->registerQuery('percotest', $query, ['field1' => ['tag1', 'tag2']]); $this->assertTrue($response->isOk()); $this->assertFalse($response->hasError()); - $query = new Term(array('name' => 'foo')); - $response = $percolator->registerQuery('percotest1', $query, array('field1' => array('tag2'))); + $query = new Term(['name' => 'foo']); + $response = $percolator->registerQuery('percotest1', $query, ['field1' => ['tag2']]); $this->assertTrue($response->isOk()); $this->assertFalse($response->hasError()); @@ -273,13 +272,13 @@ public function testPercolateWithAdditionalRequestBodyOptions() $index->refresh(); - $options = array( + $options = [ 'track_scores' => true, - 'sort' => array('_score' => 'desc'), + 'sort' => ['_score' => 'desc'], 'size' => 1, - ); + ]; - $matches = $percolator->matchDoc($doc1, new Term(array('field1' => 'tag2')), 'type', $options); + $matches = $percolator->matchDoc($doc1, new Term(['field1' => 'tag2']), 'type', $options); $this->assertCount(1, $matches); $this->assertEquals('percotest1', $matches[0]['_id']); @@ -294,19 +293,19 @@ public function testPercolateExistingDocWithAdditionalRequestBodyOptions() $percolatorName = 'existingDoc'; $percolator = $this->_getDefaultPercolator($percolatorName); - $query = new Term(array('name' => 'foobar')); - $percolator->registerQuery($percolatorName.'1', $query, array('field1' => array('tag2'))); + $query = new Term(['name' => 'foobar']); + $percolator->registerQuery($percolatorName.'1', $query, ['field1' => ['tag2']]); $index = $percolator->getIndex(); $type = $this->_addDefaultDocuments($index); - $options = array( + $options = [ 'track_scores' => true, - 'sort' => array('_score' => 'desc'), + 'sort' => ['_score' => 'desc'], 'size' => 1, - ); + ]; - $matches = $percolator->matchExistingDoc(1, $type->getName(), new Term(array('field1' => 'tag2')), $options); + $matches = $percolator->matchExistingDoc(1, $type->getName(), new Term(['field1' => 'tag2']), $options); $this->assertCount(1, $matches); $this->assertEquals('existingDoc1', $matches[0]['_id']); @@ -320,10 +319,10 @@ protected function _createIndex($name = null, $delete = true, $shards = 1) $type = $index->getType('.percolator'); $mapping = new Type\Mapping($type, - array( - 'name' => array('type' => 'string'), - 'field1' => array('type' => 'string'), - ) + [ + 'name' => ['type' => 'string'], + 'field1' => ['type' => 'string'], + ] ); $mapping->disableSource(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php index a960b6d..5891cb4 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php @@ -1,5 +1,4 @@ finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\BoolQuery::addFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -80,16 +79,16 @@ public function testToArray() $query->addFilter($filter1); $query->addFilter($filter2); - $expectedArray = array( - 'bool' => array( - 'must' => array($idsQuery1->toArray()), - 'should' => array($idsQuery3->toArray()), - 'filter' => array($filter1->toArray(), $filter2->toArray()), + $expectedArray = [ + 'bool' => [ + 'must' => [$idsQuery1->toArray()], + 'should' => [$idsQuery3->toArray()], + 'filter' => [$filter1->toArray(), $filter2->toArray()], 'minimum_number_should_match' => $minMatch, - 'must_not' => array($idsQuery2->toArray()), + 'must_not' => [$idsQuery2->toArray()], 'boost' => $boost, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -132,16 +131,16 @@ public function testToArrayWithLegacyFilter() $query->addFilter($filter2); $this->showDeprecated(); - $expectedArray = array( - 'bool' => array( - 'must' => array($idsQuery1->toArray()), - 'should' => array($idsQuery3->toArray()), - 'filter' => array($filter1->toArray(), $filter2->toArray()), + $expectedArray = [ + 'bool' => [ + 'must' => [$idsQuery1->toArray()], + 'should' => [$idsQuery3->toArray()], + 'filter' => [$filter1->toArray(), $filter2->toArray()], 'minimum_number_should_match' => $minMatch, - 'must_not' => array($idsQuery2->toArray()), + 'must_not' => [$idsQuery2->toArray()], 'boost' => $boost, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -176,48 +175,48 @@ public function testSearch() { $client = $this->_getClient(); $index = new Index($client, 'test'); - $index->create(array(), true); + $index->create([], true); $type = new Type($index, 'helloworld'); - $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans', 'test' => array('2', '4', '5'))); + $doc = new Document(1, ['id' => 1, 'email' => 'hans@test.com', 'username' => 'hans', 'test' => ['2', '4', '5']]); $type->addDocument($doc); - $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil', 'test' => array('1', '3', '6'))); + $doc = new Document(2, ['id' => 2, 'email' => 'emil@test.com', 'username' => 'emil', 'test' => ['1', '3', '6']]); $type->addDocument($doc); - $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth', 'test' => array('2', '3', '7'))); + $doc = new Document(3, ['id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth', 'test' => ['2', '3', '7']]); $type->addDocument($doc); - $doc = new Document(4, array('id' => 4, 'email' => 'john@test.com', 'username' => 'john', 'test' => array('2', '4', '8'))); + $doc = new Document(4, ['id' => 4, 'email' => 'john@test.com', 'username' => 'john', 'test' => ['2', '4', '8']]); $type->addDocument($doc); // Refresh index $index->refresh(); $boolQuery = new BoolQuery(); - $termQuery1 = new TermQuery(array('test' => '2')); + $termQuery1 = new TermQuery(['test' => '2']); $boolQuery->addMust($termQuery1); $resultSet = $type->search($boolQuery); $this->assertEquals(3, $resultSet->count()); - $termFilter = new Term(array('test' => '4')); + $termFilter = new Term(['test' => '4']); $boolQuery->addFilter($termFilter); $resultSet = $type->search($boolQuery); $this->assertEquals(2, $resultSet->count()); - $termQuery2 = new TermQuery(array('test' => '5')); + $termQuery2 = new TermQuery(['test' => '5']); $boolQuery->addMust($termQuery2); $resultSet = $type->search($boolQuery); $this->assertEquals(1, $resultSet->count()); - $termQuery3 = new TermQuery(array('username' => 'hans')); + $termQuery3 = new TermQuery(['username' => 'hans']); $boolQuery->addMust($termQuery3); $resultSet = $type->search($boolQuery); $this->assertEquals(1, $resultSet->count()); - $termQuery4 = new TermQuery(array('username' => 'emil')); + $termQuery4 = new TermQuery(['username' => 'emil']); $boolQuery->addMust($termQuery4); $resultSet = $type->search($boolQuery); @@ -231,31 +230,31 @@ public function testSearchWithLegacyFilter() { $client = $this->_getClient(); $index = new Index($client, 'test'); - $index->create(array(), true); + $index->create([], true); $type = new Type($index, 'helloworld'); - $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans', 'test' => array('2', '4', '5'))); + $doc = new Document(1, ['id' => 1, 'email' => 'hans@test.com', 'username' => 'hans', 'test' => ['2', '4', '5']]); $type->addDocument($doc); - $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil', 'test' => array('1', '3', '6'))); + $doc = new Document(2, ['id' => 2, 'email' => 'emil@test.com', 'username' => 'emil', 'test' => ['1', '3', '6']]); $type->addDocument($doc); - $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth', 'test' => array('2', '3', '7'))); + $doc = new Document(3, ['id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth', 'test' => ['2', '3', '7']]); $type->addDocument($doc); - $doc = new Document(4, array('id' => 4, 'email' => 'john@test.com', 'username' => 'john', 'test' => array('2', '4', '8'))); + $doc = new Document(4, ['id' => 4, 'email' => 'john@test.com', 'username' => 'john', 'test' => ['2', '4', '8']]); $type->addDocument($doc); // Refresh index $index->refresh(); $boolQuery = new BoolQuery(); - $termQuery1 = new TermQuery(array('test' => '2')); + $termQuery1 = new TermQuery(['test' => '2']); $boolQuery->addMust($termQuery1); $resultSet = $type->search($boolQuery); $this->assertEquals(3, $resultSet->count()); $this->hideDeprecated(); - $termFilter = new TermFilter(array('test' => '4')); + $termFilter = new TermFilter(['test' => '4']); $boolQuery->addFilter($termFilter); $this->showDeprecated(); $resultSet = $type->search($boolQuery); @@ -273,7 +272,7 @@ public function testEmptyBoolQuery() $docNumber = 3; for ($i = 0; $i < $docNumber; ++$i) { - $doc = new Document($i, array('email' => 'test@test.com')); + $doc = new Document($i, ['email' => 'test@test.com']); $type->addDocument($doc); } @@ -300,7 +299,7 @@ public function testOldObject() $docNumber = 3; for ($i = 0; $i < $docNumber; ++$i) { - $doc = new Document($i, array('email' => 'test@test.com')); + $doc = new Document($i, ['email' => 'test@test.com']); $type->addDocument($doc); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php index bea97db..c6f4340 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php @@ -1,5 +1,4 @@ 'Vital Lama', 'price' => 5.2), - array('name' => 'Vital Match', 'price' => 2.1), - array('name' => 'Mercury Vital', 'price' => 7.5), - array('name' => 'Fist Mercury', 'price' => 3.8), - array('name' => 'Lama Vital 2nd', 'price' => 3.2), - ); + protected $sampleData = [ + ['name' => 'Vital Lama', 'price' => 5.2], + ['name' => 'Vital Match', 'price' => 2.1], + ['name' => 'Mercury Vital', 'price' => 7.5], + ['name' => 'Fist Mercury', 'price' => 3.8], + ['name' => 'Lama Vital 2nd', 'price' => 3.2], + ]; protected function _getTestIndex() { $index = $this->_createIndex(); $type = $index->getType('test'); - $type->setMapping(array( - 'name' => array('type' => 'string', 'index' => 'analyzed'), - 'price' => array('type' => 'float'), - )); - $docs = array(); + $type->setMapping([ + 'name' => ['type' => 'string', 'index' => 'analyzed'], + 'price' => ['type' => 'float'], + ]); + $docs = []; foreach ($this->sampleData as $key => $value) { $docs[] = new Document($key, $value); } @@ -48,19 +47,19 @@ public function testToArray() $negativeKeyword = 'Mercury'; $query = new Boosting(); - $positiveQuery = new Term(array('name' => $keyword)); - $negativeQuery = new Term(array('name' => $negativeKeyword)); + $positiveQuery = new Term(['name' => $keyword]); + $negativeQuery = new Term(['name' => $negativeKeyword]); $query->setPositiveQuery($positiveQuery); $query->setNegativeQuery($negativeQuery); $query->setNegativeBoost(0.3); - $expected = array( - 'boosting' => array( + $expected = [ + 'boosting' => [ 'positive' => $positiveQuery->toArray(), 'negative' => $negativeQuery->toArray(), 'negative_boost' => 0.3, - ), - ); + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -73,8 +72,8 @@ public function testNegativeBoost() $negativeKeyword = 'mercury'; $query = new Boosting(); - $positiveQuery = new Term(array('name' => $keyword)); - $negativeQuery = new Term(array('name' => $negativeKeyword)); + $positiveQuery = new Term(['name' => $keyword]); + $negativeQuery = new Term(['name' => $negativeKeyword]); $query->setPositiveQuery($positiveQuery); $query->setNegativeQuery($negativeQuery); $query->setNegativeBoost(0.2); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php index f87a604..3fdb527 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php @@ -1,5 +1,4 @@ assertSame($builder, $builder->sortFields(array('field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc'))); + $this->assertSame($builder, $builder->sortFields(['field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc'])); $this->assertSame('{"sort":[{"field1":"asc"},{"field2":"desc"},{"field3":"asc"}]}', (string) $builder); } @@ -214,7 +213,7 @@ public function testSortFields() */ public function testQueries() { - $queries = array(); + $queries = []; $builder = new Builder(); $b1 = clone $builder; @@ -229,13 +228,13 @@ public function testQueries() public function getFieldData() { - return array( - array('name', 'value', '{"name":"value"}'), - array('name', true, '{"name":"true"}'), - array('name', false, '{"name":"false"}'), - array('name', array(1, 2, 3), '{"name":["1","2","3"]}'), - array('name', array('foo', 'bar', 'baz'), '{"name":["foo","bar","baz"]}'), - ); + return [ + ['name', 'value', '{"name":"value"}'], + ['name', true, '{"name":"true"}'], + ['name', false, '{"name":"false"}'], + ['name', [1, 2, 3], '{"name":["1","2","3"]}'], + ['name', ['foo', 'bar', 'baz'], '{"name":["foo","bar","baz"]}'], + ]; } /** @@ -270,14 +269,14 @@ public function testToArrayWithInvalidData() public function testToArray() { $builder = new Builder(); - $builder->query()->term()->field('category.id', array(1, 2, 3))->termClose()->queryClose(); - $expected = array( - 'query' => array( - 'term' => array( - 'category.id' => array(1, 2, 3), - ), - ), - ); + $builder->query()->term()->field('category.id', [1, 2, 3])->termClose()->queryClose(); + $expected = [ + 'query' => [ + 'term' => [ + 'category.id' => [1, 2, 3], + ], + ], + ]; $this->assertEquals($expected, $builder->toArray()); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php index eaf5a60..659db95 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php @@ -1,5 +1,4 @@ setLowFrequencyOperator(Common::OPERATOR_AND); - $expected = array( - 'common' => array( - 'body' => array( + $expected = [ + 'common' => [ + 'body' => [ 'query' => 'test query', 'cutoff_frequency' => .001, 'low_freq_operator' => 'and', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -37,14 +36,14 @@ public function testQuery() $index = $this->_createIndex(); $type = $index->getType('test'); - $docs = array( - new Document(1, array('body' => 'foo baz')), - new Document(2, array('body' => 'foo bar baz')), - new Document(3, array('body' => 'foo bar baz bat')), - ); + $docs = [ + new Document(1, ['body' => 'foo baz']), + new Document(2, ['body' => 'foo bar baz']), + new Document(3, ['body' => 'foo bar baz bat']), + ]; //add documents to create common terms for ($i = 4; $i < 24; ++$i) { - $docs[] = new Document($i, array('body' => 'foo bar')); + $docs[] = new Document($i, ['body' => 'foo bar']); } $type->addDocuments($docs); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php index 6f8a80c..4e4d82d 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php @@ -1,5 +1,4 @@ assertSame($query->getParam('filter'), array('test')); + $query = new ConstantScore(['test']); + $this->assertSame($query->getParam('filter'), ['test']); } /** @@ -45,10 +44,10 @@ public function testConstructWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\ConstantScore passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\ConstantScore::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -78,52 +77,52 @@ public function testSetFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\ConstantScore::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } public function dataProviderSampleQueries() { - return array( - array( - new \Elastica\Query\Term(array('foo', 'bar')), - array( - 'constant_score' => array( - 'filter' => array( - 'term' => array( + return [ + [ + new \Elastica\Query\Term(['foo', 'bar']), + [ + 'constant_score' => [ + 'filter' => [ + 'term' => [ 'foo', 'bar', - ), - ), - ), - ), - ), - array( - array( - 'and' => array( - array( - 'query' => array( - 'query_string' => array( + ], + ], + ], + ], + ], + [ + [ + 'and' => [ + [ + 'query' => [ + 'query_string' => [ 'query' => 'foo', 'default_field' => 'something', - ), - ), - ), - array( - 'query' => array( - 'query_string' => array( + ], + ], + ], + [ + 'query' => [ + 'query_string' => [ 'query' => 'bar', 'default_field' => 'something', - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], '{"constant_score":{"filter":{"and":[{"query":{"query_string":{"query":"foo","default_field":"something"}}},{"query":{"query_string":{"query":"bar","default_field":"something"}}}]}}}', - ), - ); + ], + ]; } /** @@ -145,24 +144,24 @@ public function testSimple($filter, $expected) public function dataProviderSampleQueriesWithLegacyFilter() { $this->hideDeprecated(); - $legacyFilter = new Term(array('foo', 'bar')); + $legacyFilter = new Term(['foo', 'bar']); $this->showDeprecated(); - return array( - array( + return [ + [ $legacyFilter, - array( - 'constant_score' => array( - 'filter' => array( - 'term' => array( + [ + 'constant_score' => [ + 'filter' => [ + 'term' => [ 'foo', 'bar', - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; } /** @@ -191,16 +190,16 @@ public function testToArray() $boost = 1.2; $filter = new \Elastica\Query\Ids(); - $filter->setIds(array(1)); + $filter->setIds([1]); $query->setFilter($filter); $query->setBoost($boost); - $expectedArray = array( - 'constant_score' => array( + $expectedArray = [ + 'constant_score' => [ 'filter' => $filter->toArray(), 'boost' => $boost, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -215,17 +214,17 @@ public function testToArrayWithLegacyFilter() $boost = 1.2; $this->hideDeprecated(); $filter = new Ids(); - $filter->setIds(array(1)); + $filter->setIds([1]); $query->setFilter($filter); $this->showDeprecated(); $query->setBoost($boost); - $expectedArray = array( - 'constant_score' => array( + $expectedArray = [ + 'constant_score' => [ 'filter' => $filter->toArray(), 'boost' => $boost, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -236,15 +235,15 @@ public function testToArrayWithLegacyFilter() public function testConstruct() { $filter = new \Elastica\Query\Ids(); - $filter->setIds(array(1)); + $filter->setIds([1]); $query = new ConstantScore($filter); - $expectedArray = array( - 'constant_score' => array( + $expectedArray = [ + 'constant_score' => [ 'filter' => $filter->toArray(), - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -255,17 +254,17 @@ public function testConstruct() public function testConstructWithLegacyFilter() { $filter = new Ids(); - $filter->setIds(array(1)); + $filter->setIds([1]); $this->hideDeprecated(); $query = new ConstantScore($filter); $this->showDeprecated(); - $expectedArray = array( - 'constant_score' => array( + $expectedArray = [ + 'constant_score' => [ 'filter' => $filter->toArray(), - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -278,11 +277,11 @@ public function testQuery() $index = $this->_createIndex(); $type = $index->getType('constant_score'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans')), - new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil')), - new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth')), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'hans@test.com', 'username' => 'hans']), + new Document(2, ['id' => 2, 'email' => 'emil@test.com', 'username' => 'emil']), + new Document(3, ['id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth']), + ]); // Refresh index $index->refresh(); @@ -294,12 +293,12 @@ public function testQuery() $query->setQuery($query_match); $query->setBoost($boost); - $expectedArray = array( - 'constant_score' => array( + $expectedArray = [ + 'constant_score' => [ 'query' => $query_match->toArray(), 'boost' => $boost, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); $resultSet = $type->search($query); @@ -316,7 +315,7 @@ public function testQuery() public function testConstructEmpty() { $query = new ConstantScore(); - $expectedArray = array('constant_score' => array()); + $expectedArray = ['constant_score' => []]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php index 4de6d59..356b574 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php @@ -1,5 +1,4 @@ addQuery($idsQuery2); $query->addQuery($idsQuery3->toArray()); - $expectedArray = array( - 'dis_max' => array( + $expectedArray = [ + 'dis_max' => [ 'tie_breaker' => $tieBreaker, 'boost' => $boost, - 'queries' => array( + 'queries' => [ $idsQuery1->toArray(), $idsQuery2->toArray(), $idsQuery3->toArray(), - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -58,12 +57,12 @@ public function testQuery() $index = $this->_createIndex(); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php index 5c3bb91..50b822f 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php @@ -1,5 +1,4 @@ 'test@test.com', 'username' => 'test 7/6 123', 'test' => array('2', '3', '5'), ) + $doc = new Document(1, [ + 'email' => 'test@test.com', 'username' => 'test 7/6 123', 'test' => ['2', '3', '5'], ] ); $type->addDocument($doc); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ExistsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ExistsTest.php index 580371d..7ceb686 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ExistsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ExistsTest.php @@ -1,5 +1,4 @@ array('field' => $field)); + $expectedArray = ['exists' => ['field' => $field]]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php index 553b675..9120c15 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php @@ -1,5 +1,4 @@ finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\Filtered passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\Filtered::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -80,9 +79,9 @@ public function testSetFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\Filtered::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -94,10 +93,10 @@ public function testFilteredSearch() $index = $this->_createIndex(); $type = $index->getType('helloworld'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))), - new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => ['2', '3', '5']]), + new Document(2, ['id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => ['2', '3', '5']]), + ]); $index->refresh(); @@ -162,10 +161,10 @@ public function testFilteredSearchNoQuery() $index = $this->_createIndex(); $type = $index->getType('helloworld'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))), - new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => ['2', '3', '5']]), + new Document(2, ['id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => ['2', '3', '5']]), + ]); $index->refresh(); @@ -186,9 +185,9 @@ public function testFilteredSearchNoFilter() $index = $this->_createIndex(); $type = $index->getType('helloworld'); - $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))); + $doc = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => ['2', '3', '5']]); $type->addDocument($doc); - $doc = new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))); + $doc = new Document(2, ['id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => ['2', '3', '5']]); $type->addDocument($doc); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php index 7943354..2aaa383 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(array( - 'name' => array('type' => 'string', 'index' => 'not_analyzed'), - 'location' => array('type' => 'geo_point'), - 'price' => array('type' => 'float'), - 'popularity' => array('type' => 'integer'), - )); + $type->setMapping([ + 'name' => ['type' => 'string', 'index' => 'not_analyzed'], + 'location' => ['type' => 'geo_point'], + 'price' => ['type' => 'float'], + 'popularity' => ['type' => 'integer'], + ]); - $type->addDocuments(array( - new Document(1, array( + $type->addDocuments([ + new Document(1, [ 'name' => "Mr. Frostie's", - 'location' => array('lat' => 32.799605, 'lon' => -117.243027), + 'location' => ['lat' => 32.799605, 'lon' => -117.243027], 'price' => 4.5, 'popularity' => null, - )), - new Document(2, array( + ]), + new Document(2, [ 'name' => "Miller's Field", - 'location' => array('lat' => 32.795964, 'lon' => -117.255028), + 'location' => ['lat' => 32.795964, 'lon' => -117.255028], 'price' => 9.5, 'popularity' => 1, - )), - )); + ]), + ]); $index->refresh(); @@ -87,9 +86,9 @@ public function testAddFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -119,10 +118,10 @@ public function testAddDecayFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addDecayFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -152,10 +151,10 @@ public function testScriptScoreFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addScriptScoreFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -185,10 +184,10 @@ public function testAddFieldValueFactorFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addFieldValueFactorFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -218,12 +217,12 @@ public function testAddBoostFactorFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addBoostFactorFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Query\FunctionScore::addBoostFactorFunction is deprecated. Use addWeightFunction instead. This method will be removed in further Elastica releases', 'Deprecated: Elastica\Query\FunctionScore::addWeightFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -253,10 +252,10 @@ public function testAddWeightFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addWeightFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -286,10 +285,10 @@ public function testAddRandomScoreFunctionWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\FunctionScore::addRandomScoreFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\FunctionScore::addFunction passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -306,29 +305,29 @@ public function testToArray() $query->setQuery($childQuery); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, $locationScale); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale); - $expected = array( - 'function_score' => array( + $expected = [ + 'function_score' => [ 'query' => $childQuery->toArray(), - 'functions' => array( - array( - 'gauss' => array( - 'location' => array( + 'functions' => [ + [ + 'gauss' => [ + 'location' => [ 'origin' => $this->locationOrigin, 'scale' => $locationScale, - ), - ), - ), - array( - 'gauss' => array( - 'price' => array( + ], + ], + ], + [ + 'gauss' => [ + 'price' => [ 'origin' => $priceOrigin, 'scale' => $priceScale, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -353,31 +352,31 @@ public function testDecayWeight() .5 ); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale, null, null, 2); - $expected = array( - 'function_score' => array( + $expected = [ + 'function_score' => [ 'query' => $childQuery->toArray(), - 'functions' => array( - array( - 'gauss' => array( - 'location' => array( + 'functions' => [ + [ + 'gauss' => [ + 'location' => [ 'origin' => $this->locationOrigin, 'scale' => $locationScale, - ), - ), + ], + ], 'weight' => .5, - ), - array( - 'gauss' => array( - 'price' => array( + ], + [ + 'gauss' => [ + 'price' => [ 'origin' => $priceOrigin, 'scale' => $priceScale, - ), - ), + ], + ], 'weight' => 2, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -402,11 +401,11 @@ public function testGauss() */ public function testAddBoostFactorFunction() { - $filter = new \Elastica\Query\Term(array('price' => 4.5)); + $filter = new \Elastica\Query\Term(['price' => 4.5]); $query = new FunctionScore(); $query->addWeightFunction(5.0, $filter); - $sameFilter = new \Elastica\Query\Term(array('price' => 4.5)); + $sameFilter = new \Elastica\Query\Term(['price' => 4.5]); $sameQuery = new FunctionScore(); $this->hideDeprecated(); $sameQuery->addBoostFactorFunction(5.0, $sameFilter); @@ -422,13 +421,13 @@ public function testLegacyFilterAddBoostFactorFunction() { $query = new FunctionScore(); $this->hideDeprecated(); - $filter = new Term(array('price' => 4.5)); + $filter = new Term(['price' => 4.5]); $query->addWeightFunction(5.0, $filter); $this->showDeprecated(); $sameQuery = new FunctionScore(); $this->hideDeprecated(); - $sameFilter = new Term(array('price' => 4.5)); + $sameFilter = new Term(['price' => 4.5]); $sameQuery->addBoostFactorFunction(5.0, $sameFilter); $this->showDeprecated(); @@ -440,24 +439,24 @@ public function testLegacyFilterAddBoostFactorFunction() */ public function testWeight() { - $filter = new \Elastica\Query\Term(array('price' => 4.5)); + $filter = new \Elastica\Query\Term(['price' => 4.5]); $query = new FunctionScore(); $query->addWeightFunction(5.0, $filter); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ 'weight' => 5.0, - 'filter' => array( - 'term' => array( + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); @@ -475,25 +474,25 @@ public function testWeight() public function testWeightWithLegacyFilter() { $this->hideDeprecated(); - $filter = new Term(array('price' => 4.5)); + $filter = new Term(['price' => 4.5]); $query = new FunctionScore(); $query->addWeightFunction(5.0, $filter); $this->showDeprecated(); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ 'weight' => 5.0, - 'filter' => array( - 'term' => array( + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); @@ -510,26 +509,26 @@ public function testWeightWithLegacyFilter() */ public function testRandomScore() { - $filter = new \Elastica\Query\Term(array('price' => 4.5)); + $filter = new \Elastica\Query\Term(['price' => 4.5]); $query = new FunctionScore(); $query->addRandomScoreFunction(2, $filter); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'random_score' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'random_score' => [ 'seed' => 2, - ), - 'filter' => array( - 'term' => array( + ], + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); @@ -548,27 +547,27 @@ public function testRandomScore() public function testRandomScoreWithLegacyFilter() { $this->hideDeprecated(); - $filter = new Term(array('price' => 4.5)); + $filter = new Term(['price' => 4.5]); $query = new FunctionScore(); $query->addRandomScoreFunction(2, $filter); $this->showDeprecated(); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'random_score' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'random_score' => [ 'seed' => 2, - ), - 'filter' => array( - 'term' => array( + ], + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); @@ -586,27 +585,27 @@ public function testRandomScoreWithLegacyFilter() */ public function testRandomScoreWeight() { - $filter = new \Elastica\Query\Term(array('price' => 4.5)); + $filter = new \Elastica\Query\Term(['price' => 4.5]); $query = new FunctionScore(); $query->addRandomScoreFunction(2, $filter, 2); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'random_score' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'random_score' => [ 'seed' => 2, - ), - 'filter' => array( - 'term' => array( + ], + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), + ], + ], 'weight' => 2, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -617,28 +616,28 @@ public function testRandomScoreWeight() public function testRandomScoreWeightWithLegacyFilter() { $this->hideDeprecated(); - $filter = new Term(array('price' => 4.5)); + $filter = new Term(['price' => 4.5]); $query = new FunctionScore(); $query->addRandomScoreFunction(2, $filter, 2); $this->showDeprecated(); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'random_score' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'random_score' => [ 'seed' => 2, - ), - 'filter' => array( - 'term' => array( + ], + 'filter' => [ + 'term' => [ 'price' => 4.5, - ), - ), + ], + ], 'weight' => 2, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -666,17 +665,17 @@ public function testScriptScore() $script = new Script($scriptString); $query = new FunctionScore(); $query->addScriptScoreFunction($script); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'script_score' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'script_score' => [ 'script' => $scriptString, - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; $this->assertEquals($expected, $query->toArray()); @@ -695,21 +694,21 @@ public function testSetMinScore() { $this->_checkVersion('1.5'); - $expected = array( - 'function_score' => array( + $expected = [ + 'function_score' => [ 'min_score' => 0.8, - 'functions' => array( - array( - 'gauss' => array( - 'price' => array( + 'functions' => [ + [ + 'gauss' => [ + 'price' => [ 'origin' => 0, 'scale' => 10, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $query = new FunctionScore(); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10); @@ -732,20 +731,20 @@ public function testFieldValueFactor() { $this->_checkVersion('1.6'); - $expected = array( - 'function_score' => array( - 'functions' => array( - array( - 'field_value_factor' => array( + $expected = [ + 'function_score' => [ + 'functions' => [ + [ + 'field_value_factor' => [ 'field' => 'popularity', 'factor' => 1.2, 'modifier' => 'sqrt', 'missing' => 0.1, // available from >=1.6 - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; $query = new FunctionScore(); $query->addFieldValueFactorFunction('popularity', 1.2, FunctionScore::FIELD_VALUE_FACTOR_MODIFIER_SQRT, 0.1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php index dfbe185..3ce3ced 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php @@ -1,5 +1,4 @@ hideDeprecated(); - $fuzzy->addField('user', array('value' => 'Nicolas', 'boost' => 1.0)); + $fuzzy->addField('user', ['value' => 'Nicolas', 'boost' => 1.0]); $this->showDeprecated(); $sameFuzzy = new Fuzzy(); @@ -36,36 +35,36 @@ public function testToArray() $fuzzy->setField('user', 'Nicolas'); $fuzzy->setFieldOption('boost', 1.0); - $expectedArray = array( - 'fuzzy' => array( - 'user' => array( + $expectedArray = [ + 'fuzzy' => [ + 'user' => [ 'value' => 'Nicolas', 'boost' => 1.0, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $fuzzy->toArray(), 'Deprecated method failed'); $fuzzy = new Fuzzy('user', 'Nicolas'); - $expectedArray = array( - 'fuzzy' => array( - 'user' => array( + $expectedArray = [ + 'fuzzy' => [ + 'user' => [ 'value' => 'Nicolas', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $fuzzy->toArray()); $fuzzy = new Fuzzy(); $fuzzy->setField('user', 'Nicolas')->setFieldOption('boost', 1.0); - $expectedArray = array( - 'fuzzy' => array( - 'user' => array( + $expectedArray = [ + 'fuzzy' => [ + 'user' => [ 'value' => 'Nicolas', 'boost' => 1.0, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $fuzzy->toArray()); } @@ -76,15 +75,15 @@ public function testQuery() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + ]); $index->refresh(); @@ -107,12 +106,12 @@ public function testBadArguments() $query = new Fuzzy(); $this->hideDeprecated(); - $query->addField('name', array(array('value' => 'Baden'))); + $query->addField('name', [['value' => 'Baden']]); $this->showDeprecated(); $this->setExpectedException('Elastica\Exception\InvalidException'); $query = new Fuzzy(); - $query->setField('name', array()); + $query->setField('name', []); $this->setExpectedException('Elastica\Exception\InvalidException'); $query = new Fuzzy(); @@ -127,7 +126,7 @@ public function testAddFieldDeprecated() { $query = new Fuzzy(); $errorCollector = $this->startCollectErrors(); - $query->addField('user', array('value' => 'Nicolas', 'boost' => 1.0)); + $query->addField('user', ['value' => 'Nicolas', 'boost' => 1.0]); $this->finishCollectErrors(); $errorCollector->assertOnlyOneDeprecatedError('Query\Fuzzy::addField is deprecated. Use setField and setFieldOption instead. This method will be removed in further Elastica releases'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoBoundingBoxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoBoundingBoxTest.php index b627b09..d5a93ac 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoBoundingBoxTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoBoundingBoxTest.php @@ -1,5 +1,4 @@ addCoordinates($key, $coords); - $expectedArray = array('top_left' => $coords[0], 'bottom_right' => $coords[1]); + $expectedArray = ['top_left' => $coords[0], 'bottom_right' => $coords[1]]; $this->assertEquals($expectedArray, $query->getParam($key)); $returnValue = $query->addCoordinates($key, $coords); @@ -30,7 +29,7 @@ public function testAddCoordinates() */ public function testAddCoordinatesInvalidException() { - $query = new GeoBoundingBox('foo', array()); + $query = new GeoBoundingBox('foo', []); } /** @@ -39,17 +38,17 @@ public function testAddCoordinatesInvalidException() public function testToArray() { $key = 'pin.location'; - $coords = array('40.73, -74.1', '40.01, -71.12'); + $coords = ['40.73, -74.1', '40.01, -71.12']; $query = new GeoBoundingBox($key, $coords); - $expectedArray = array( - 'geo_bounding_box' => array( - $key => array( + $expectedArray = [ + 'geo_bounding_box' => [ + $key => [ 'top_left' => $coords[0], 'bottom_right' => $coords[1], - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceRangeTest.php index ce769d7..b278fbd 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceRangeTest.php @@ -1,5 +1,4 @@ getType('test'); // Set mapping - $type->setMapping(array('point' => array('type' => 'geo_point'))); + $type->setMapping(['point' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('point', 17, 19); @@ -33,9 +32,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('point', 30, 40); @@ -48,8 +47,8 @@ public function testGeoPoint() $query = new Query(); $geoQuery = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('from' => '0km', 'to' => '2km') + ['lat' => 30, 'lon' => 40], + ['from' => '0km', 'to' => '2km'] ); $query = new Query(new MatchAll()); @@ -60,8 +59,8 @@ public function testGeoPoint() $query = new Query(); $geoQuery = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('gte' => '0km', 'lte' => '4000km') + ['lat' => 30, 'lon' => 40], + ['gte' => '0km', 'lte' => '4000km'] ); $query = new Query(new MatchAll()); $query->setPostFilter($geoQuery); @@ -78,8 +77,8 @@ public function testInvalidRange() { $geoQuery = new GeoDistanceRange( 'point', - array('lat' => 30, 'lon' => 40), - array('invalid' => '0km', 'lte' => '40000km') + ['lat' => 30, 'lon' => 40], + ['invalid' => '0km', 'lte' => '40000km'] ); } @@ -93,7 +92,7 @@ public function testInvalidLocation($location) $geoQuery = new GeoDistanceRange( 'point', $location, - array('gt' => '0km', 'lte' => '40000km') + ['gt' => '0km', 'lte' => '40000km'] ); } @@ -112,110 +111,110 @@ public function testConstruct($key, $location, $ranges, $expected) public function invalidLocationDataProvider() { - return array( - array( - array('lat' => 1.0), - ), - array( - array('lon' => 1.0), - ), - array( - array(), - ), - array( + return [ + [ + ['lat' => 1.0], + ], + [ + ['lon' => 1.0], + ], + [ + [], + ], + [ new \stdClass(), - ), - array( + ], + [ null, - ), - array( + ], + [ true, - ), - array( + ], + [ false, - ), - ); + ], + ]; } public function constructDataProvider() { - return array( - array( + return [ + [ 'location', 'u09tvqx', - array( + [ 'from' => '10km', 'to' => '20km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'from' => '10km', 'to' => '20km', 'location' => 'u09tvqx', - ), - ), - ), - array( + ], + ], + ], + [ 'location', 'u09tvqx', - array( + [ 'to' => '20km', 'include_upper' => 0, 'from' => '10km', 'include_lower' => 1, - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'to' => '20km', 'include_upper' => false, 'from' => '10km', 'include_lower' => true, 'location' => 'u09tvqx', - ), - ), - ), - array( + ], + ], + ], + [ 'location', - array( + [ 'lon' => 2.35, 'lat' => 48.86, - ), - array( + ], + [ 'lte' => '20km', 'gt' => '10km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'lte' => '20km', 'gt' => '10km', - 'location' => array( + 'location' => [ 'lat' => 48.86, 'lon' => 2.35, - ), - ), - ), - ), - array( + ], + ], + ], + ], + [ 'location', - array( + [ 'lat' => 48.86, 'lon' => 2.35, - ), - array( + ], + [ 'lt' => '20km', 'gte' => '10km', - ), - array( - 'geo_distance_range' => array( + ], + [ + 'geo_distance_range' => [ 'lt' => '20km', 'gte' => '10km', - 'location' => array( + 'location' => [ 'lat' => 48.86, 'lon' => 2.35, - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceTest.php index be6ac62..fe70dcc 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoDistanceTest.php @@ -1,5 +1,4 @@ getType('test'); // Set mapping - $type->setMapping(array('point' => array('type' => 'geo_point'))); + $type->setMapping(['point' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('point', 17, 19); @@ -34,9 +33,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('point', 30, 40); @@ -46,7 +45,7 @@ public function testGeoPoint() $index->refresh(); // Only one point should be in radius - $geoQuery = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '1km'); + $geoQuery = new GeoDistance('point', ['lat' => 30, 'lon' => 40], '1km'); $query = new Query(new MatchAll()); $query->setPostFilter($geoQuery); @@ -54,7 +53,7 @@ public function testGeoPoint() // Both points should be inside $query = new Query(); - $geoQuery = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '40000km'); + $geoQuery = new GeoDistance('point', ['lat' => 30, 'lon' => 40], '40000km'); $query = new Query(new MatchAll()); $query->setPostFilter($geoQuery); $index->refresh(); @@ -68,20 +67,20 @@ public function testGeoPoint() public function testConstructLatlon() { $key = 'location'; - $location = array( + $location = [ 'lat' => 48.86, 'lon' => 2.35, - ); + ]; $distance = '10km'; $query = new GeoDistance($key, $location, $distance); - $expected = array( - 'geo_distance' => array( + $expected = [ + 'geo_distance' => [ $key => $location, 'distance' => $distance, - ), - ); + ], + ]; $data = $query->toArray(); @@ -99,12 +98,12 @@ public function testConstructGeohash() $query = new GeoDistance($key, $location, $distance); - $expected = array( - 'geo_distance' => array( + $expected = [ + 'geo_distance' => [ $key => $location, 'distance' => $distance, - ), - ); + ], + ]; $data = $query->toArray(); @@ -116,7 +115,7 @@ public function testConstructGeohash() */ public function testSetDistanceType() { - $query = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km'); + $query = new GeoDistance('location', ['lat' => 48.86, 'lon' => 2.35], '10km'); $distanceType = GeoDistance::DISTANCE_TYPE_ARC; $query->setDistanceType($distanceType); @@ -130,7 +129,7 @@ public function testSetDistanceType() */ public function testSetOptimizeBbox() { - $query = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km'); + $query = new GeoDistance('location', ['lat' => 48.86, 'lon' => 2.35], '10km'); $optimizeBbox = GeoDistance::OPTIMIZE_BBOX_MEMORY; $query->setOptimizeBbox($optimizeBbox); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoPolygonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoPolygonTest.php index 01e38c9..271d452 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoPolygonTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoPolygonTest.php @@ -1,5 +1,4 @@ getType('test'); // Set mapping - $type->setMapping(array('location' => array('type' => 'geo_point'))); + $type->setMapping(['location' => ['type' => 'geo_point']]); // Add doc 1 $doc1 = new Document(1, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc1->addGeoPoint('location', 17, 19); @@ -34,9 +33,9 @@ public function testGeoPoint() // Add doc 2 $doc2 = new Document(2, - array( + [ 'name' => 'ruflin', - ) + ] ); $doc2->addGeoPoint('location', 30, 40); @@ -45,7 +44,7 @@ public function testGeoPoint() $index->refresh(); // Only one point should be in polygon - $points = array(array(16, 16), array(16, 20), array(20, 20), array(20, 16), array(16, 16)); + $points = [[16, 16], [16, 20], [20, 20], [20, 16], [16, 16]]; $geoQuery = new GeoPolygon('location', $points); $query = new Query(new MatchAll()); @@ -54,7 +53,7 @@ public function testGeoPoint() // Both points should be inside $query = new Query(); - $points = array(array(16, 16), array(16, 40), array(40, 40), array(40, 16), array(16, 16)); + $points = [[16, 16], [16, 40], [40, 40], [40, 16], [16, 16]]; $geoQuery = new GeoPolygon('location', $points); $query = new Query(new MatchAll()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapePreIndexedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapePreIndexedTest.php index b566282..3dea489 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapePreIndexedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapePreIndexedTest.php @@ -1,5 +1,4 @@ getType('other_type'); // create mapping - $mapping = new \Elastica\Type\Mapping($type, array( - 'location' => array( + $mapping = new \Elastica\Type\Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $type->setMapping($mapping); // create other type mapping - $otherMapping = new \Elastica\Type\Mapping($type, array( - 'location' => array( + $otherMapping = new \Elastica\Type\Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $otherType->setMapping($otherMapping); // add type docs - $type->addDocument(new \Elastica\Document('1', array( - 'location' => array( + $type->addDocument(new \Elastica\Document('1', [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(0.0, 50.0), - array(50.0, 0.0), - ), - ), - ))); + 'coordinates' => [ + [0.0, 50.0], + [50.0, 0.0], + ], + ], + ])); // add other type docs - $otherType->addDocument(new \Elastica\Document('2', array( - 'location' => array( + $otherType->addDocument(new \Elastica\Document('2', [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(25.0, 75.0), - array(75.0, 25.0), - ), - ), - ))); + 'coordinates' => [ + [25.0, 75.0], + [75.0, 25.0], + ], + ], + ])); $index->optimize(); $index->refresh(); @@ -65,19 +64,19 @@ public function testGeoProvided() ); $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'indexed_shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'indexed_shape' => [ 'id' => '1', 'type' => 'type', 'index' => $indexName, 'path' => 'location', - ), + ], 'relation' => $gsp->getRelation(), - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapeProvidedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapeProvidedTest.php index e72d37a..cf24f11 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapeProvidedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeoShapeProvidedTest.php @@ -1,5 +1,4 @@ getType('test'); // create mapping - $mapping = new Mapping($type, array( - 'location' => array( + $mapping = new Mapping($type, [ + 'location' => [ 'type' => 'geo_shape', - ), - )); + ], + ]); $type->setMapping($mapping); // add docs - $type->addDocument(new Document(1, array( - 'location' => array( + $type->addDocument(new Document(1, [ + 'location' => [ 'type' => 'envelope', - 'coordinates' => array( - array(-50.0, 50.0), - array(50.0, -50.0), - ), - ), - ))); + 'coordinates' => [ + [-50.0, 50.0], + [50.0, -50.0], + ], + ], + ])); $index->optimize(); $index->refresh(); - $envelope = array( - array(25.0, 75.0), - array(75.0, 25.0), - ); + $envelope = [ + [25.0, 75.0], + [75.0, 25.0], + ]; $gsp = new GeoShapeProvided('location', $envelope); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'shape' => [ 'type' => GeoShapeProvided::TYPE_ENVELOPE, 'coordinates' => $envelope, 'relation' => AbstractGeoShape::RELATION_INTERSECT, - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); @@ -73,20 +72,20 @@ public function testConstructEnvelope() */ public function testConstructPolygon() { - $polygon = array(array(102.0, 2.0), array(103.0, 2.0), array(103.0, 3.0), array(103.0, 3.0), array(102.0, 2.0)); + $polygon = [[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [103.0, 3.0], [102.0, 2.0]]; $gsp = new GeoShapeProvided('location', $polygon, GeoShapeProvided::TYPE_POLYGON); - $expected = array( - 'geo_shape' => array( - 'location' => array( - 'shape' => array( + $expected = [ + 'geo_shape' => [ + 'location' => [ + 'shape' => [ 'type' => GeoShapeProvided::TYPE_POLYGON, 'coordinates' => $polygon, 'relation' => $gsp->getRelation(), - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $gsp->toArray()); } @@ -96,7 +95,7 @@ public function testConstructPolygon() */ public function testSetRelation() { - $gsp = new GeoShapeProvided('location', array(array(25.0, 75.0), array(75.0, 25.0))); + $gsp = new GeoShapeProvided('location', [[25.0, 75.0], [75.0, 25.0]]); $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT); $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation()); $this->assertInstanceOf('Elastica\Query\GeoShapeProvided', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT)); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeohashCellTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeohashCellTest.php index 4c03989..6e1fc79 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeohashCellTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/GeohashCellTest.php @@ -1,5 +1,4 @@ 37.789018, 'lon' => -122.391506), '50m'); - $expected = array( - 'geohash_cell' => array( - 'pin' => array( + $query = new GeohashCell('pin', ['lat' => 37.789018, 'lon' => -122.391506], '50m'); + $expected = [ + 'geohash_cell' => [ + 'pin' => [ 'lat' => 37.789018, 'lon' => -122.391506, - ), + ], 'precision' => '50m', 'neighbors' => false, - ), - ); + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -36,20 +35,20 @@ public function testQuery() { $index = $this->_createIndex(); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'pin' => array( + $mapping = new Mapping($type, [ + 'pin' => [ 'type' => 'geo_point', 'geohash' => true, 'geohash_prefix' => true, - ), - )); + ], + ]); $type->setMapping($mapping); - $type->addDocument(new Document(1, array('pin' => '9q8yyzm0zpw8'))); - $type->addDocument(new Document(2, array('pin' => '9mudgb0yued0'))); + $type->addDocument(new Document(1, ['pin' => '9q8yyzm0zpw8'])); + $type->addDocument(new Document(2, ['pin' => '9mudgb0yued0'])); $index->refresh(); - $geoQuery = new GeohashCell('pin', array('lat' => 32.828326, 'lon' => -117.255854)); + $geoQuery = new GeohashCell('pin', ['lat' => 32.828326, 'lon' => -117.255854]); $query = new Query(); $query->setPostFilter($geoQuery); $results = $type->search($query); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php index 6de794a..ccbb535 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'has_child' => [ 'query' => $q->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -47,13 +46,13 @@ public function testSetScope() $query = new HasChild($q, $type); $query->setScope($scope); - $expectedArray = array( - 'has_child' => array( + $expectedArray = [ + 'has_child' => [ 'query' => $q->toArray(), 'type' => $type, '_scope' => $scope, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -76,7 +75,7 @@ public function testTypeInsideHasChildSearch() $this->assertEquals(1, $searchResults->count()); $result = $searchResults->current()->getData(); - $expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'); + $expected = ['id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com']; $this->assertEquals($expected, $result); } @@ -93,21 +92,21 @@ protected function _getTestIndex() $childMapping->send(); $altType = $index->getType('alt'); - $altDoc = new Document('alt1', array('name' => 'altname')); + $altDoc = new Document('alt1', ['name' => 'altname']); $altType->addDocument($altDoc); - $parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com')); + $parent1 = new Document('parent1', ['id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com']); $parentType->addDocument($parent1); - $parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com')); + $parent2 = new Document('parent2', ['id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com']); $parentType->addDocument($parent2); - $child1 = new Document('child1', array('id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com')); + $child1 = new Document('child1', ['id' => 'child1', 'user' => 'child1', 'email' => 'child1@test.com']); $child1->setParent('parent1'); $childType->addDocument($child1); - $child2 = new Document('child2', array('id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com')); + $child2 = new Document('child2', ['id' => 'child2', 'user' => 'child2', 'email' => 'child2@test.com']); $child2->setParent('parent2'); $childType->addDocument($child2); - $child3 = new Document('child3', array('id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => array(array('name' => 'testname')))); + $child3 = new Document('child3', ['id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => [['name' => 'testname']]]); $child3->setParent('parent2'); $childType->addDocument($child3); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php index a9d036e..6cbf118 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php @@ -1,5 +1,4 @@ array( + $expectedArray = [ + 'has_parent' => [ 'query' => $q->toArray(), 'type' => $type, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -47,13 +46,13 @@ public function testSetScope() $query = new HasParent($q, $type); $query->setScope($scope); - $expectedArray = array( - 'has_parent' => array( + $expectedArray = [ + 'has_parent' => [ 'query' => $q->toArray(), 'type' => $type, '_scope' => $scope, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -72,16 +71,16 @@ public function testHasParent() $productType->setMapping($mapping); $shopType->addDocuments( - array( - new Document('zurich', array('brand' => 'google')), - new Document('london', array('brand' => 'apple')), - ) + [ + new Document('zurich', ['brand' => 'google']), + new Document('london', ['brand' => 'apple']), + ] ); - $doc1 = new Document(1, array('device' => 'chromebook')); + $doc1 = new Document(1, ['device' => 'chromebook']); $doc1->setParent('zurich'); - $doc2 = new Document(2, array('device' => 'macmini')); + $doc2 = new Document(2, ['device' => 'macmini']); $doc2->setParent('london'); $productType->addDocument($doc1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php index 53c5ec0..46acc4a 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php @@ -1,5 +1,4 @@ addDocuments(array( - new Document(1, array('id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => array('2', '3', '5'))), - new Document(2, array('id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => array('2', '3', '5'))), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => ['2', '3', '5']]), + new Document(2, ['id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => ['2', '3', '5']]), + ]); $matchQuery = new Query\MatchPhrase('phrase', 'ruflin'); $query = new Query($matchQuery); - $query->setHighlight(array( - 'pre_tags' => array(''), - 'post_tags' => array(''), - 'fields' => array( - 'phrase' => array( + $query->setHighlight([ + 'pre_tags' => [''], + 'post_tags' => [''], + 'fields' => [ + 'phrase' => [ 'fragment_size' => 200, 'number_of_fragments' => 1, - ), - ), - )); + ], + ], + ]); $index->refresh(); @@ -42,7 +41,7 @@ public function testHightlightSearch() foreach ($resultSet as $result) { $highlight = $result->getHighlights(); - $this->assertEquals(array('phrase' => array(0 => 'My name is ruflin')), $highlight); + $this->assertEquals(['phrase' => [0 => 'My name is ruflin']], $highlight); } $this->assertEquals(2, $resultSet->count()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php index 909080c..c314bca 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php @@ -1,9 +1,9 @@ getType('helloworld1'); $type2 = $index->getType('helloworld2'); - $doc = new Document(1, array('name' => 'hello world')); + $doc = new Document(1, ['name' => 'hello world']); $type1->addDocument($doc); - $doc = new Document(2, array('name' => 'nicolas ruflin')); + $doc = new Document(2, ['name' => 'nicolas ruflin']); $type1->addDocument($doc); - $doc = new Document(3, array('name' => 'ruflin')); + $doc = new Document(3, ['name' => 'ruflin']); $type1->addDocument($doc); - $doc = new Document(4, array('name' => 'hello world again')); + $doc = new Document(4, ['name' => 'hello world again']); $type2->addDocument($doc); $index->refresh(); @@ -57,7 +57,7 @@ public function testSetIdsSearchSingle() public function testSetIdsSearchArray() { $query = new Ids(); - $query->setIds(array('1', '2')); + $query->setIds(['1', '2']); $resultSet = $this->_type->search($query); @@ -84,7 +84,7 @@ public function testComboIdsSearchArray() { $query = new Ids(); - $query->setIds(array('1', '2')); + $query->setIds(['1', '2']); $query->addId('3'); $resultSet = $this->_type->search($query); @@ -114,7 +114,7 @@ public function testSetTypeSingleSearchArray() { $query = new Ids(); - $query->setIds(array('1', '2')); + $query->setIds(['1', '2']); $query->setType('helloworld1'); $resultSet = $this->_index->search($query); @@ -147,7 +147,7 @@ public function testSetTypeSingleSearchArrayDocInOtherType() $query = new Ids(); // Doc 4 is in the second type... - $query->setIds(array('1', '4')); + $query->setIds(['1', '4']); $query->setType('helloworld1'); $resultSet = $this->_index->search($query); @@ -163,8 +163,8 @@ public function testSetTypeArraySearchArray() { $query = new Ids(); - $query->setIds(array('1', '4')); - $query->setType(array('helloworld1', 'helloworld2')); + $query->setIds(['1', '4']); + $query->setType(['helloworld1', 'helloworld2']); $resultSet = $this->_index->search($query); @@ -179,10 +179,23 @@ public function testSetTypeArraySearchSingle() $query = new Ids(); $query->setIds('4'); - $query->setType(array('helloworld1', 'helloworld2')); + $query->setType(['helloworld1', 'helloworld2']); $resultSet = $this->_index->search($query); $this->assertEquals(1, $resultSet->count()); } + + public function testQueryTypeAndTypeCollision() + { + // This test ensures that Elastica\Type and Elastica\Query\Type + // do not collide when used together, which at one point + // happened because of a use statement in Elastica\Query\Ids + // Test goal is to make sure a Fatal Error is not triggered + // + // adapted fix for Elastica\Filter\Type + // see https://github.com/ruflin/Elastica/pull/438 + $queryType = new Type(); + $filter = new Ids(); + } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php index fafcf9c..c6728e5 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - $field => array( + $mapping = new Mapping($type, [ + $field => [ 'type' => 'image', 'store' => false, 'include_in_all' => false, - 'feature' => array( - 'CEDD' => array( + 'feature' => [ + 'CEDD' => [ 'hash' => 'BIT_SAMPLING', - ), - ), - ), - ) + ], + ], + ], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array($field => $this->_testFileContent)), - new Document(2, array($field => $this->_testFileContent)), - new Document(3, array($field => $this->_testFileContent)), - )); + $type->addDocuments([ + new Document(1, [$field => $this->_testFileContent]), + new Document(2, [$field => $this->_testFileContent]), + new Document(3, [$field => $this->_testFileContent]), + ]); $index->refresh(); @@ -120,31 +119,31 @@ public function testFromImage() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - $field => array( + $mapping = new Mapping($type, [ + $field => [ 'type' => 'image', 'store' => false, 'include_in_all' => false, - 'feature' => array( - 'CEDD' => array( + 'feature' => [ + 'CEDD' => [ 'hash' => 'BIT_SAMPLING', - ), - ), - ), - ) + ], + ], + ], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array($field => $this->_testFileContent)), - new Document(2, array($field => $this->_testFileContent)), - new Document(3, array($field => $this->_testFileContent)), - )); + $type->addDocuments([ + new Document(1, [$field => $this->_testFileContent]), + new Document(2, [$field => $this->_testFileContent]), + new Document(3, [$field => $this->_testFileContent]), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IndicesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IndicesTest.php index 3d1887a..bb2e732 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IndicesTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IndicesTest.php @@ -1,5 +1,4 @@ array( - 'indices' => array('index1', 'index2'), - 'query' => array( - 'term' => array('tag' => 'wow'), - ), - 'no_match_query' => array( - 'term' => array('tag' => 'such filter'), - ), - ), - ); - $query = new Indices(new Term(array('tag' => 'wow')), array('index1', 'index2')); - $query->setNoMatchQuery(new Term(array('tag' => 'such filter'))); + $expected = [ + 'indices' => [ + 'indices' => ['index1', 'index2'], + 'query' => [ + 'term' => ['tag' => 'wow'], + ], + 'no_match_query' => [ + 'term' => ['tag' => 'such filter'], + ], + ], + ]; + $query = new Indices(new Term(['tag' => 'wow']), ['index1', 'index2']); + $query->setNoMatchQuery(new Term(['tag' => 'such filter'])); $this->assertEquals($expected, $query->toArray()); } @@ -37,12 +36,12 @@ public function testToArray() */ public function testIndicesQuery() { - $docs = array( - new Document(1, array('color' => 'blue')), - new Document(2, array('color' => 'green')), - new Document(3, array('color' => 'blue')), - new Document(4, array('color' => 'yellow')), - ); + $docs = [ + new Document(1, ['color' => 'blue']), + new Document(2, ['color' => 'green']), + new Document(3, ['color' => 'blue']), + new Document(4, ['color' => 'yellow']), + ]; $index1 = $this->_createIndex(); $index1->addAlias('indices_query'); @@ -55,12 +54,12 @@ public function testIndicesQuery() $index2->refresh(); $boolQuery = new Query\BoolQuery(); - $boolQuery->addMustNot(new Term(array('color' => 'blue'))); + $boolQuery->addMustNot(new Term(['color' => 'blue'])); - $indicesQuery = new Indices($boolQuery, array($index1->getName())); + $indicesQuery = new Indices($boolQuery, [$index1->getName()]); $boolQuery = new Query\BoolQuery(); - $boolQuery->addMustNot(new Term(array('color' => 'yellow'))); + $boolQuery->addMustNot(new Term(['color' => 'yellow'])); $indicesQuery->setNoMatchQuery($boolQuery); $query = new Query(); @@ -92,16 +91,16 @@ public function testSetIndices() $index1 = $client->getIndex('index1'); $index2 = $client->getIndex('index2'); - $indices = array('one', 'two'); - $query = new Indices(new Term(array('color' => 'blue')), $indices); + $indices = ['one', 'two']; + $query = new Indices(new Term(['color' => 'blue']), $indices); $this->assertEquals($indices, $query->getParam('indices')); $indices[] = 'three'; $query->setIndices($indices); $this->assertEquals($indices, $query->getParam('indices')); - $query->setIndices(array($index1, $index2)); - $expected = array($index1->getName(), $index2->getName()); + $query->setIndices([$index1, $index2]); + $expected = [$index1->getName(), $index2->getName()]; $this->assertEquals($expected, $query->getParam('indices')); $returnValue = $query->setIndices($indices); @@ -116,14 +115,14 @@ public function testAddIndex() $client = $this->_getClient(); $index = $client->getIndex('someindex'); - $query = new Indices(new Term(array('color' => 'blue')), array()); + $query = new Indices(new Term(['color' => 'blue']), []); $query->addIndex($index); - $expected = array($index->getName()); + $expected = [$index->getName()]; $this->assertEquals($expected, $query->getParam('indices')); $query->addIndex('foo'); - $expected = array($index->getName(), 'foo'); + $expected = [$index->getName(), 'foo']; $this->assertEquals($expected, $query->getParam('indices')); $returnValue = $query->addIndex('bar'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/LimitTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/LimitTest.php index 0e7cc3e..d18f0b7 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/LimitTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/LimitTest.php @@ -1,5 +1,4 @@ array('value' => 15), - ); + $expectedArray = [ + 'limit' => ['value' => 15], + ]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php index 65c84bc..9fe8490 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php @@ -1,5 +1,4 @@ new \stdClass()); + $expectedArray = ['match_all' => new \stdClass()]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -34,8 +33,8 @@ public function testMatchAllIndicesTypes() $search1 = new Search($client); $resultSet1 = $search1->search(new MatchAll()); - $doc1 = new Document(1, array('name' => 'ruflin')); - $doc2 = new Document(1, array('name' => 'ruflin')); + $doc1 = new Document(1, ['name' => 'ruflin']); + $doc2 = new Document(1, ['name' => 'ruflin']); $index1->getType('test')->addDocument($doc1); $index2->getType('test')->addDocument($doc2); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php index 3ea0296..f74e0d7 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php @@ -1,5 +1,4 @@ setFieldPrefixLength($field, $prefixLength); $query->setFieldMaxExpansions($field, $maxExpansions); - $expectedArray = array( - 'match' => array( - $field => array( + $expectedArray = [ + 'match' => [ + $field => [ 'query' => $testQuery, 'type' => $type, 'operator' => $operator, @@ -52,9 +51,9 @@ public function testToArray() 'fuzzy_rewrite' => $fuzzyRewrite, 'prefix_length' => $prefixLength, 'max_expansions' => $maxExpansions, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } @@ -66,15 +65,15 @@ public function testMatch() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -97,15 +96,15 @@ public function testMatchSetFieldBoost() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -129,15 +128,15 @@ public function testMatchSetFieldBoostWithString() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -161,13 +160,13 @@ public function testMatchZeroTerm() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + ]); $index->refresh(); @@ -187,15 +186,15 @@ public function testMatchPhrase() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -218,15 +217,15 @@ public function testMatchPhraseAlias() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -247,15 +246,15 @@ public function testMatchPhrasePrefix() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -278,15 +277,15 @@ public function testMatchPhrasePrefixAlias() { $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'New Hampshire')), - new Document(4, array('name' => 'Basel Land')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'New Hampshire']), + new Document(4, ['name' => 'Basel Land']), + ]); $index->refresh(); @@ -327,10 +326,10 @@ public function testMatchFuzzinessType() public function testConstruct() { $match = new Match(null, 'values'); - $this->assertEquals(array('match' => array()), $match->toArray()); + $this->assertEquals(['match' => []], $match->toArray()); $match = new Match('field', null); - $this->assertEquals(array('match' => array()), $match->toArray()); + $this->assertEquals(['match' => []], $match->toArray()); $match1 = new Match('field', 'values'); $match2 = new Match(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MissingTest.php index b1ac756..6dcc387 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MissingTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MissingTest.php @@ -1,5 +1,4 @@ array('field' => 'field_name')); + $expectedArray = ['missing' => ['field' => 'field_name']]; $this->assertEquals($expectedArray, $query->toArray()); $query = new Missing('field_name'); $query->setExistence(true); - $expectedArray = array('missing' => array('field' => 'field_name', 'existence' => true)); + $expectedArray = ['missing' => ['field' => 'field_name', 'existence' => true]]; $this->assertEquals($expectedArray, $query->toArray()); $query = new Missing('field_name'); $query->setNullValue(true); - $expectedArray = array('missing' => array('field' => 'field_name', 'null_value' => true)); + $expectedArray = ['missing' => ['field' => 'field_name', 'null_value' => true]]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php index f2d44b4..7ba5065 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php @@ -1,5 +1,4 @@ _getClient(); $index = new Index($client, 'test'); - $index->create(array(), true); + $index->create([], true); $index->getSettings()->setNumberOfReplicas(0); //$index->getSettings()->setNumberOfShards(1); $type = new Type($index, 'helloworldmlt'); - $mapping = new Mapping($type, array( - 'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'), - 'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'), - )); + $mapping = new Mapping($type, [ + 'email' => ['store' => 'yes', 'type' => 'string', 'index' => 'analyzed'], + 'content' => ['store' => 'yes', 'type' => 'string', 'index' => 'analyzed'], + ]); - $mapping->setSource(array('enabled' => false)); + $mapping->setSource(['enabled' => false]); $type->setMapping($mapping); - $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'This is a sample post. Hello World Fuzzy Like This!')); + $doc = new Document(1000, ['email' => 'testemail@gmail.com', 'content' => 'This is a sample post. Hello World Fuzzy Like This!']); $type->addDocument($doc); - $doc = new Document(1001, array('email' => 'nospam@gmail.com', 'content' => 'This is a fake nospam email address for gmail')); + $doc = new Document(1001, ['email' => 'nospam@gmail.com', 'content' => 'This is a fake nospam email address for gmail']); $type->addDocument($doc); // Refresh index @@ -45,7 +44,7 @@ public function testSearch() $mltQuery = new MoreLikeThis(); $mltQuery->setLike('fake gmail sample'); - $mltQuery->setFields(array('email', 'content')); + $mltQuery->setFields(['email', 'content']); $mltQuery->setMaxQueryTerms(3); $mltQuery->setMinDocFrequency(1); $mltQuery->setMinTermFrequency(1); @@ -63,21 +62,21 @@ public function testSearch() */ public function testSearchByDocument() { - $client = $this->_getClient(array('persistent' => false)); + $client = $this->_getClient(['persistent' => false]); $index = $client->getIndex('elastica_test'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); $type = new Type($index, 'mlt_test'); - $type->addDocuments(array( - new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')), - new Document(2, array('visible' => true, 'name' => 'bruce wayne')), - new Document(3, array('visible' => false, 'name' => 'bruce wayne')), - new Document(4, array('visible' => true, 'name' => 'batman')), - new Document(5, array('visible' => false, 'name' => 'batman')), - new Document(6, array('visible' => true, 'name' => 'superman')), - new Document(7, array('visible' => true, 'name' => 'spiderman')), - )); + $type->addDocuments([ + new Document(1, ['visible' => true, 'name' => 'bruce wayne batman']), + new Document(2, ['visible' => true, 'name' => 'bruce wayne']), + new Document(3, ['visible' => false, 'name' => 'bruce wayne']), + new Document(4, ['visible' => true, 'name' => 'batman']), + new Document(5, ['visible' => false, 'name' => 'batman']), + new Document(6, ['visible' => true, 'name' => 'superman']), + new Document(7, ['visible' => true, 'name' => 'spiderman']), + ]); $index->refresh(); @@ -162,7 +161,7 @@ public function testSetFields() { $query = new MoreLikeThis(); - $fields = array('firstname', 'lastname'); + $fields = ['firstname', 'lastname']; $query->setFields($fields); $data = $query->toArray(); @@ -176,7 +175,7 @@ public function testSetFields() public function testSetIds() { $query = new MoreLikeThis(); - $ids = array(1, 2, 3); + $ids = [1, 2, 3]; $query->setIds($ids); } @@ -338,7 +337,7 @@ public function testSetStopWords() { $query = new MoreLikeThis(); - $stopWords = array('no', 'yes', 'test'); + $stopWords = ['no', 'yes', 'test']; $query->setStopWords($stopWords); $this->assertEquals($stopWords, $query->getParam('stop_words')); @@ -350,19 +349,19 @@ public function testSetStopWords() public function testToArrayForId() { $query = new MoreLikeThis(); - $query->setLike(new Document(1, array(), 'type', 'index')); + $query->setLike(new Document(1, [], 'type', 'index')); $data = $query->toArray(); $this->assertEquals( - array('more_like_this' => array( - 'like' => array( + ['more_like_this' => [ + 'like' => [ '_id' => 1, '_type' => 'type', '_index' => 'index', - ), - ), - ), + ], + ], + ], $data ); } @@ -373,21 +372,21 @@ public function testToArrayForId() public function testToArrayForSource() { $query = new MoreLikeThis(); - $query->setLike(new Document('', array('Foo' => 'Bar'), 'type', 'index')); + $query->setLike(new Document('', ['Foo' => 'Bar'], 'type', 'index')); $data = $query->toArray(); $this->assertEquals( - array('more_like_this' => array( - 'like' => array( + ['more_like_this' => [ + 'like' => [ '_type' => 'type', '_index' => 'index', - 'doc' => array( + 'doc' => [ 'Foo' => 'Bar', - ), - ), - ), - ), + ], + ], + ], + ], $data ); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php index 7d58e14..474662b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php @@ -1,5 +1,4 @@ 1, 'name' => 'Rodolfo', 'last_name' => 'Moraes', 'full_name' => 'Rodolfo Moraes'), - array('id' => 2, 'name' => 'Tristan', 'last_name' => 'Maindron', 'full_name' => 'Tristan Maindron'), - array('id' => 3, 'name' => 'Monique', 'last_name' => 'Maindron', 'full_name' => 'Monique Maindron'), - array('id' => 4, 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'), - ); + private static $data = [ + ['id' => 1, 'name' => 'Rodolfo', 'last_name' => 'Moraes', 'full_name' => 'Rodolfo Moraes'], + ['id' => 2, 'name' => 'Tristan', 'last_name' => 'Maindron', 'full_name' => 'Tristan Maindron'], + ['id' => 3, 'name' => 'Monique', 'last_name' => 'Maindron', 'full_name' => 'Monique Maindron'], + ['id' => 4, 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'], + ]; /** * @group functional @@ -29,7 +28,7 @@ public function testMinimumShouldMatch() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('Tristan Maindron'); - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setMinimumShouldMatch('2<100%'); $resultSet = $this->_getResults($multiMatch); @@ -43,7 +42,7 @@ public function testAndOperator() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('Monique Maindron'); - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setOperator(MultiMatch::OPERATOR_AND); $resultSet = $this->_getResults($multiMatch); @@ -57,7 +56,7 @@ public function testType() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('Trist'); - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX); $resultSet = $this->_getResults($multiMatch); @@ -71,7 +70,7 @@ public function testFuzzy() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('Tritsan'); // Misspell on purpose - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setFuzziness(2); $resultSet = $this->_getResults($multiMatch); @@ -79,7 +78,7 @@ public function testFuzzy() $multiMatch = new MultiMatch(); $multiMatch->setQuery('Tritsan'); // Misspell on purpose - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setFuzziness(0); $resultSet = $this->_getResults($multiMatch); @@ -87,7 +86,7 @@ public function testFuzzy() $multiMatch = new MultiMatch(); $multiMatch->setQuery('Tritsan'); // Misspell on purpose - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setFuzziness(MultiMatch::FUZZINESS_AUTO); $resultSet = $this->_getResults($multiMatch); @@ -103,7 +102,7 @@ public function testFuzzyWithOptions1() // on the first 6 letters. $multiMatch = new MultiMatch(); $multiMatch->setQuery('Tritsan'); // Misspell on purpose - $multiMatch->setFields(array('full_name', 'name')); + $multiMatch->setFields(['full_name', 'name']); $multiMatch->setFuzziness(2); $multiMatch->setPrefixLength(6); $resultSet = $this->_getResults($multiMatch); @@ -121,7 +120,7 @@ public function testFuzzyWithOptions2() // If MaxExpansion was set to 2, we could hit "Maindron" too. $multiMatch = new MultiMatch(); $multiMatch->setQuery('M'); - $multiMatch->setFields(array('name')); + $multiMatch->setFields(['name']); $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX); $multiMatch->setPrefixLength(0); $multiMatch->setMaxExpansions(1); @@ -137,7 +136,7 @@ public function testZeroTerm() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('not'); // This is a stopword. - $multiMatch->setFields(array('full_name', 'last_name')); + $multiMatch->setFields(['full_name', 'last_name']); $multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_NONE); $multiMatch->setAnalyzer('stops'); $resultSet = $this->_getResults($multiMatch); @@ -157,14 +156,14 @@ public function testBaseMultiMatch() { $multiMatch = new MultiMatch(); $multiMatch->setQuery('Rodolfo'); - $multiMatch->setFields(array('name', 'last_name')); + $multiMatch->setFields(['name', 'last_name']); $resultSet = $this->_getResults($multiMatch); $this->assertEquals(1, $resultSet->count()); $multiMatch = new MultiMatch(); $multiMatch->setQuery('Moraes'); - $multiMatch->setFields(array('name', 'last_name')); + $multiMatch->setFields(['name', 'last_name']); $resultSet = $this->_getResults($multiMatch); $this->assertEquals(1, $resultSet->count()); @@ -186,28 +185,28 @@ private function _generateIndex() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array( - 'analysis' => array( - 'analyzer' => array( - 'noStops' => array( + $index->create([ + 'analysis' => [ + 'analyzer' => [ + 'noStops' => [ 'type' => 'standard', 'stopwords' => '_none_', - ), - 'stops' => array( + ], + 'stops' => [ 'type' => 'standard', - 'stopwords' => array('not'), - ), - ), - ), - ), true); + 'stopwords' => ['not'], + ], + ], + ], + ], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'), - 'last_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'), - 'full_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'), - )); + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'], + 'last_name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'], + 'full_name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'], + ]); $type->setMapping($mapping); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php index a18f537..d07841e 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php @@ -1,5 +1,4 @@ assertInstanceOf('Elastica\Query\Nested', $nested->setQuery($queryString)); $this->assertInstanceOf('Elastica\Query\Nested', $nested->setPath($path)); - $expected = array( - 'nested' => array( + $expected = [ + 'nested' => [ 'query' => $queryString->toArray(), 'path' => $path, - ), - ); + ], + ]; $this->assertEquals($expected, $nested->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NumericRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NumericRangeTest.php index ea47dec..6695336 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NumericRangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NumericRangeTest.php @@ -1,5 +1,4 @@ addField('fieldName', array('to' => 'value')); + $returnValue = $rangeQuery->addField('fieldName', ['to' => 'value']); $this->assertInstanceOf('Elastica\Query\NumericRange', $returnValue); } @@ -24,14 +23,14 @@ public function testToArray() { $query = new NumericRange(); - $fromTo = array('from' => 'ra', 'to' => 'ru'); + $fromTo = ['from' => 'ra', 'to' => 'ru']; $query->addField('name', $fromTo); - $expectedArray = array( - 'numeric_range' => array( + $expectedArray = [ + 'numeric_range' => [ 'name' => $fromTo, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php index 239efdc..de776d2 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php @@ -1,5 +1,4 @@ _createIndex(); - $docs = array( - new Document(1, array('color' => 'green', 'make' => 'ford')), - new Document(2, array('color' => 'blue', 'make' => 'volvo')), - new Document(3, array('color' => 'red', 'make' => 'ford')), - new Document(4, array('color' => 'green', 'make' => 'renault')), - ); + $docs = [ + new Document(1, ['color' => 'green', 'make' => 'ford']), + new Document(2, ['color' => 'blue', 'make' => 'volvo']), + new Document(3, ['color' => 'red', 'make' => 'ford']), + new Document(4, ['color' => 'green', 'make' => 'renault']), + ]; $index->getType('test')->addDocuments($docs); $index->refresh(); @@ -33,14 +32,14 @@ public function testArrayDeprecated() $errorsCollector = $this->startCollectErrors(); $query = new Query(); - $query->setPostFilter(array('a')); + $query->setPostFilter(['a']); $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query::setPostFilter() passing filter as array is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -57,9 +56,9 @@ public function testFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query::setPostFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -80,13 +79,13 @@ public function testToArray() { $query = new Query(); - $post_filter = new Query\Term(array('color' => 'green')); + $post_filter = new Query\Term(['color' => 'green']); $query->setPostFilter($post_filter); $data = $query->toArray(); $this->assertArrayHasKey('post_filter', $data); - $this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']); + $this->assertEquals(['term' => ['color' => 'green']], $data['post_filter']); } /** @@ -97,14 +96,14 @@ public function testToArrayWithLegacyFilter() $query = new Query(); $this->hideDeprecated(); - $post_filter = new Term(array('color' => 'green')); + $post_filter = new Term(['color' => 'green']); $query->setPostFilter($post_filter); $this->showDeprecated(); $data = $query->toArray(); $this->assertArrayHasKey('post_filter', $data); - $this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']); + $this->assertEquals(['term' => ['color' => 'green']], $data['post_filter']); } /** diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php index 070097f..e12ead0 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php @@ -1,5 +1,4 @@ $str, - ); + ]; - $this->assertEquals(array('query_string' => $expected), $query->toArray()); + $this->assertEquals(['query_string' => $expected], $query->toArray()); - $fields = array(); + $fields = []; $max = rand() % 10 + 1; for ($i = 0; $i < $max; ++$i) { $fields[] = md5(rand()); @@ -30,13 +29,13 @@ public function testSearchMultipleFields() $query->setFields($fields); $expected['fields'] = $fields; - $this->assertEquals(array('query_string' => $expected), $query->toArray()); + $this->assertEquals(['query_string' => $expected], $query->toArray()); - foreach (array(false, true) as $val) { + foreach ([false, true] as $val) { $query->setUseDisMax($val); $expected['use_dis_max'] = $val; - $this->assertEquals(array('query_string' => $expected), $query->toArray()); + $this->assertEquals(['query_string' => $expected], $query->toArray()); } } @@ -49,7 +48,7 @@ public function testSearch() $index->getSettings()->setNumberOfReplicas(0); $type = $index->getType('helloworld'); - $doc = new Document(1, array('email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))); + $doc = new Document(1, ['email' => 'test@test.com', 'username' => 'hanswurst', 'test' => ['2', '3', '5']]); $type->addDocument($doc); $index->refresh(); @@ -69,14 +68,14 @@ public function testSearchFields() $index = $this->_createIndex(); $type = $index->getType('test'); - $doc = new Document(1, array('title' => 'hello world', 'firstname' => 'nicolas', 'lastname' => 'ruflin', 'price' => '102', 'year' => '2012')); + $doc = new Document(1, ['title' => 'hello world', 'firstname' => 'nicolas', 'lastname' => 'ruflin', 'price' => '102', 'year' => '2012']); $type->addDocument($doc); $index->refresh(); $query = new QueryString(); $query = $query->setQuery('ruf*'); $query = $query->setDefaultField('title'); - $query = $query->setFields(array('title', 'firstname', 'lastname', 'price', 'year')); + $query = $query->setFields(['title', 'firstname', 'lastname', 'price', 'year']); $resultSet = $type->search($query); $this->assertEquals(1, $resultSet->count()); @@ -131,7 +130,7 @@ public function testSetRewrite() public function testSetQueryInvalid() { $query = new QueryString(); - $query->setQuery(array()); + $query->setQuery([]); } /** @@ -145,12 +144,12 @@ public function testSetTimezone() $query = new QueryString($text); $query->setTimezone($timezone); - $expected = array( - 'query_string' => array( + $expected = [ + 'query_string' => [ 'query' => $text, 'time_zone' => $timezone, - ), - ); + ], + ]; $this->assertEquals($expected, $query->toArray()); $this->assertInstanceOf('Elastica\Query\QueryString', $query->setTimezone($timezone)); @@ -179,7 +178,7 @@ public function testSetBoost() $query = new QueryString('test'); $query->setBoost(9.3); - $doc = new Document('', array('name' => 'test')); + $doc = new Document('', ['name' => 'test']); $index->getType('test')->addDocument($doc); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php index 341f987..7b39bbf 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('age' => 16, 'height' => 140)), - new Document(2, array('age' => 21, 'height' => 155)), - new Document(3, array('age' => 33, 'height' => 160)), - new Document(4, array('age' => 68, 'height' => 160)), - )); + $type->addDocuments([ + new Document(1, ['age' => 16, 'height' => 140]), + new Document(2, ['age' => 21, 'height' => 155]), + new Document(3, ['age' => 33, 'height' => 160]), + new Document(4, ['age' => 68, 'height' => 160]), + ]); $index->optimize(); $index->refresh(); - $query = new Range('age', array('from' => 10, 'to' => 20)); + $query = new Range('age', ['from' => 10, 'to' => 20]); $result = $type->search($query)->count(); $this->assertEquals(1, $result); $query = new Range(); - $query->addField('height', array('gte' => 160)); + $query->addField('height', ['gte' => 160]); $result = $type->search($query)->count(); $this->assertEquals(2, $result); @@ -46,14 +45,14 @@ public function testToArray() { $range = new Range(); - $field = array('from' => 20, 'to' => 40); + $field = ['from' => 20, 'to' => 40]; $range->addField('age', $field); - $expectedArray = array( - 'range' => array( + $expectedArray = [ + 'range' => [ 'age' => $field, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $range->toArray()); } @@ -63,17 +62,17 @@ public function testToArray() */ public function testConstruct() { - $ranges = array('from' => 20, 'to' => 40); + $ranges = ['from' => 20, 'to' => 40]; $range = new Range( 'age', $ranges ); - $expectedArray = array( - 'range' => array( + $expectedArray = [ + 'range' => [ 'age' => $ranges, - ), - ); + ], + ]; $this->assertEquals($expectedArray, $range->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php index affdb64..c45a902 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php @@ -1,5 +1,4 @@ array( - $field => array( + $expectedArray = [ + 'regexp' => [ + $field => [ 'value' => $value, 'boost' => $boost, - ), - ), - ); + ], + ], + ]; $this->assertequals($expectedArray, $query->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php index c5bde31..2d748fe 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php @@ -1,5 +1,4 @@ setRescore($queryRescore); $data = $query->toArray(); - $expected = array( - 'query' => array( - 'match' => array( - 'test1' => array( + $expected = [ + 'query' => [ + 'match' => [ + 'test1' => [ 'query' => 'foo', - ), - ), - ), - 'rescore' => array( - 'query' => array( - 'rescore_query' => array( - 'term' => array( - 'test2' => array( + ], + ], + ], + 'rescore' => [ + 'query' => [ + 'rescore_query' => [ + 'term' => [ + 'test2' => [ 'value' => 'bar', 'boost' => 2, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $data); } @@ -66,28 +65,28 @@ public function testSetSize() $query->setRescore($queryRescore); $data = $query->toArray(); - $expected = array( - 'query' => array( - 'match' => array( - 'test1' => array( + $expected = [ + 'query' => [ + 'match' => [ + 'test1' => [ 'query' => 'foo', - ), - ), - ), - 'rescore' => array( + ], + ], + ], + 'rescore' => [ 'window_size' => 50, - 'query' => array( - 'rescore_query' => array( - 'term' => array( - 'test2' => array( + 'query' => [ + 'rescore_query' => [ + 'term' => [ + 'test2' => [ 'value' => 'bar', 'boost' => 2, - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $data); } @@ -110,30 +109,30 @@ public function testSetWeights() $query->setRescore($queryRescore); $data = $query->toArray(); - $expected = array( - 'query' => array( - 'match' => array( - 'test1' => array( + $expected = [ + 'query' => [ + 'match' => [ + 'test1' => [ 'query' => 'foo', - ), - ), - ), - 'rescore' => array( + ], + ], + ], + 'rescore' => [ 'window_size' => 50, - 'query' => array( - 'rescore_query' => array( - 'term' => array( - 'test2' => array( + 'query' => [ + 'rescore_query' => [ + 'term' => [ + 'test2' => [ 'value' => 'bar', 'boost' => 2, - ), - ), - ), + ], + ], + ], 'query_weight' => 0.7, 'rescore_query_weight' => 1.2, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $data); } @@ -158,44 +157,44 @@ public function testMultipleQueries() $rescoreQuery2->setRescoreQuery($secQuery2); $query->setQuery($mainQuery); - $query->setRescore(array($rescoreQuery1, $rescoreQuery2)); + $query->setRescore([$rescoreQuery1, $rescoreQuery2]); $data = $query->toArray(); - $expected = array( - 'query' => array( - 'match' => array( - 'test1' => array( + $expected = [ + 'query' => [ + 'match' => [ + 'test1' => [ 'query' => 'foo', - ), - ), - ), - 'rescore' => array( - array( - 'query' => array( - 'rescore_query' => array( - 'term' => array( - 'test2' => array( + ], + ], + ], + 'rescore' => [ + [ + 'query' => [ + 'rescore_query' => [ + 'term' => [ + 'test2' => [ 'value' => 'bar', 'boost' => 1, - ), - ), - ), - ), - ), - array( - 'query' => array( - 'rescore_query' => array( - 'term' => array( - 'test2' => array( + ], + ], + ], + ], + ], + [ + 'query' => [ + 'rescore_query' => [ + 'term' => [ + 'test2' => [ 'value' => 'tom', 'boost' => 2, - ), - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $data); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ScriptTest.php index 0431855..54e10ca 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ScriptTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ScriptTest.php @@ -1,5 +1,4 @@ toArray(); $this->assertInternalType('array', $array); - $expected = array( - 'script' => array( + $expected = [ + 'script' => [ 'script' => $string, - ), - ); + ], + ]; $this->assertEquals($expected, $array); } @@ -34,10 +33,10 @@ public function testToArray() public function testSetScript() { $string = '_score * 2.0'; - $params = array( + $params = [ 'param1' => 'one', 'param2' => 1, - ); + ]; $lang = 'mvel'; $script = new Script($string, $params, $lang); @@ -46,13 +45,13 @@ public function testSetScript() $array = $query->toArray(); - $expected = array( - 'script' => array( + $expected = [ + 'script' => [ 'script' => $string, 'params' => $params, 'lang' => $lang, - ), - ); + ], + ]; $this->assertEquals($expected, $array); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php index 050a926..9a367f6 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php @@ -1,5 +1,4 @@ setDefaultOperator(SimpleQueryString::OPERATOR_OR); $query->setAnalyzer('whitespace'); - $expected = array( - 'simple_query_string' => array( + $expected = [ + 'simple_query_string' => [ 'query' => $string, 'fields' => $fields, 'analyzer' => 'whitespace', 'default_operator' => SimpleQueryString::OPERATOR_OR, - ), - ); + ], + ]; $this->assertEquals($expected, $query->toArray()); } @@ -37,22 +36,22 @@ public function testToArray() public function testQuery() { $index = $this->_createIndex(); - $docs = array( - new Document(1, array('make' => 'Gibson', 'model' => 'Les Paul')), - new Document(2, array('make' => 'Gibson', 'model' => 'SG Standard')), - new Document(3, array('make' => 'Gibson', 'model' => 'SG Supreme')), - new Document(4, array('make' => 'Gibson', 'model' => 'SG Faded')), - new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')), - ); + $docs = [ + new Document(1, ['make' => 'Gibson', 'model' => 'Les Paul']), + new Document(2, ['make' => 'Gibson', 'model' => 'SG Standard']), + new Document(3, ['make' => 'Gibson', 'model' => 'SG Supreme']), + new Document(4, ['make' => 'Gibson', 'model' => 'SG Faded']), + new Document(5, ['make' => 'Fender', 'model' => 'Stratocaster']), + ]; $index->getType('guitars')->addDocuments($docs); $index->refresh(); - $query = new SimpleQueryString('gibson +sg +-faded', array('make', 'model')); + $query = new SimpleQueryString('gibson +sg +-faded', ['make', 'model']); $results = $index->search($query); $this->assertEquals(2, $results->getTotalHits()); - $query->setFields(array('model')); + $query->setFields(['model']); $results = $index->search($query); // We should not get any hits, since the "make" field was not included in the query. @@ -64,12 +63,12 @@ public function testQuery() */ public function testSetMinimumShouldMatch() { - $expected = array( - 'simple_query_string' => array( + $expected = [ + 'simple_query_string' => [ 'query' => 'DONT PANIC', 'minimum_should_match' => '75%', - ), - ); + ], + ]; $query = new SimpleQueryString($expected['simple_query_string']['query']); $query->setMinimumShouldMatch($expected['simple_query_string']['minimum_should_match']); @@ -87,12 +86,12 @@ public function testSetMinimumShouldMatchWorks() $index = $this->_createIndex(); $type = $index->getType('foobars'); - $type->addDocuments(array( - new Document(1, array('body' => 'foo')), - new Document(2, array('body' => 'bar')), - new Document(3, array('body' => 'foo bar')), - new Document(4, array('body' => 'foo baz bar')), - )); + $type->addDocuments([ + new Document(1, ['body' => 'foo']), + new Document(2, ['body' => 'bar']), + new Document(3, ['body' => 'foo bar']), + new Document(4, ['body' => 'foo baz bar']), + ]); $index->refresh(); $query = new SimpleQueryString('foo bar'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php index 8e7a5c0..3ed0cfb 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php @@ -1,5 +1,4 @@ array('world'), 'name' => 'ruflin'); + $testQuery = ['hello' => ['world'], 'name' => 'ruflin']; $query = new Simple($testQuery); $this->assertEquals($testQuery, $query->toArray()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php index 40a42bf..6200f64 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('helloworld'); - $type->addDocuments(array( - new Document(1, array('name' => 'hello world')), - new Document(2, array('name' => 'nicolas ruflin')), - new Document(3, array('name' => 'ruflin')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'hello world']), + new Document(2, ['name' => 'nicolas ruflin']), + new Document(3, ['name' => 'ruflin']), + ]); $query = new Terms(); - $query->setTerms('name', array('nicolas', 'hello')); + $query->setTerms('name', ['nicolas', 'hello']); $index->refresh(); @@ -43,7 +42,7 @@ public function testFilteredSearch() public function testSetMinimum() { $key = 'name'; - $terms = array('nicolas', 'ruflin'); + $terms = ['nicolas', 'ruflin']; $minimum = 2; $query = new Terms($key, $terms); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TypeTest.php index 531a242..eaae621 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TypeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TypeTest.php @@ -1,5 +1,4 @@ array('value' => 'type_name'), - ); + $expectedArray = [ + 'type' => ['value' => 'type_name'], + ]; $this->assertEquals($expectedArray, $typeQuery->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php index 90f949d..d267b73 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php @@ -1,5 +1,4 @@ array( - $key => array( + $expectedArray = [ + 'wildcard' => [ + $key => [ 'value' => $value, 'boost' => $boost, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expectedArray, $wildcard->toArray()); } @@ -49,34 +48,34 @@ public function testSearchWithAnalyzer() $client = $this->_getClient(); $index = $client->getIndex('test'); - $indexParams = array( - 'analysis' => array( - 'analyzer' => array( - 'lw' => array( + $indexParams = [ + 'analysis' => [ + 'analyzer' => [ + 'lw' => [ 'type' => 'custom', 'tokenizer' => 'keyword', - 'filter' => array('lowercase'), - ), - ), - ), - ); + 'filter' => ['lowercase'], + ], + ], + ], + ]; $index->create($indexParams, true); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'lw'), - ) + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no', 'analyzer' => 'lw'], + ] ); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'Basel-Stadt')), - new Document(2, array('name' => 'New York')), - new Document(3, array('name' => 'Baden')), - new Document(4, array('name' => 'Baden Baden')), - new Document(5, array('name' => 'New Orleans')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'Basel-Stadt']), + new Document(2, ['name' => 'New York']), + new Document(3, ['name' => 'Baden']), + new Document(4, ['name' => 'Baden Baden']), + new Document(5, ['name' => 'New Orleans']), + ]); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php index be4c0bf..47ca7e3 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php @@ -1,5 +1,4 @@ assertTrue(method_exists($dsl, $methodName)); // Check returned value - $return = call_user_func_array(array($dsl, $methodName), $arguments); + $return = call_user_func_array([$dsl, $methodName], $arguments); $this->assertTrue(class_exists($className), 'Class not exists but NotImplementedException is not thrown'); $this->assertInstanceOf($className, $return); @@ -41,7 +40,7 @@ protected function _assertImplemented(DSL $dsl, $methodName, $className, $argume protected function _assertNotImplemented(DSL $dsl, $methodName, $arguments) { try { - call_user_func(array($dsl, $methodName), $arguments); + call_user_func([$dsl, $methodName], $arguments); $this->fail('NotImplementedException is not thrown'); } catch (NotImplementedException $ex) { // expected diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php index a14a81a..02e9676 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php @@ -1,5 +1,4 @@ _assertImplemented($aggregationDSL, 'avg', 'Elastica\Aggregation\Avg', array('name')); - $this->_assertImplemented($aggregationDSL, 'cardinality', 'Elastica\Aggregation\Cardinality', array('name')); - $this->_assertImplemented($aggregationDSL, 'date_histogram', 'Elastica\Aggregation\DateHistogram', array('name', 'field', 1)); - $this->_assertImplemented($aggregationDSL, 'date_range', 'Elastica\Aggregation\DateRange', array('name')); - $this->_assertImplemented($aggregationDSL, 'extended_stats', 'Elastica\Aggregation\ExtendedStats', array('name')); + $this->_assertImplemented($aggregationDSL, 'avg', 'Elastica\Aggregation\Avg', ['name']); + $this->_assertImplemented($aggregationDSL, 'cardinality', 'Elastica\Aggregation\Cardinality', ['name']); + $this->_assertImplemented($aggregationDSL, 'date_histogram', 'Elastica\Aggregation\DateHistogram', ['name', 'field', 1]); + $this->_assertImplemented($aggregationDSL, 'date_range', 'Elastica\Aggregation\DateRange', ['name']); + $this->_assertImplemented($aggregationDSL, 'extended_stats', 'Elastica\Aggregation\ExtendedStats', ['name']); $this->hideDeprecated(); - $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', array('name', new Exists('field'))); + $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', ['name', new Exists('field')]); $this->showDeprecated(); - $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', array('name', new Term())); + $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', ['name', new Term()]); - $this->_assertImplemented($aggregationDSL, 'filters', 'Elastica\Aggregation\Filters', array('name')); - $this->_assertImplemented($aggregationDSL, 'geo_distance', 'Elastica\Aggregation\GeoDistance', array('name', 'field', 'origin')); - $this->_assertImplemented($aggregationDSL, 'geohash_grid', 'Elastica\Aggregation\GeohashGrid', array('name', 'field')); - $this->_assertImplemented($aggregationDSL, 'global_agg', 'Elastica\Aggregation\GlobalAggregation', array('name')); - $this->_assertImplemented($aggregationDSL, 'histogram', 'Elastica\Aggregation\Histogram', array('name', 'field', 1)); - $this->_assertImplemented($aggregationDSL, 'ipv4_range', 'Elastica\Aggregation\IpRange', array('name', 'field')); - $this->_assertImplemented($aggregationDSL, 'max', 'Elastica\Aggregation\Max', array('name')); - $this->_assertImplemented($aggregationDSL, 'min', 'Elastica\Aggregation\Min', array('name')); - $this->_assertImplemented($aggregationDSL, 'missing', 'Elastica\Aggregation\Missing', array('name', 'field')); - $this->_assertImplemented($aggregationDSL, 'nested', 'Elastica\Aggregation\Nested', array('name', 'path')); - $this->_assertImplemented($aggregationDSL, 'percentiles', 'Elastica\Aggregation\Percentiles', array('name')); - $this->_assertImplemented($aggregationDSL, 'range', 'Elastica\Aggregation\Range', array('name')); - $this->_assertImplemented($aggregationDSL, 'reverse_nested', 'Elastica\Aggregation\ReverseNested', array('name')); - $this->_assertImplemented($aggregationDSL, 'scripted_metric', 'Elastica\Aggregation\ScriptedMetric', array('name')); - $this->_assertImplemented($aggregationDSL, 'significant_terms', 'Elastica\Aggregation\SignificantTerms', array('name')); - $this->_assertImplemented($aggregationDSL, 'stats', 'Elastica\Aggregation\Stats', array('name')); - $this->_assertImplemented($aggregationDSL, 'sum', 'Elastica\Aggregation\Sum', array('name')); - $this->_assertImplemented($aggregationDSL, 'terms', 'Elastica\Aggregation\Terms', array('name')); - $this->_assertImplemented($aggregationDSL, 'top_hits', 'Elastica\Aggregation\TopHits', array('name')); - $this->_assertImplemented($aggregationDSL, 'value_count', 'Elastica\Aggregation\ValueCount', array('name', 'field')); + $this->_assertImplemented($aggregationDSL, 'filters', 'Elastica\Aggregation\Filters', ['name']); + $this->_assertImplemented($aggregationDSL, 'geo_distance', 'Elastica\Aggregation\GeoDistance', ['name', 'field', 'origin']); + $this->_assertImplemented($aggregationDSL, 'geohash_grid', 'Elastica\Aggregation\GeohashGrid', ['name', 'field']); + $this->_assertImplemented($aggregationDSL, 'global_agg', 'Elastica\Aggregation\GlobalAggregation', ['name']); + $this->_assertImplemented($aggregationDSL, 'histogram', 'Elastica\Aggregation\Histogram', ['name', 'field', 1]); + $this->_assertImplemented($aggregationDSL, 'ipv4_range', 'Elastica\Aggregation\IpRange', ['name', 'field']); + $this->_assertImplemented($aggregationDSL, 'max', 'Elastica\Aggregation\Max', ['name']); + $this->_assertImplemented($aggregationDSL, 'min', 'Elastica\Aggregation\Min', ['name']); + $this->_assertImplemented($aggregationDSL, 'missing', 'Elastica\Aggregation\Missing', ['name', 'field']); + $this->_assertImplemented($aggregationDSL, 'nested', 'Elastica\Aggregation\Nested', ['name', 'path']); + $this->_assertImplemented($aggregationDSL, 'percentiles', 'Elastica\Aggregation\Percentiles', ['name']); + $this->_assertImplemented($aggregationDSL, 'range', 'Elastica\Aggregation\Range', ['name']); + $this->_assertImplemented($aggregationDSL, 'reverse_nested', 'Elastica\Aggregation\ReverseNested', ['name']); + $this->_assertImplemented($aggregationDSL, 'scripted_metric', 'Elastica\Aggregation\ScriptedMetric', ['name']); + $this->_assertImplemented($aggregationDSL, 'significant_terms', 'Elastica\Aggregation\SignificantTerms', ['name']); + $this->_assertImplemented($aggregationDSL, 'stats', 'Elastica\Aggregation\Stats', ['name']); + $this->_assertImplemented($aggregationDSL, 'sum', 'Elastica\Aggregation\Sum', ['name']); + $this->_assertImplemented($aggregationDSL, 'terms', 'Elastica\Aggregation\Terms', ['name']); + $this->_assertImplemented($aggregationDSL, 'top_hits', 'Elastica\Aggregation\TopHits', ['name']); + $this->_assertImplemented($aggregationDSL, 'value_count', 'Elastica\Aggregation\ValueCount', ['name', 'field']); - $this->_assertNotImplemented($aggregationDSL, 'children', array('name')); - $this->_assertNotImplemented($aggregationDSL, 'geo_bounds', array('name')); - $this->_assertNotImplemented($aggregationDSL, 'percentile_ranks', array('name')); + $this->_assertNotImplemented($aggregationDSL, 'children', ['name']); + $this->_assertNotImplemented($aggregationDSL, 'geo_bounds', ['name']); + $this->_assertNotImplemented($aggregationDSL, 'percentile_ranks', ['name']); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php index 1329947..b44ed29 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php @@ -1,5 +1,4 @@ hideDeprecated(); - $this->_assertImplemented($filterDSL, 'bool', 'Elastica\Filter\BoolFilter', array()); - $this->_assertImplemented($filterDSL, 'bool_and', 'Elastica\Filter\BoolAnd', array(array(new Exists('field')))); - $this->_assertImplemented($filterDSL, 'bool_not', 'Elastica\Filter\BoolNot', array(new Exists('field'))); - $this->_assertImplemented($filterDSL, 'bool_or', 'Elastica\Filter\BoolOr', array(array(new Exists('field')))); - $this->_assertImplemented($filterDSL, 'exists', 'Elastica\Filter\Exists', array('field')); - $this->_assertImplemented($filterDSL, 'geo_bounding_box', 'Elastica\Filter\GeoBoundingBox', array('field', array(1, 2))); - $this->_assertImplemented($filterDSL, 'geo_distance', 'Elastica\Filter\GeoDistance', array('key', 'location', 'distance')); - $this->_assertImplemented($filterDSL, 'geo_distance_range', 'Elastica\Filter\GeoDistanceRange', array('key', 'location')); - $this->_assertImplemented($filterDSL, 'geo_polygon', 'Elastica\Filter\GeoPolygon', array('key', array())); - $this->_assertImplemented($filterDSL, 'geo_shape_pre_indexed', 'Elastica\Filter\GeoShapePreIndexed', array('path', 'indexedId', 'indexedType', 'indexedIndex', 'indexedPath')); - $this->_assertImplemented($filterDSL, 'geo_shape_provided', 'Elastica\Filter\GeoShapeProvided', array('path', array())); - $this->_assertImplemented($filterDSL, 'geohash_cell', 'Elastica\Filter\GeohashCell', array('field', 'location')); - $this->_assertImplemented($filterDSL, 'has_child', 'Elastica\Filter\HasChild', array(new Match(), 'type')); - $this->_assertImplemented($filterDSL, 'has_parent', 'Elastica\Filter\HasParent', array(new Match(), 'type')); - $this->_assertImplemented($filterDSL, 'ids', 'Elastica\Filter\Ids', array('type', array())); - $this->_assertImplemented($filterDSL, 'indices', 'Elastica\Filter\Indices', array(new Exists('field'), array())); - $this->_assertImplemented($filterDSL, 'limit', 'Elastica\Filter\Limit', array(1)); - $this->_assertImplemented($filterDSL, 'match_all', 'Elastica\Filter\MatchAll', array()); - $this->_assertImplemented($filterDSL, 'missing', 'Elastica\Filter\Missing', array('field')); - $this->_assertImplemented($filterDSL, 'nested', 'Elastica\Filter\Nested', array()); - $this->_assertImplemented($filterDSL, 'numeric_range', 'Elastica\Filter\NumericRange', array()); - $this->_assertImplemented($filterDSL, 'prefix', 'Elastica\Filter\Prefix', array('field', 'prefix')); - $this->_assertImplemented($filterDSL, 'query', 'Elastica\Filter\Query', array(new Match())); - $this->_assertImplemented($filterDSL, 'range', 'Elastica\Filter\Range', array('field', array())); - $this->_assertImplemented($filterDSL, 'regexp', 'Elastica\Filter\Regexp', array('field', 'regex')); - $this->_assertImplemented($filterDSL, 'script', 'Elastica\Filter\Script', array('script')); - $this->_assertImplemented($filterDSL, 'term', 'Elastica\Filter\Term', array()); - $this->_assertImplemented($filterDSL, 'terms', 'Elastica\Filter\Terms', array('field', array())); - $this->_assertImplemented($filterDSL, 'type', 'Elastica\Filter\Type', array('type')); + $this->_assertImplemented($filterDSL, 'bool', 'Elastica\Filter\BoolFilter', []); + $this->_assertImplemented($filterDSL, 'bool_and', 'Elastica\Filter\BoolAnd', [[new Exists('field')]]); + $this->_assertImplemented($filterDSL, 'bool_not', 'Elastica\Filter\BoolNot', [new Exists('field')]); + $this->_assertImplemented($filterDSL, 'bool_or', 'Elastica\Filter\BoolOr', [[new Exists('field')]]); + $this->_assertImplemented($filterDSL, 'exists', 'Elastica\Filter\Exists', ['field']); + $this->_assertImplemented($filterDSL, 'geo_bounding_box', 'Elastica\Filter\GeoBoundingBox', ['field', [1, 2]]); + $this->_assertImplemented($filterDSL, 'geo_distance', 'Elastica\Filter\GeoDistance', ['key', 'location', 'distance']); + $this->_assertImplemented($filterDSL, 'geo_distance_range', 'Elastica\Filter\GeoDistanceRange', ['key', 'location']); + $this->_assertImplemented($filterDSL, 'geo_polygon', 'Elastica\Filter\GeoPolygon', ['key', []]); + $this->_assertImplemented($filterDSL, 'geo_shape_pre_indexed', 'Elastica\Filter\GeoShapePreIndexed', ['path', 'indexedId', 'indexedType', 'indexedIndex', 'indexedPath']); + $this->_assertImplemented($filterDSL, 'geo_shape_provided', 'Elastica\Filter\GeoShapeProvided', ['path', []]); + $this->_assertImplemented($filterDSL, 'geohash_cell', 'Elastica\Filter\GeohashCell', ['field', 'location']); + $this->_assertImplemented($filterDSL, 'has_child', 'Elastica\Filter\HasChild', [new Match(), 'type']); + $this->_assertImplemented($filterDSL, 'has_parent', 'Elastica\Filter\HasParent', [new Match(), 'type']); + $this->_assertImplemented($filterDSL, 'ids', 'Elastica\Filter\Ids', ['type', []]); + $this->_assertImplemented($filterDSL, 'indices', 'Elastica\Filter\Indices', [new Exists('field'), []]); + $this->_assertImplemented($filterDSL, 'limit', 'Elastica\Filter\Limit', [1]); + $this->_assertImplemented($filterDSL, 'match_all', 'Elastica\Filter\MatchAll', []); + $this->_assertImplemented($filterDSL, 'missing', 'Elastica\Filter\Missing', ['field']); + $this->_assertImplemented($filterDSL, 'nested', 'Elastica\Filter\Nested', []); + $this->_assertImplemented($filterDSL, 'numeric_range', 'Elastica\Filter\NumericRange', []); + $this->_assertImplemented($filterDSL, 'prefix', 'Elastica\Filter\Prefix', ['field', 'prefix']); + $this->_assertImplemented($filterDSL, 'query', 'Elastica\Filter\Query', [new Match()]); + $this->_assertImplemented($filterDSL, 'range', 'Elastica\Filter\Range', ['field', []]); + $this->_assertImplemented($filterDSL, 'regexp', 'Elastica\Filter\Regexp', ['field', 'regex']); + $this->_assertImplemented($filterDSL, 'script', 'Elastica\Filter\Script', ['script']); + $this->_assertImplemented($filterDSL, 'term', 'Elastica\Filter\Term', []); + $this->_assertImplemented($filterDSL, 'terms', 'Elastica\Filter\Terms', ['field', []]); + $this->_assertImplemented($filterDSL, 'type', 'Elastica\Filter\Type', ['type']); $this->showDeprecated(); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php index 0735adc..1c2e0ac 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php @@ -1,5 +1,4 @@ finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query\ConstantScore passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\ConstantScore::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -77,11 +76,11 @@ public function testFilteredDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Use bool() instead. Filtered query is deprecated since ES 2.0.0-beta1 and this method will be removed in further Elastica releases.', 'Deprecated: Elastica\Query\Filtered passing AbstractFilter is deprecated. Pass AbstractQuery instead.', 'Deprecated: Elastica\Query\Filtered::setFilter passing AbstractFilter is deprecated. Pass AbstractQuery instead.', - ) + ] ); } @@ -92,52 +91,58 @@ public function testInterface() { $queryDSL = new DSL\Query(); - $this->_assertImplemented($queryDSL, 'bool', 'Elastica\Query\BoolQuery', array()); - $this->_assertImplemented($queryDSL, 'boosting', 'Elastica\Query\Boosting', array()); - $this->_assertImplemented($queryDSL, 'common_terms', 'Elastica\Query\Common', array('field', 'query', 0.001)); - $this->_assertImplemented($queryDSL, 'constant_score', 'Elastica\Query\ConstantScore', array(new Match())); - $this->_assertImplemented($queryDSL, 'dis_max', 'Elastica\Query\DisMax', array()); + $this->_assertImplemented($queryDSL, 'bool', 'Elastica\Query\BoolQuery', []); + $this->_assertImplemented($queryDSL, 'boosting', 'Elastica\Query\Boosting', []); + $this->_assertImplemented($queryDSL, 'common_terms', 'Elastica\Query\Common', ['field', 'query', 0.001]); + $this->_assertImplemented($queryDSL, 'constant_score', 'Elastica\Query\ConstantScore', [new Match()]); + $this->_assertImplemented($queryDSL, 'dis_max', 'Elastica\Query\DisMax', []); $this->hideDeprecated(); - $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', array(new Match(), new Exists('field'))); - $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', array(new Match(), new Term())); + $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', [new Match(), new Exists('field')]); + $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', [new Match(), new Term()]); $this->showDeprecated(); - $this->_assertImplemented($queryDSL, 'function_score', 'Elastica\Query\FunctionScore', array()); - $this->_assertImplemented($queryDSL, 'fuzzy', 'Elastica\Query\Fuzzy', array('field', 'type')); - $this->_assertImplemented($queryDSL, 'has_child', 'Elastica\Query\HasChild', array(new Match())); - $this->_assertImplemented($queryDSL, 'has_parent', 'Elastica\Query\HasParent', array(new Match(), 'type')); - $this->_assertImplemented($queryDSL, 'ids', 'Elastica\Query\Ids', array('type', array())); - $this->_assertImplemented($queryDSL, 'match', 'Elastica\Query\Match', array('field', 'values')); - $this->_assertImplemented($queryDSL, 'match_all', 'Elastica\Query\MatchAll', array()); - $this->_assertImplemented($queryDSL, 'more_like_this', 'Elastica\Query\MoreLikeThis', array()); - $this->_assertImplemented($queryDSL, 'multi_match', 'Elastica\Query\MultiMatch', array()); - $this->_assertImplemented($queryDSL, 'nested', 'Elastica\Query\Nested', array()); - $this->_assertImplemented($queryDSL, 'prefix', 'Elastica\Query\Prefix', array()); - $this->_assertImplemented($queryDSL, 'query_string', 'Elastica\Query\QueryString', array()); - $this->_assertImplemented($queryDSL, 'range', 'Elastica\Query\Range', array('field', array())); - $this->_assertImplemented($queryDSL, 'regexp', 'Elastica\Query\Regexp', array('field', 'value', 1.0)); - $this->_assertImplemented($queryDSL, 'simple_query_string', 'Elastica\Query\SimpleQueryString', array('query')); - $this->_assertImplemented($queryDSL, 'term', 'Elastica\Query\Term', array()); - $this->_assertImplemented($queryDSL, 'terms', 'Elastica\Query\Terms', array('field', array())); - $this->_assertImplemented($queryDSL, 'top_children', 'Elastica\Query\TopChildren', array(new Match(), 'type')); - $this->_assertImplemented($queryDSL, 'wildcard', 'Elastica\Query\Wildcard', array()); - - $this->_assertNotImplemented($queryDSL, 'custom_boost_factor', array()); - $this->_assertNotImplemented($queryDSL, 'custom_filters_score', array()); - $this->_assertNotImplemented($queryDSL, 'custom_score', array()); - $this->_assertNotImplemented($queryDSL, 'field', array()); - $this->_assertNotImplemented($queryDSL, 'geo_shape', array()); - $this->_assertNotImplemented($queryDSL, 'indices', array()); - $this->_assertNotImplemented($queryDSL, 'minimum_should_match', array()); - $this->_assertNotImplemented($queryDSL, 'more_like_this_field', array()); - $this->_assertNotImplemented($queryDSL, 'span_first', array()); - $this->_assertNotImplemented($queryDSL, 'span_multi_term', array()); - $this->_assertNotImplemented($queryDSL, 'span_near', array()); - $this->_assertNotImplemented($queryDSL, 'span_not', array()); - $this->_assertNotImplemented($queryDSL, 'span_or', array()); - $this->_assertNotImplemented($queryDSL, 'span_term', array()); - $this->_assertNotImplemented($queryDSL, 'template', array()); - $this->_assertNotImplemented($queryDSL, 'text', array()); + $this->_assertImplemented($queryDSL, 'function_score', 'Elastica\Query\FunctionScore', []); + $this->_assertImplemented($queryDSL, 'fuzzy', 'Elastica\Query\Fuzzy', ['field', 'type']); + $this->_assertImplemented($queryDSL, 'has_child', 'Elastica\Query\HasChild', [new Match()]); + $this->_assertImplemented($queryDSL, 'has_parent', 'Elastica\Query\HasParent', [new Match(), 'type']); + $this->_assertImplemented($queryDSL, 'ids', 'Elastica\Query\Ids', ['type', []]); + $this->_assertImplemented($queryDSL, 'match', 'Elastica\Query\Match', ['field', 'values']); + $this->_assertImplemented($queryDSL, 'match_all', 'Elastica\Query\MatchAll', []); + $this->_assertImplemented($queryDSL, 'more_like_this', 'Elastica\Query\MoreLikeThis', []); + $this->_assertImplemented($queryDSL, 'multi_match', 'Elastica\Query\MultiMatch', []); + $this->_assertImplemented($queryDSL, 'nested', 'Elastica\Query\Nested', []); + $this->_assertImplemented($queryDSL, 'prefix', 'Elastica\Query\Prefix', []); + $this->_assertImplemented($queryDSL, 'query_string', 'Elastica\Query\QueryString', []); + $this->_assertImplemented($queryDSL, 'range', 'Elastica\Query\Range', ['field', []]); + $this->_assertImplemented($queryDSL, 'regexp', 'Elastica\Query\Regexp', ['field', 'value', 1.0]); + $this->_assertImplemented($queryDSL, 'simple_query_string', 'Elastica\Query\SimpleQueryString', ['query']); + $this->_assertImplemented($queryDSL, 'term', 'Elastica\Query\Term', []); + $this->_assertImplemented($queryDSL, 'terms', 'Elastica\Query\Terms', ['field', []]); + $this->_assertImplemented($queryDSL, 'top_children', 'Elastica\Query\TopChildren', [new Match(), 'type']); + $this->_assertImplemented($queryDSL, 'wildcard', 'Elastica\Query\Wildcard', []); + $this->_assertImplemented( + $queryDSL, + 'geo_distance', + 'Elastica\Query\GeoDistance', + ['key', ['lat' => 1, 'lon' => 0], 'distance'] + ); + + $this->_assertNotImplemented($queryDSL, 'custom_boost_factor', []); + $this->_assertNotImplemented($queryDSL, 'custom_filters_score', []); + $this->_assertNotImplemented($queryDSL, 'custom_score', []); + $this->_assertNotImplemented($queryDSL, 'field', []); + $this->_assertNotImplemented($queryDSL, 'geo_shape', []); + $this->_assertNotImplemented($queryDSL, 'indices', []); + $this->_assertNotImplemented($queryDSL, 'minimum_should_match', []); + $this->_assertNotImplemented($queryDSL, 'more_like_this_field', []); + $this->_assertNotImplemented($queryDSL, 'span_first', []); + $this->_assertNotImplemented($queryDSL, 'span_multi_term', []); + $this->_assertNotImplemented($queryDSL, 'span_near', []); + $this->_assertNotImplemented($queryDSL, 'span_not', []); + $this->_assertNotImplemented($queryDSL, 'span_or', []); + $this->_assertNotImplemented($queryDSL, 'span_term', []); + $this->_assertNotImplemented($queryDSL, 'template', []); + $this->_assertNotImplemented($queryDSL, 'text', []); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php index 2bc4531..577b2ba 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php @@ -1,5 +1,4 @@ _assertImplemented($suggestDSL, 'completion', 'Elastica\Suggest\Completion', array('name', 'field')); - $this->_assertImplemented($suggestDSL, 'phrase', 'Elastica\Suggest\Phrase', array('name', 'field')); - $this->_assertImplemented($suggestDSL, 'term', 'Elastica\Suggest\Term', array('name', 'field')); + $this->_assertImplemented($suggestDSL, 'completion', 'Elastica\Suggest\Completion', ['name', 'field']); + $this->_assertImplemented($suggestDSL, 'phrase', 'Elastica\Suggest\Phrase', ['name', 'field']); + $this->_assertImplemented($suggestDSL, 'term', 'Elastica\Suggest\Term', ['name', 'field']); - $this->_assertNotImplemented($suggestDSL, 'context', array()); + $this->_assertNotImplemented($suggestDSL, 'context', []); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php index 0c8074d..ef51620 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php @@ -1,5 +1,4 @@ assertVersions($version, $dsl); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php index 1ee295d..2e508ce 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php @@ -1,5 +1,4 @@ finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query::create() passing filter is deprecated. Create query and use setPostFilter with AbstractQuery instead.', 'Deprecated: Elastica\Query::setPostFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -64,11 +63,11 @@ public function testSetFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query::setFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', 'Deprecated: Elastica\Query::setFilter() is deprecated and will be removed in further Elastica releases. Use Elastica\Query::setPostFilter() instead.', 'Deprecated: Elastica\Query::setPostFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -98,9 +97,9 @@ public function testSetPostFilterWithLegacyFilterDeprecated() $this->finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Query::setPostFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -150,12 +149,12 @@ public function testStringConversion() */ public function testRawQuery() { - $textQuery = new Term(array('title' => 'test')); + $textQuery = new Term(['title' => 'test']); $query1 = Query::create($textQuery); $query2 = new Query(); - $query2->setRawQuery(array('query' => array('term' => array('title' => 'test')))); + $query2->setRawQuery(['query' => ['term' => ['title' => 'test']]]); $this->assertEquals($query1->toArray(), $query2->toArray()); } @@ -195,18 +194,18 @@ public function testSetSuggestMustReturnQueryInstance() */ public function testArrayQuery() { - $query = array( - 'query' => array( - 'text' => array( + $query = [ + 'query' => [ + 'text' => [ 'title' => 'test', - ), - ), - ); + ], + ], + ]; $query1 = Query::create($query); $query2 = new Query(); - $query2->setRawQuery(array('query' => array('text' => array('title' => 'test')))); + $query2->setRawQuery(['query' => ['text' => ['title' => 'test']]]); $this->assertEquals($query1->toArray(), $query2->toArray()); } @@ -219,11 +218,11 @@ public function testSetSort() $index = $this->_createIndex(); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'hello world')), - new Document(2, array('firstname' => 'guschti', 'lastname' => 'ruflin')), - new Document(3, array('firstname' => 'nicolas', 'lastname' => 'ruflin')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'hello world']), + new Document(2, ['firstname' => 'guschti', 'lastname' => 'ruflin']), + new Document(3, ['firstname' => 'nicolas', 'lastname' => 'ruflin']), + ]); $queryTerm = new Term(); $queryTerm->setTerm('lastname', 'ruflin'); @@ -233,7 +232,7 @@ public function testSetSort() $query = Query::create($queryTerm); // ASC order - $query->setSort(array(array('firstname' => array('order' => 'asc')))); + $query->setSort([['firstname' => ['order' => 'asc']]]); $resultSet = $type->search($query); $this->assertEquals(2, $resultSet->count()); @@ -244,7 +243,7 @@ public function testSetSort() $this->assertEquals('nicolas', $second['firstname']); // DESC order - $query->setSort(array('firstname' => array('order' => 'desc'))); + $query->setSort(['firstname' => ['order' => 'desc']]); $resultSet = $type->search($query); $this->assertEquals(2, $resultSet->count()); @@ -261,10 +260,10 @@ public function testSetSort() public function testAddSort() { $query = new Query(); - $sortParam = array('firstname' => array('order' => 'asc')); + $sortParam = ['firstname' => ['order' => 'asc']]; $query->addSort($sortParam); - $this->assertEquals($query->getParam('sort'), array($sortParam)); + $this->assertEquals($query->getParam('sort'), [$sortParam]); } /** @@ -274,7 +273,7 @@ public function testSetRawQuery() { $query = new Query(); - $params = array('query' => 'test'); + $params = ['query' => 'test']; $query->setRawQuery($params); $this->assertEquals($params, $query->toArray()); @@ -287,9 +286,9 @@ public function testSetFields() { $query = new Query(); - $params = array('query' => 'test'); + $params = ['query' => 'test']; - $query->setFields(array('firstname', 'lastname')); + $query->setFields(['firstname', 'lastname']); $data = $query->toArray(); @@ -409,6 +408,31 @@ public function testAddScriptFieldsToArrayCast() $this->assertEquals($query->toArray(), $anotherQuery->toArray()); } + /** + * @group unit + */ + public function testAddScriptFieldToExistingScriptFields() + { + $script1 = new Script('s1'); + $script2 = new Script('s2'); + + // add script1, then add script2 + $query = new Query(); + $scriptFields1 = new ScriptFields(); + $scriptFields1->addScript('script1', $script1); + $query->setScriptFields($scriptFields1); + $query->addScriptField('script2', $script2); + + // add script1 and script2 at once + $anotherQuery = new Query(); + $scriptFields2 = new ScriptFields(); + $scriptFields2->addScript('script1', $script1); + $scriptFields2->addScript('script2', $script2); + $anotherQuery->setScriptFields($scriptFields2); + + $this->assertEquals($query->toArray(), $anotherQuery->toArray()); + } + /** * @group unit */ @@ -473,10 +497,10 @@ public function testSetPostFilterToArrayCast() { $query = new Query(); $postFilter = new \Elastica\Query\Terms(); - $postFilter->setTerms('key', array('term')); + $postFilter->setTerms('key', ['term']); $query->setPostFilter($postFilter); - $postFilter->setTerms('another key', array('another term')); + $postFilter->setTerms('another key', ['another term']); $anotherQuery = new Query(); $anotherQuery->setPostFilter($postFilter); @@ -493,10 +517,10 @@ public function testLegacySetPostFilterToArrayCast() $query = new Query(); $postFilter = new \Elastica\Filter\Terms(); - $postFilter->setTerms('key', array('term')); + $postFilter->setTerms('key', ['term']); $query->setPostFilter($postFilter); - $postFilter->setTerms('another key', array('another term')); + $postFilter->setTerms('another key', ['another term']); $anotherQuery = new Query(); $anotherQuery->setPostFilter($postFilter); @@ -516,7 +540,7 @@ public function testNoSource() // Adds 1 document to the index $doc1 = new Document(1, - array('username' => 'ruflin', 'test' => array('2', '3', '5')) + ['username' => 'ruflin', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php index cbb1e48..bcaa32d 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php @@ -1,5 +1,4 @@ 'params'); - $data = array('key' => 'value'); + $query = ['no' => 'params']; + $data = ['key' => 'value']; $request = new Request($path, $method, $data, $query); @@ -45,7 +44,7 @@ public function testSend() $connection->setHost($this->_getHost()); $connection->setPort('9200'); - $request = new Request('_stats', Request::GET, array(), array(), $connection); + $request = new Request('_stats', Request::GET, [], [], $connection); $response = $request->send(); @@ -59,8 +58,8 @@ public function testToString() { $path = 'test'; $method = Request::POST; - $query = array('no' => 'params'); - $data = array('key' => 'value'); + $query = ['no' => 'params']; + $data = ['key' => 'value']; $connection = new Connection(); $connection->setHost($this->_getHost()); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php index 578cdf3..dc3489b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('helloworld'); - $mapping = new Mapping($type, array( - 'name' => array('type' => 'string', 'store' => 'no'), - 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'), - )); + $mapping = new Mapping($type, [ + 'name' => ['type' => 'string', 'store' => 'no'], + 'dtmPosted' => ['type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'], + ]); $type->setMapping($mapping); - $type->addDocuments(array( - new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00')), - new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00')), - new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00')), - new Document(4, array('name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00']), + new Document(2, ['name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00']), + new Document(3, ['name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00']), + new Document(4, ['name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00']), + ]); $query = new Query(); $query->setQuery(new MatchAll()); @@ -56,7 +55,7 @@ public function testIsOk() $index = $this->_createIndex(); $type = $index->getType('test'); - $doc = new Document(1, array('name' => 'ruflin')); + $doc = new Document(1, ['name' => 'ruflin']); $response = $type->addDocument($doc); $this->assertTrue($response->isOk()); @@ -70,10 +69,10 @@ public function testIsOkMultiple() $index = $this->_createIndex(); $type = $index->getType('test'); - $docs = array( - new Document(1, array('name' => 'ruflin')), - new Document(2, array('name' => 'ruflin')), - ); + $docs = [ + new Document(1, ['name' => 'ruflin']), + new Document(2, ['name' => 'ruflin']), + ]; $response = $type->addDocuments($docs); $this->assertTrue($response->isOk()); @@ -84,14 +83,14 @@ public function testIsOkMultiple() */ public function testIsOkBulkWithErrorsField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, 'errors' => false, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200]], + ], + ])); $this->assertTrue($response->isOk()); } @@ -101,14 +100,14 @@ public function testIsOkBulkWithErrorsField() */ public function testIsNotOkBulkWithErrorsField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, 'errors' => true, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200]], + ], + ])); $this->assertFalse($response->isOk()); } @@ -118,13 +117,13 @@ public function testIsNotOkBulkWithErrorsField() */ public function testIsOkBulkItemsWithOkField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => true)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => true]], + ], + ])); $this->assertTrue($response->isOk()); } @@ -134,9 +133,9 @@ public function testIsOkBulkItemsWithOkField() */ public function testStringErrorMessage() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'error' => 'a', - ))); + ])); $this->assertEquals('a', $response->getErrorMessage()); } @@ -146,11 +145,11 @@ public function testStringErrorMessage() */ public function testArrayErrorMessage() { - $response = new Response(json_encode(array( - 'error' => array('a', 'b'), - ))); + $response = new Response(json_encode([ + 'error' => ['a', 'b'], + ])); - $this->assertEquals(array('a', 'b'), $response->getFullError()); + $this->assertEquals(['a', 'b'], $response->getFullError()); } /** @@ -158,13 +157,13 @@ public function testArrayErrorMessage() */ public function testIsNotOkBulkItemsWithOkField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => false)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => false]], + ], + ])); $this->assertFalse($response->isOk()); } @@ -174,13 +173,13 @@ public function testIsNotOkBulkItemsWithOkField() */ public function testIsOkBulkItemsWithStatusField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200]], + ], + ])); $this->assertTrue($response->isOk()); } @@ -190,13 +189,13 @@ public function testIsOkBulkItemsWithStatusField() */ public function testIsNotOkBulkItemsWithStatusField() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 301)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 301]], + ], + ])); $this->assertFalse($response->isOk()); } @@ -206,13 +205,13 @@ public function testIsNotOkBulkItemsWithStatusField() */ public function testDecodeResponseWithBigIntSetToTrue() { - $response = new Response(json_encode(array( + $response = new Response(json_encode([ 'took' => 213, - 'items' => array( - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)), - array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)), - ), - ))); + 'items' => [ + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200]], + ['index' => ['_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200]], + ], + ])); $response->setJsonBigintConversion(true); $this->assertTrue(is_array($response->getData())); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/BuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/BuilderTest.php new file mode 100644 index 0000000..de5ce37 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/BuilderTest.php @@ -0,0 +1,57 @@ +builder = new DefaultBuilder(); + } + + public function testEmptyResponse() + { + $response = new Response(''); + $query = new Query(); + + $resultSet = $this->builder->buildResultSet($response, $query); + + $this->assertSame($response, $resultSet->getResponse()); + $this->assertSame($query, $resultSet->getQuery()); + $this->assertCount(0, $resultSet->getResults()); + } + + public function testResponse() + { + $response = new Response([ + 'hits' => [ + 'hits' => [ + ['test' => 1], + ['test' => 2], + ['test' => 3], + ], + ], + ]); + $query = new Query(); + + $resultSet = $this->builder->buildResultSet($response, $query); + + $this->assertSame($response, $resultSet->getResponse()); + $this->assertSame($query, $resultSet->getQuery()); + $this->assertCount(3, $resultSet->getResults()); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ChainProcessorTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ChainProcessorTest.php new file mode 100644 index 0000000..b546640 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ChainProcessorTest.php @@ -0,0 +1,32 @@ +getMock('Elastica\\ResultSet\\ProcessorInterface'), + $processor2 = $this->getMock('Elastica\\ResultSet\\ProcessorInterface'), + ]); + $resultSet = new ResultSet(new Response(''), new Query(), []); + + $processor1->expects($this->once()) + ->method('process') + ->with($resultSet); + $processor2->expects($this->once()) + ->method('process') + ->with($resultSet); + + $processor->process($resultSet); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ProcessingBuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ProcessingBuilderTest.php new file mode 100644 index 0000000..a2c51b4 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSet/ProcessingBuilderTest.php @@ -0,0 +1,56 @@ +innerBuilder = $this->getMock('Elastica\\ResultSet\\BuilderInterface'); + $this->processor = $this->getMock('Elastica\\ResultSet\\ProcessorInterface'); + + $this->builder = new ResultSet\ProcessingBuilder($this->innerBuilder, $this->processor); + } + + public function testProcessors() + { + $response = new Response(''); + $query = new Query(); + $resultSet = new ResultSet($response, $query, []); + + $this->innerBuilder->expects($this->once()) + ->method('buildResultSet') + ->with($response, $query) + ->willReturn($resultSet); + $this->processor->expects($this->once()) + ->method('process') + ->with($resultSet); + + $this->builder->buildResultSet($response, $query); + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php index ea7b4a5..9526fef 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'elastica search')), - new Document(2, array('name' => 'elastica library')), - new Document(3, array('name' => 'elastica test')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'elastica search']), + new Document(2, ['name' => 'elastica library']), + new Document(3, ['name' => 'elastica test']), + ]); $index->refresh(); $resultSet = $type->search('elastica search'); @@ -40,11 +39,11 @@ public function testArrayAccess() $index = $this->_createIndex(); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'elastica search')), - new Document(2, array('name' => 'elastica library')), - new Document(3, array('name' => 'elastica test')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'elastica search']), + new Document(2, ['name' => 'elastica library']), + new Document(3, ['name' => 'elastica test']), + ]); $index->refresh(); $resultSet = $type->search('elastica search'); @@ -65,11 +64,11 @@ public function testDocumentsAccess() $index = $this->_createIndex(); $type = $index->getType('test'); - $type->addDocuments(array( - new Document(1, array('name' => 'elastica search')), - new Document(2, array('name' => 'elastica library')), - new Document(3, array('name' => 'elastica test')), - )); + $type->addDocuments([ + new Document(1, ['name' => 'elastica search']), + new Document(2, ['name' => 'elastica library']), + new Document(3, ['name' => 'elastica test']), + ]); $index->refresh(); $resultSet = $type->search('elastica search'); @@ -96,13 +95,13 @@ public function testInvalidOffsetCreation() $index = $this->_createIndex(); $type = $index->getType('test'); - $doc = new Document(1, array('name' => 'elastica search')); + $doc = new Document(1, ['name' => 'elastica search']); $type->addDocument($doc); $index->refresh(); $resultSet = $type->search('elastica search'); - $result = new Result(array('_id' => 'fakeresult')); + $result = new Result(['_id' => 'fakeresult']); $resultSet[1] = $result; } @@ -115,7 +114,7 @@ public function testInvalidOffsetGet() $index = $this->_createIndex(); $type = $index->getType('test'); - $doc = new Document(1, array('name' => 'elastica search')); + $doc = new Document(1, ['name' => 'elastica search']); $type->addDocument($doc); $index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php index 769a512..ac5fe2b 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php @@ -1,5 +1,4 @@ 'hans')); + $doc1 = new Document($docId, ['username' => 'hans']); $type->addDocument($doc1); // Refreshes index @@ -56,7 +55,7 @@ public function testGetIdNoSource() $client = $this->_getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $type = $index->getType($typeName); $mapping = new Mapping($type); @@ -65,7 +64,7 @@ public function testGetIdNoSource() // Adds 1 document to the index $docId = 3; - $doc1 = new Document($docId, array('username' => 'hans')); + $doc1 = new Document($docId, ['username' => 'hans']); $type->addDocument($doc1); // Refreshes index @@ -77,7 +76,7 @@ public function testGetIdNoSource() $result = $resultSet->current(); - $this->assertEquals(array(), $result->getSource()); + $this->assertEquals([], $result->getSource()); $this->assertInstanceOf('Elastica\Result', $result); $this->assertEquals($indexName, $result->getIndex()); $this->assertEquals($typeName, $result->getType()); @@ -97,7 +96,7 @@ public function testGetTotalTimeReturnsExpectedResults() // Adds 1 document to the index $docId = 3; - $doc1 = new Document($docId, array('username' => 'hans')); + $doc1 = new Document($docId, ['username' => 'hans']); $type->addDocument($doc1); // Refreshes index @@ -118,15 +117,15 @@ public function testGetTotalTimeReturnsExpectedResults() */ public function testHasFields() { - $data = array('value set'); + $data = ['value set']; - $result = new Result(array()); + $result = new Result([]); $this->assertFalse($result->hasFields()); - $result = new Result(array('_source' => $data)); + $result = new Result(['_source' => $data]); $this->assertFalse($result->hasFields()); - $result = new Result(array('fields' => $data)); + $result = new Result(['fields' => $data]); $this->assertTrue($result->hasFields()); $this->assertEquals($data, $result->getFields()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php index def02e1..06d4e5c 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php @@ -1,5 +1,4 @@ _createIndex('', true, 2); $index->refresh(); - $docs = array(); + $docs = []; for ($x = 1; $x <= 12; ++$x) { - $docs[] = new Document($x, array('id' => $x, 'key' => 'value')); + $docs[] = new Document($x, ['id' => $x, 'key' => 'value']); } $type = $index->getType('scanAndScrollTest'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFieldsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFieldsTest.php index fabbde0..ac937aa 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFieldsTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFieldsTest.php @@ -1,5 +1,4 @@ setScripts(array( + $scriptFields->setScripts([ 'test' => $script, - )); + ]); $this->assertSame($scriptFields->getParam('test'), $script); // Constructor - $scriptFields = new ScriptFields(array( + $scriptFields = new ScriptFields([ 'test' => $script, - )); + ]); $this->assertSame($scriptFields->getParam('test'), $script); } @@ -44,15 +43,15 @@ public function testSetScriptFields() $query = new Query(); $script = new Script('1 + 2'); - $scriptFields = new ScriptFields(array( + $scriptFields = new ScriptFields([ 'test' => $script, - )); + ]); $query->setScriptFields($scriptFields); $this->assertSame($query->getParam('script_fields'), $scriptFields); - $query->setScriptFields(array( + $query->setScriptFields([ 'test' => $script, - )); + ]); $this->assertSame($query->getParam('script_fields')->getParam('test'), $script); } @@ -63,7 +62,7 @@ public function testSetScriptFields() public function testNameException() { $script = new Script('1 + 2'); - $scriptFields = new ScriptFields(array($script)); + $scriptFields = new ScriptFields([$script]); } /** @@ -77,15 +76,15 @@ public function testQuery() $type = $index->getType('test'); - $doc = new Document(1, array('firstname' => 'guschti', 'lastname' => 'ruflin')); + $doc = new Document(1, ['firstname' => 'guschti', 'lastname' => 'ruflin']); $type->addDocument($doc); $index->refresh(); $query = new Query(); $script = new Script('1 + 2'); - $scriptFields = new ScriptFields(array( + $scriptFields = new ScriptFields([ 'test' => $script, - )); + ]); $query->setScriptFields($scriptFields); $resultSet = $type->search($query); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFileTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFileTest.php index 5e32d89..7c01ab2 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFileTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptFileTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('test'); - $type->setMapping(new Mapping(null, array( - 'location' => array('type' => 'geo_point'), - ))); + $type->setMapping(new Mapping(null, [ + 'location' => ['type' => 'geo_point'], + ])); - $type->addDocuments(array( - new Document(1, array('location' => array('lat' => 48.8825968, 'lon' => 2.3706111))), - new Document(2, array('location' => array('lat' => 48.9057932, 'lon' => 2.2739735))), - )); + $type->addDocuments([ + new Document(1, ['location' => ['lat' => 48.8825968, 'lon' => 2.3706111]]), + new Document(2, ['location' => ['lat' => 48.9057932, 'lon' => 2.2739735]]), + ]); $index->refresh(); - $scriptFile = new ScriptFile('calculate-distance', array('lat' => 48.858859, 'lon' => 2.3470599)); + $scriptFile = new ScriptFile('calculate-distance', ['lat' => 48.858859, 'lon' => 2.3470599]); $query = new Query(); $query->addScriptField('distance', $scriptFile); @@ -49,8 +48,8 @@ public function testSearch() $results = $resultSet->getResults(); $this->assertEquals(2, $resultSet->count()); - $this->assertEquals(array(3.149406767298327), $results[0]->__get('distance')); - $this->assertEquals(array(7.4639790751755726), $results[1]->__get('distance')); + $this->assertEquals([3.149406767298327], $results[0]->__get('distance')); + $this->assertEquals([7.4639790751755726], $results[1]->__get('distance')); } /** @@ -61,23 +60,23 @@ public function testConstructor() $value = 'calculate-distance.groovy'; $scriptFile = new ScriptFile($value); - $expected = array( + $expected = [ 'script_file' => $value, - ); + ]; $this->assertEquals($value, $scriptFile->getScriptFile()); $this->assertEquals($expected, $scriptFile->toArray()); - $params = array( + $params = [ 'param1' => 'one', 'param2' => 10, - ); + ]; $scriptFile = new ScriptFile($value, $params); - $expected = array( + $expected = [ 'script_file' => $value, 'params' => $params, - ); + ]; $this->assertEquals($value, $scriptFile->getScriptFile()); $this->assertEquals($params, $scriptFile->getParams()); @@ -96,9 +95,9 @@ public function testCreateString() $this->assertEquals($string, $scriptFile->getScriptFile()); - $expected = array( + $expected = [ 'script_file' => $string, - ); + ]; $this->assertEquals($expected, $scriptFile->toArray()); } @@ -121,14 +120,14 @@ public function testCreateScriptFile() public function testCreateArray() { $string = 'calculate-distance.groovy'; - $params = array( + $params = [ 'param1' => 'one', 'param2' => 1, - ); - $array = array( + ]; + $array = [ 'script_file' => $string, 'params' => $params, - ); + ]; $scriptFile = ScriptFile::create($array); @@ -155,17 +154,17 @@ public function testCreateInvalid($data) */ public function dataProviderCreateInvalid() { - return array( - array( + return [ + [ new \stdClass(), - ), - array( - array('params' => array('param1' => 'one')), - ), - array( - array('script' => 'calculate-distance.groovy', 'params' => 'param'), - ), - ); + ], + [ + ['params' => ['param1' => 'one']], + ], + [ + ['script' => 'calculate-distance.groovy', 'params' => 'param'], + ], + ]; } /** diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptTest.php index ad29421..1bc9b7d 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Script/ScriptTest.php @@ -1,5 +1,4 @@ $value, - ); + ]; $this->assertEquals($value, $script->getScript()); $this->assertEquals($expected, $script->toArray()); - $params = array( + $params = [ 'param1' => 'one', 'param2' => 10, - ); + ]; $script = new Script($value, $params); - $expected = array( + $expected = [ 'script' => $value, 'params' => $params, - ); + ]; $this->assertEquals($value, $script->getScript()); $this->assertEquals($params, $script->getParams()); @@ -41,11 +40,11 @@ public function testConstructor() $script = new Script($value, $params, $lang); - $expected = array( + $expected = [ 'script' => $value, 'params' => $params, 'lang' => $lang, - ); + ]; $this->assertEquals($value, $script->getScript()); $this->assertEquals($params, $script->getParams()); @@ -65,9 +64,9 @@ public function testCreateString() $this->assertEquals($string, $script->getScript()); - $expected = array( + $expected = [ 'script' => $string, - ); + ]; $this->assertEquals($expected, $script->toArray()); } @@ -91,15 +90,15 @@ public function testCreateArray() { $string = '_score * 2.0'; $lang = 'mvel'; - $params = array( + $params = [ 'param1' => 'one', 'param2' => 1, - ); - $array = array( + ]; + $array = [ 'script' => $string, 'lang' => $lang, 'params' => $params, - ); + ]; $script = Script::create($array); @@ -127,17 +126,17 @@ public function testCreateInvalid($data) */ public function dataProviderCreateInvalid() { - return array( - array( + return [ + [ new \stdClass(), - ), - array( - array('params' => array('param1' => 'one')), - ), - array( - array('script' => '_score * 2.0', 'params' => 'param'), - ), - ); + ], + [ + ['params' => ['param1' => 'one']], + ], + [ + ['script' => '_score * 2.0', 'params' => 'param'], + ], + ]; } /** @@ -145,7 +144,7 @@ public function dataProviderCreateInvalid() */ public function testSetLang() { - $script = new Script('foo', array(), Script::LANG_GROOVY); + $script = new Script('foo', [], Script::LANG_GROOVY); $this->assertEquals(Script::LANG_GROOVY, $script->getLang()); $script->setLang(Script::LANG_PYTHON); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php index 72fb611..5b945b8 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php @@ -1,5 +1,4 @@ _createIndex(); $index->refresh(); - $docs = array(); + $docs = []; for ($x = 1; $x <= 11; ++$x) { - $docs[] = new Document($x, array('id' => $x, 'key' => 'value')); + $docs[] = new Document($x, ['id' => $x, 'key' => 'value']); } $type = $index->getType('scrollTest'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php index c9cecba..90d6335 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php @@ -1,5 +1,4 @@ finishCollectErrors(); $errorsCollector->assertOnlyDeprecatedErrors( - array( + [ 'Deprecated: Elastica\Search::setQuery() passing AbstractFilter is deprecated. Create query and use setPostFilter with AbstractQuery instead.', 'Deprecated: Elastica\Query::create() passing filter is deprecated. Create query and use setPostFilter with AbstractQuery instead.', 'Deprecated: Elastica\Query::setPostFilter() passing filter as AbstractFilter is deprecated. Pass instance of AbstractQuery instead.', - ) + ] ); } @@ -94,7 +93,7 @@ public function testAddIndices() $client = $this->_getClient(); $search = new Search($client); - $indices = array(); + $indices = []; $indices[] = $client->getIndex('elastica_test1'); $indices[] = $client->getIndex('elastica_test2'); @@ -116,7 +115,7 @@ public function testAddType() $type1 = $index->getType('type1'); $type2 = $index->getType('type2'); - $this->assertEquals(array(), $search->getTypes()); + $this->assertEquals([], $search->getTypes()); $search->addType($type1); $types = $search->getTypes(); @@ -149,7 +148,7 @@ public function testAddTypes() $index = $client->getIndex('foo'); - $types = array(); + $types = []; $types[] = $index->getType('type1'); $types[] = $index->getType('type2'); @@ -247,22 +246,22 @@ public function testSearchRequest() $type1 = $index1->getType('hello1'); - $result = $search1->search(array()); + $result = $search1->search([]); $this->assertFalse($result->getResponse()->hasError()); $search1->addIndex($index1); - $result = $search1->search(array()); + $result = $search1->search([]); $this->assertFalse($result->getResponse()->hasError()); $search1->addIndex($index2); - $result = $search1->search(array()); + $result = $search1->search([]); $this->assertFalse($result->getResponse()->hasError()); $search1->addType($type1); - $result = $search1->search(array()); + $result = $search1->search([]); $this->assertFalse($result->getResponse()->hasError()); } @@ -276,9 +275,9 @@ public function testSearchScrollRequest() $index = $this->_createIndex(); $type = $index->getType('scrolltest'); - $docs = array(); + $docs = []; for ($x = 1; $x <= 10; ++$x) { - $docs[] = new Document($x, array('id' => $x, 'testscroll' => 'jbafford')); + $docs[] = new Document($x, ['id' => $x, 'testscroll' => 'jbafford']); } $type->addDocuments($docs); @@ -286,11 +285,11 @@ public function testSearchScrollRequest() $search = new Search($client); $search->addIndex($index)->addType($type); - $result = $search->search(array(), array( + $result = $search->search([], [ Search::OPTION_SEARCH_TYPE => Search::OPTION_SEARCH_TYPE_SCAN, Search::OPTION_SCROLL => '5m', Search::OPTION_SIZE => 5, - )); + ]); $this->assertFalse($result->getResponse()->hasError()); $scrollId = $result->getResponse()->getScrollId(); @@ -300,28 +299,28 @@ public function testSearchScrollRequest() //So we should get two results of 5 items, and then no items //We should also have sent the raw scroll_id as the HTTP request body $search = new Search($client); - $result = $search->search(array(), array( + $result = $search->search([], [ Search::OPTION_SCROLL => '5m', Search::OPTION_SCROLL_ID => $scrollId, - )); + ]); $this->assertFalse($result->getResponse()->hasError()); $this->assertEquals(5, count($result->getResults())); $this->assertArrayNotHasKey(Search::OPTION_SCROLL_ID, $search->getClient()->getLastRequest()->getQuery()); $this->assertEquals($scrollId, $search->getClient()->getLastRequest()->getData()); - $result = $search->search(array(), array( + $result = $search->search([], [ Search::OPTION_SCROLL => '5m', Search::OPTION_SCROLL_ID => $scrollId, - )); + ]); $this->assertFalse($result->getResponse()->hasError()); $this->assertEquals(5, count($result->getResults())); $this->assertArrayNotHasKey(Search::OPTION_SCROLL_ID, $search->getClient()->getLastRequest()->getQuery()); $this->assertEquals($scrollId, $search->getClient()->getLastRequest()->getData()); - $result = $search->search(array(), array( + $result = $search->search([], [ Search::OPTION_SCROLL => '5m', Search::OPTION_SCROLL_ID => $scrollId, - )); + ]); $this->assertFalse($result->getResponse()->hasError()); $this->assertEquals(0, count($result->getResults())); $this->assertArrayNotHasKey(Search::OPTION_SCROLL_ID, $search->getClient()->getLastRequest()->getQuery()); @@ -339,22 +338,22 @@ public function testLimitDefaultSearch() $search = new Search($client); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); $type = $index->getType('zeroType'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + ]); $index->refresh(); $search->addIndex($index)->addType($type); @@ -378,11 +377,11 @@ public function testArrayConfigSearch() $search = new Search($client); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); - $docs = array(); + $docs = []; for ($i = 0; $i < 11; ++$i) { - $docs[] = new Document($i, array('id' => 1, 'email' => 'test@test.com', 'username' => 'test')); + $docs[] = new Document($i, ['id' => 1, 'email' => 'test@test.com', 'username' => 'test']); } $type = $index->getType('zeroType'); @@ -400,31 +399,31 @@ public function testArrayConfigSearch() $this->assertEquals(1, $resultSet->count()); //Array with limit - $resultSet = $search->search('test', array('limit' => 2)); + $resultSet = $search->search('test', ['limit' => 2]); $this->assertEquals(2, $resultSet->count()); //Array with size - $resultSet = $search->search('test', array('size' => 2)); + $resultSet = $search->search('test', ['size' => 2]); $this->assertEquals(2, $resultSet->count()); //Array with from - $resultSet = $search->search('test', array('from' => 10)); + $resultSet = $search->search('test', ['from' => 10]); $this->assertEquals(10, $resultSet->current()->getId()); //Array with routing - $resultSet = $search->search('test', array('routing' => 'r1,r2')); + $resultSet = $search->search('test', ['routing' => 'r1,r2']); $this->assertEquals(10, $resultSet->count()); //Array with limit and routing - $resultSet = $search->search('test', array('limit' => 5, 'routing' => 'r1,r2')); + $resultSet = $search->search('test', ['limit' => 5, 'routing' => 'r1,r2']); $this->assertEquals(5, $resultSet->count()); //Search types - $resultSet = $search->search('test', array('limit' => 5, 'search_type' => 'count')); + $resultSet = $search->search('test', ['limit' => 5, 'search_type' => 'count']); $this->assertTrue(($resultSet->count() === 0) && $resultSet->getTotalHits() === 11); //Timeout - this one is a bit more tricky to test - $mockResponse = new \Elastica\Response(json_encode(array('timed_out' => true))); + $mockResponse = new \Elastica\Response(json_encode(['timed_out' => true])); $client = $this->getMockBuilder('Elastica\\Client') ->disableOriginalConstructor() ->getMock(); @@ -434,11 +433,11 @@ public function testArrayConfigSearch() $script = new Script('Thread.sleep(100); return _score;'); $query = new FunctionScore(); $query->addScriptScoreFunction($script); - $resultSet = $search->search($query, array('timeout' => 50)); + $resultSet = $search->search($query, ['timeout' => 50]); $this->assertTrue($resultSet->hasTimedOut()); // Throws InvalidException - $resultSet = $search->search('test', array('invalid_option' => 'invalid_option_value')); + $resultSet = $search->search('test', ['invalid_option' => 'invalid_option_value']); } /** @@ -447,7 +446,7 @@ public function testArrayConfigSearch() public function testSearchWithVersionOption() { $index = $this->_createIndex(); - $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin')); + $doc = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin']); $index->getType('test')->addDocument($doc); $index->refresh(); @@ -457,10 +456,10 @@ public function testSearchWithVersionOption() // Version param should not be inside by default $results = $search->search(new MatchAll()); $hit = $results->current(); - $this->assertEquals(array(), $hit->getParam('_version')); + $this->assertEquals([], $hit->getParam('_version')); // Added version param to result - $results = $search->search(new MatchAll(), array('version' => true)); + $results = $search->search(new MatchAll(), ['version' => true]); $hit = $results->current(); $this->assertEquals(1, $hit->getParam('_version')); } @@ -474,22 +473,22 @@ public function testCountRequest() $search = new Search($client); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); $type = $index->getType('zeroType'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'marley']), + ]); $index->refresh(); $search->addIndex($index)->addType($type); @@ -519,21 +518,21 @@ public function testEmptySearch() $search = new Search($client); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); $type = $index->getType('zeroType'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')), - new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')), - new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')), - new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')), - new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']), + new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']), + new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']), + new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']), + new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'bunny']), + ]); $index->refresh(); $search->addIndex($index)->addType($type); @@ -562,7 +561,7 @@ public function testCount() $search = new Search($index->getClient()); $type = $index->getType('test'); - $doc = new Document(1, array('id' => 1, 'username' => 'ruflin')); + $doc = new Document(1, ['id' => 1, 'username' => 'ruflin']); $type->addDocument($doc); $index->refresh(); @@ -608,7 +607,7 @@ public function testIgnoreUnavailableOption() $error = $exception->getResponse()->getFullError(); $this->assertEquals('index_not_found_exception', $error['type']); - $results = $search->search($query, array(Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true)); + $results = $search->search($query, [Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true]); $this->assertInstanceOf('\Elastica\ResultSet', $results); } } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php index e65b5de..5d4ccf3 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php @@ -1,5 +1,4 @@ _snapshot = new Snapshot($this->_getClient()); $this->_index = $this->_createIndex(); - $this->_docs = array( - new Document('1', array('city' => 'San Diego')), - new Document('2', array('city' => 'San Luis Obispo')), - new Document('3', array('city' => 'San Francisco')), - ); + $this->_docs = [ + new Document('1', ['city' => 'San Diego']), + new Document('2', ['city' => 'San Luis Obispo']), + new Document('3', ['city' => 'San Francisco']), + ]; $this->_index->getType('test')->addDocuments($this->_docs); $this->_index->refresh(); } @@ -49,7 +48,7 @@ public function testRegisterRepository() $repositoryName = 'testrepo'; $location = $this->_snapshotPath.'backup1'; - $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location)); + $response = $this->_snapshot->registerRepository($repositoryName, 'fs', ['location' => $location]); $this->assertTrue($response->isOk()); $response = $this->_snapshot->getRepository($repositoryName); @@ -69,12 +68,12 @@ public function testSnapshotAndRestore() $location = $this->_snapshotPath.'backup2'; // register the repository - $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location)); + $response = $this->_snapshot->registerRepository($repositoryName, 'fs', ['location' => $location]); $this->assertTrue($response->isOk()); // create a snapshot of our test index $snapshotName = 'test_snapshot_1'; - $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true); + $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, ['indices' => $this->_index->getName()], true); // ensure that the snapshot was created properly $this->assertTrue($response->isOk()); @@ -92,7 +91,7 @@ public function testSnapshotAndRestore() $this->_index->delete(); // restore the index from our snapshot - $response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, array(), true); + $response = $this->_snapshot->restoreSnapshot($repositoryName, $snapshotName, [], true); $this->assertTrue($response->isOk()); $this->_index->refresh(); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php index 6e82bbd..cd34509 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex($indexName); - $index->create(array(), true); + $index->create([], true); $index = $this->_createIndex(); $index->refresh(); $index->optimize(); @@ -91,7 +90,7 @@ public function testAliasExists() $this->assertTrue($status->aliasExists($aliasName)); $indicesWithAlias = $status->getIndicesWithAlias($aliasName); - $this->assertEquals(array($indexName), array_map( + $this->assertEquals([$indexName], array_map( function ($index) { return $index->getName(); }, $indicesWithAlias)); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php index 87c177f..308d0e9 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('song'); - $type->setMapping(array( - 'fieldName' => array( + $type->setMapping([ + 'fieldName' => [ 'type' => 'completion', 'payloads' => true, - ), - )); + ], + ]); - $type->addDocuments(array( - new Document(1, array( - 'fieldName' => array( - 'input' => array('Nevermind', 'Nirvana'), + $type->addDocuments([ + new Document(1, [ + 'fieldName' => [ + 'input' => ['Nevermind', 'Nirvana'], 'output' => 'Nevermind - Nirvana', - 'payload' => array( + 'payload' => [ 'year' => 1991, - ), - ), - )), - new Document(2, array( - 'fieldName' => array( - 'input' => array('Bleach', 'Nirvana'), + ], + ], + ]), + new Document(2, [ + 'fieldName' => [ + 'input' => ['Bleach', 'Nirvana'], 'output' => 'Bleach - Nirvana', - 'payload' => array( + 'payload' => [ 'year' => 1989, - ), - ), - )), - new Document(3, array( - 'fieldName' => array( - 'input' => array('Incesticide', 'Nirvana'), + ], + ], + ]), + new Document(3, [ + 'fieldName' => [ + 'input' => ['Incesticide', 'Nirvana'], 'output' => 'Incesticide - Nirvana', - 'payload' => array( + 'payload' => [ 'year' => 1992, - ), - ), - )), - )); + ], + ], + ]), + ]); $index->refresh(); @@ -68,13 +67,13 @@ public function testToArray() $suggest = new Completion('suggestName', 'fieldName'); $suggest->setText('foo'); $suggest->setSize(10); - $expected = array( + $expected = [ 'text' => 'foo', - 'completion' => array( + 'completion' => [ 'size' => 10, 'field' => 'fieldName', - ), - ); + ], + ]; $this->assertEquals($expected, $suggest->toArray()); } @@ -105,7 +104,7 @@ public function testSuggestWorks() public function testFuzzySuggestWorks() { $suggest = new Completion('suggestName', 'fieldName'); - $suggest->setFuzzy(array('fuzziness' => 2)); + $suggest->setFuzzy(['fuzziness' => 2]); $suggest->setText('Neavermint'); $index = $this->_getIndexForTest(); @@ -127,10 +126,10 @@ public function testSetFuzzy() { $suggest = new Completion('suggestName', 'fieldName'); - $fuzzy = array( + $fuzzy = [ 'unicode_aware' => true, 'fuzziness' => 3, - ); + ]; $suggest->setFuzzy($fuzzy); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php index 48ccf88..a1d04f4 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('testSuggestType'); - $type->addDocuments(array( - new Document(1, array('text' => 'Github is pretty cool')), - new Document(2, array('text' => 'Elasticsearch is bonsai cool')), - new Document(3, array('text' => 'This is a test phrase')), - new Document(4, array('text' => 'Another sentence for testing')), - new Document(5, array('text' => 'Some more words here')), - )); + $type->addDocuments([ + new Document(1, ['text' => 'Github is pretty cool']), + new Document(2, ['text' => 'Elasticsearch is bonsai cool']), + new Document(3, ['text' => 'This is a test phrase']), + new Document(4, ['text' => 'Another sentence for testing']), + new Document(5, ['text' => 'Some more words here']), + ]); $index->refresh(); return $index; @@ -42,18 +41,18 @@ public function testToArray() $suggest->addSuggestion($phraseSuggest); $suggest->setGlobalText('global!'); - $expected = array( - 'suggest' => array( + $expected = [ + 'suggest' => [ 'text' => 'global!', - 'suggest1' => array( + 'suggest1' => [ 'text' => 'elasticsearch is bansai coor', - 'phrase' => array( + 'phrase' => [ 'field' => 'text', 'analyzer' => 'simple', - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $suggest->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php index c8ea27b..85f058c 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php @@ -1,5 +1,4 @@ _createIndex(); $type = $index->getType('testSuggestType'); - $type->addDocuments(array( - new Document(1, array('id' => 1, 'text' => 'GitHub')), - new Document(2, array('id' => 1, 'text' => 'Elastic')), - new Document(3, array('id' => 1, 'text' => 'Search')), - new Document(4, array('id' => 1, 'text' => 'Food')), - new Document(5, array('id' => 1, 'text' => 'Flood')), - new Document(6, array('id' => 1, 'text' => 'Folks')), - )); + $type->addDocuments([ + new Document(1, ['id' => 1, 'text' => 'GitHub']), + new Document(2, ['id' => 1, 'text' => 'Elastic']), + new Document(3, ['id' => 1, 'text' => 'Search']), + new Document(4, ['id' => 1, 'text' => 'Food']), + new Document(5, ['id' => 1, 'text' => 'Flood']), + new Document(6, ['id' => 1, 'text' => 'Folks']), + ]); $index->refresh(); return $index; @@ -46,24 +45,24 @@ public function testToArray() $suggest2->setSuggestMode(Term::SUGGEST_MODE_POPULAR); $suggest->addSuggestion($suggest2->setText('Girhub')); - $expected = array( - 'suggest' => array( - 'suggest1' => array( - 'term' => array( + $expected = [ + 'suggest' => [ + 'suggest1' => [ + 'term' => [ 'field' => '_all', 'sort' => 'frequency', - ), + ], 'text' => 'Foor', - ), - 'suggest2' => array( - 'term' => array( + ], + 'suggest2' => [ + 'term' => [ 'field' => '_all', 'suggest_mode' => 'popular', - ), + ], 'text' => 'Girhub', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $suggest->toArray()); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SuggestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SuggestTest.php index ac780ea..a5943ed 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SuggestTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SuggestTest.php @@ -1,5 +1,4 @@ assertEquals(10, $newIndex->count()); - $oldResult = array(); + $oldResult = []; foreach ($oldIndex->search()->getResults() as $result) { $oldResult[] = $result->getData(); } - $newResult = array(); + $newResult = []; foreach ($newIndex->search()->getResults() as $result) { $newResult[] = $result->getData(); @@ -60,26 +59,26 @@ public function testReindexTypeOption() $newIndex = $this->_createIndex(null, true, 2); // \Elastica\Type - CrossIndex::reindex($oldIndex, $newIndex, array( + CrossIndex::reindex($oldIndex, $newIndex, [ CrossIndex::OPTION_TYPE => $type1, - )); + ]); $this->assertEquals(10, $newIndex->count()); $newIndex->deleteDocuments($docs1); // string - CrossIndex::reindex($oldIndex, $newIndex, array( + CrossIndex::reindex($oldIndex, $newIndex, [ CrossIndex::OPTION_TYPE => 'crossIndexTest_2', - )); + ]); $this->assertEquals(10, $newIndex->count()); $newIndex->deleteDocuments($docs2); // array - CrossIndex::reindex($oldIndex, $newIndex, array( - CrossIndex::OPTION_TYPE => array( + CrossIndex::reindex($oldIndex, $newIndex, [ + CrossIndex::OPTION_TYPE => [ 'crossIndexTest_1', $type2, - ), - )); + ], + ]); $this->assertEquals(20, $newIndex->count()); } @@ -94,12 +93,12 @@ public function testCopy() $newIndex = $this->_createIndex(null, true, 2); $oldType = $oldIndex->getType('copy_test'); - $oldMapping = array( - 'name' => array( + $oldMapping = [ + 'name' => [ 'type' => 'string', 'store' => true, - ), - ); + ], + ]; $oldType->setMapping($oldMapping); $docs = $this->_addDocs($oldType, 10); @@ -127,9 +126,9 @@ public function testCopy() $ignoredType = $oldIndex->getType('copy_test_1'); $this->_addDocs($ignoredType, 10); - CrossIndex::copy($oldIndex, $newIndex, array( + CrossIndex::copy($oldIndex, $newIndex, [ CrossIndex::OPTION_TYPE => $oldType, - )); + ]); $this->assertFalse($newIndex->getType($ignoredType->getName())->exists()); $this->assertEquals(10, $newIndex->count()); @@ -143,9 +142,9 @@ public function testCopy() */ private function _addDocs(Type $type, $docs) { - $insert = array(); + $insert = []; for ($i = 1; $i <= $docs; ++$i) { - $insert[] = new Document($i, array('id' => $i, 'key' => 'value')); + $insert[] = new Document($i, ['id' => $i, 'key' => 'value']); } $type->addDocuments($insert); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php index 712c83a..3e85ef6 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php @@ -1,5 +1,4 @@ 'Http')), - array(array('type' => new Http())), - array(new Http()), - ); + return [ + ['Http'], + [['type' => 'Http']], + [['type' => new Http()]], + [new Http()], + ]; } /** @@ -32,7 +31,7 @@ public function getValidDefinitions() public function testCanCreateTransportInstances($transport) { $connection = new Connection(); - $params = array(); + $params = []; $transport = AbstractTransport::create($transport, $connection, $params); $this->assertInstanceOf('Elastica\Transport\AbstractTransport', $transport); $this->assertSame($connection, $transport->getConnection()); @@ -40,10 +39,10 @@ public function testCanCreateTransportInstances($transport) public function getInvalidDefinitions() { - return array( - array(array('transport' => 'Http')), - array('InvalidTransport'), - ); + return [ + [['transport' => 'Http']], + ['InvalidTransport'], + ]; } /** @@ -63,16 +62,16 @@ public function testThrowsExecptionOnInvalidTransportDefinition($transport) public function testCanInjectParamsWhenUsingArray() { $connection = new Connection(); - $params = array( + $params = [ 'param1' => 'some value', 'param3' => 'value3', - ); + ]; - $transport = AbstractTransport::create(array( + $transport = AbstractTransport::create([ 'type' => 'Http', 'param1' => 'value1', 'param2' => 'value2', - ), $connection, $params); + ], $connection, $params); $this->assertSame('value1', $transport->getParam('param1')); $this->assertSame('value2', $transport->getParam('param2')); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AwsAuthV4Test.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AwsAuthV4Test.php index feb5350..e131894 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AwsAuthV4Test.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AwsAuthV4Test.php @@ -1,5 +1,4 @@ false, 'transport' => 'AwsAuthV4', 'aws_access_key_id' => 'foo', 'aws_secret_access_key' => 'bar', 'aws_session_token' => 'baz', 'aws_region' => 'us-east-1', - ); + ]; $client = $this->_getClient($config); try { @@ -53,10 +52,10 @@ public function testSignsWithProvidedCredentials() public function testSignsWithEnvironmentalCredentials() { - $config = array( + $config = [ 'persistent' => false, 'transport' => 'AwsAuthV4', - ); + ]; putenv('AWS_REGION=us-east-1'); putenv('AWS_ACCESS_KEY_ID=foo'); putenv('AWS_SECRET_ACCESS_KEY=bar'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php index cb52fe6..b4945fc 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php @@ -1,5 +1,4 @@ false, 'transport' => 'Guzzle'), + return [ + [ + ['persistent' => false, 'transport' => 'Guzzle'], 'GET', - ), - array( - array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)), + ], + [ + ['persistent' => false, 'transport' => ['type' => 'Guzzle', 'postWithRequestBody' => false]], 'GET', - ), - array( - array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)), + ], + [ + ['persistent' => false, 'transport' => ['type' => 'Guzzle', 'postWithRequestBody' => true]], 'POST', - ), - ); + ], + ]; } /** @@ -48,9 +47,9 @@ public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $http $client = $this->_getClient($config); $index = $client->getIndex('dynamic_http_method_test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('test' => 'test'))); + $type->addDocument(new Document(1, ['test' => 'test'])); $index->refresh(); $resultSet = $index->search('test'); $info = $resultSet->getResponse()->getTransferInfo(); @@ -78,7 +77,7 @@ public function testWithEnvironmentalProxy() $this->checkProxy($this->_getProxyUrl()); putenv('http_proxy='.$this->_getProxyUrl().'/'); - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $transferInfo = $client->request('/_nodes')->getTransferInfo(); $this->assertEquals(200, $transferInfo['http_code']); @@ -97,11 +96,11 @@ public function testWithEnabledEnvironmentalProxy() $this->checkProxy($this->_getProxyUrl403()); putenv('http_proxy='.$this->_getProxyUrl403().'/'); - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $transferInfo = $client->request('/_nodes')->getTransferInfo(); $this->assertEquals(403, $transferInfo['http_code']); - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $client->getConnection()->setProxy(''); $transferInfo = $client->request('/_nodes')->getTransferInfo(); $this->assertEquals(200, $transferInfo['http_code']); @@ -115,7 +114,7 @@ public function testWithEnabledEnvironmentalProxy() public function testWithProxy() { $this->checkProxy($this->_getProxyUrl()); - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $client->getConnection()->setProxy($this->_getProxyUrl()); $transferInfo = $client->request('/_nodes')->getTransferInfo(); @@ -127,7 +126,7 @@ public function testWithProxy() */ public function testWithoutProxy() { - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $client->getConnection()->setProxy(''); $transferInfo = $client->request('/_nodes')->getTransferInfo(); @@ -139,28 +138,30 @@ public function testWithoutProxy() */ public function testBodyReuse() { - $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'persistent' => false]); $index = $client->getIndex('elastica_body_reuse_test'); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('test' => 'test'))); + $type->addDocument(new Document(1, ['test' => 'test'])); $index->refresh(); - $resultSet = $index->search(array( - 'query' => array( - 'query_string' => array( + $resultSet = $index->search([ + 'query' => [ + 'query_string' => [ 'query' => 'pew pew pew', - ), - ), - )); + ], + ], + ]); $this->assertEquals(0, $resultSet->getTotalHits()); $response = $index->request('/_search', 'POST'); - $resultSet = new ResultSet($response, Query::create(array())); + + $builder = new ResultSet\DefaultBuilder(); + $resultSet = $builder->buildResultSet($response, Query::create([])); $this->assertEquals(1, $resultSet->getTotalHits()); } @@ -171,7 +172,7 @@ public function testBodyReuse() */ public function testInvalidConnection() { - $client = $this->_getClient(array('transport' => 'Guzzle', 'port' => 4500, 'persistent' => false)); + $client = $this->_getClient(['transport' => 'Guzzle', 'port' => 4500, 'persistent' => false]); $response = $client->request('_stats', 'GET'); $client->request('_status', 'GET'); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php index 5453fb8..1fd4998 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php @@ -1,5 +1,4 @@ 'Http', 'curl' => array(CURLINFO_HEADER_OUT => true)), + return [ + [ + ['transport' => 'Http', 'curl' => [CURLINFO_HEADER_OUT => true]], 'GET', - ), - array( - array('transport' => array('type' => 'Http', 'postWithRequestBody' => false, 'curl' => array(CURLINFO_HEADER_OUT => true))), + ], + [ + ['transport' => ['type' => 'Http', 'postWithRequestBody' => false, 'curl' => [CURLINFO_HEADER_OUT => true]]], 'GET', - ), - array( - array('transport' => array('type' => 'Http', 'postWithRequestBody' => true, 'curl' => array(CURLINFO_HEADER_OUT => true))), + ], + [ + ['transport' => ['type' => 'Http', 'postWithRequestBody' => true, 'curl' => [CURLINFO_HEADER_OUT => true]]], 'POST', - ), - ); + ], + ]; } /** @@ -41,11 +40,11 @@ public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $http $client = $this->_getClient($config); $index = $client->getIndex('dynamic_http_method_test'); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('test' => 'test'))); + $type->addDocument(new Document(1, ['test' => 'test'])); $index->refresh(); @@ -75,7 +74,7 @@ public function testCurlNobodyOptionIsResetAfterHeadRequest() { $client = $this->_getClient(); $index = $client->getIndex('curl_test'); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $type = $index->getType('item'); @@ -83,7 +82,7 @@ public function testCurlNobodyOptionIsResetAfterHeadRequest() $index->exists(); $id = 1; - $data = array('id' => $id, 'name' => 'Item 1'); + $data = ['id' => $id, 'name' => 'Item 1']; $doc = new \Elastica\Document($id, $data); $type->addDocument($doc); @@ -104,7 +103,7 @@ public function testUnicodeData() { $client = $this->_getClient(); $index = $client->getIndex('curl_test'); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $type = $index->getType('item'); @@ -113,11 +112,11 @@ public function testUnicodeData() $index->exists(); $id = 22; - $data = array('id' => $id, 'name' => ' + $data = ['id' => $id, 'name' => ' Сегодня, я вижу, особенно грустен твой взгляд, / И руки особенно тонки, колени обняв. / Послушай: далеко, далеко, на озере Чад / - Изысканный бродит жираф.'); + Изысканный бродит жираф.']; $doc = new \Elastica\Document($id, $data); @@ -201,26 +200,28 @@ public function testBodyReuse() $client = $this->_getClient(); $index = $client->getIndex('elastica_body_reuse_test'); - $index->create(array(), true); + $index->create([], true); $this->_waitForAllocation($index); $type = $index->getType('test'); - $type->addDocument(new Document(1, array('test' => 'test'))); + $type->addDocument(new Document(1, ['test' => 'test'])); $index->refresh(); - $resultSet = $index->search(array( - 'query' => array( - 'query_string' => array( + $resultSet = $index->search([ + 'query' => [ + 'query_string' => [ 'query' => 'pew pew pew', - ), - ), - )); + ], + ], + ]); $this->assertEquals(0, $resultSet->getTotalHits()); $response = $index->request('/_search', 'POST'); - $resultSet = new ResultSet($response, Query::create(array())); + + $builder = new ResultSet\DefaultBuilder(); + $resultSet = $builder->buildResultSet($response, Query::create([])); $this->assertEquals(1, $resultSet->getTotalHits()); } @@ -230,11 +231,11 @@ public function testBodyReuse() */ public function testRequestSuccessWithHttpCompressionEnabled() { - $client = $this->_getClient(array('transport' => array('type' => 'Http', 'compression' => true, 'curl' => array(CURLINFO_HEADER_OUT => true)))); + $client = $this->_getClient(['transport' => ['type' => 'Http', 'compression' => true, 'curl' => [CURLINFO_HEADER_OUT => true]]]); $index = $client->getIndex('elastica_request_with_body_and_http_compression_enabled'); - $createIndexResponse = $index->create(array(), true); + $createIndexResponse = $index->create([], true); $createIndexResponseTransferInfo = $createIndexResponse->getTransferInfo(); $this->assertRegExp('/Accept-Encoding:\ (gzip|deflate)/', $createIndexResponseTransferInfo['request_header']); @@ -246,11 +247,11 @@ public function testRequestSuccessWithHttpCompressionEnabled() */ public function testRequestSuccessWithHttpCompressionDisabled() { - $client = $this->_getClient(array('transport' => array('type' => 'Http', 'compression' => false, 'curl' => array(CURLINFO_HEADER_OUT => true)))); + $client = $this->_getClient(['transport' => ['type' => 'Http', 'compression' => false, 'curl' => [CURLINFO_HEADER_OUT => true]]]); $index = $client->getIndex('elastica_request_with_body_and_http_compression_disabled'); - $createIndexResponse = $index->create(array(), true); + $createIndexResponse = $index->create([], true); $createIndexResponseTransferInfo = $createIndexResponse->getTransferInfo(); $this->assertRegExp('/Accept-Encoding:\ (gzip|deflate)/', $createIndexResponseTransferInfo['request_header']); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php index 82ea89e..bdb8079 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php @@ -1,5 +1,4 @@ _getClient(); - $connection = new Connection(array('transport' => 'NullTransport')); - $client->setConnections(array($connection)); + $connection = new Connection(['transport' => 'NullTransport']); + $client->setConnections([$connection]); $index = $client->getIndex('elasticaNullTransportTest1'); @@ -65,7 +64,7 @@ public function testEmptyResult() public function testExec() { $request = new Request('/test'); - $params = array('name' => 'ruflin'); + $params = ['name' => 'ruflin']; $transport = new NullTransport(); $response = $transport->exec($request, $params); @@ -85,7 +84,7 @@ public function testOldObject() } $request = new Request('/test'); - $params = array('name' => 'ruflin'); + $params = ['name' => 'ruflin']; $transport = new \Elastica\Transport\Null(); $response = $transport->exec($request, $params); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php index bc29c63..6423832 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php @@ -1,5 +1,4 @@ _getClient($config); $index = $client->getIndex('benchmark'.uniqid()); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); return $index->getType('benchmark'); } @@ -50,9 +49,9 @@ public function testAddDocument(array $config, $transport) $type = $this->getType($config); $index = $type->getIndex(); - $index->create(array(), true); + $index->create([], true); - $times = array(); + $times = []; for ($i = 0; $i < $this->_max; ++$i) { $data = $this->getData($i); $doc = new Document($i, $data); @@ -79,12 +78,12 @@ public function testRandomRead(array $config, $transport) $type->search('test'); - $times = array(); + $times = []; for ($i = 0; $i < $this->_max; ++$i) { $test = rand(1, $this->_max); $query = new Query(); $query->setQuery(new \Elastica\Query\MatchAll()); - $query->setPostFilter(new \Elastica\Filter\Term(array('test' => $test))); + $query->setPostFilter(new \Elastica\Filter\Term(['test' => $test])); $result = $type->search($query); $times[] = $result->getResponse()->getQueryTime(); } @@ -103,9 +102,9 @@ public function testBulk(array $config, $transport) $type = $this->getType($config); - $times = array(); + $times = []; for ($i = 0; $i < $this->_max; ++$i) { - $docs = array(); + $docs = []; for ($j = 0; $j < 10; ++$j) { $data = $this->getData($i.$j); $docs[] = new Document($i, $data); @@ -128,31 +127,31 @@ public function testGetMapping(array $config, $transport) $client = $this->_getClient($config); $index = $client->getIndex('benchmark'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('mappingTest'); // Define mapping $mapping = new \Elastica\Type\Mapping(); - $mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0)); - $mapping->setProperties(array( - 'id' => array('type' => 'integer', 'include_in_all' => false), - 'user' => array( + $mapping->setParam('_boost', ['name' => '_boost', 'null_value' => 1.0]); + $mapping->setProperties([ + 'id' => ['type' => 'integer', 'include_in_all' => false], + 'user' => [ 'type' => 'object', - 'properties' => array( - 'name' => array('type' => 'string', 'include_in_all' => true), - 'fullName' => array('type' => 'string', 'include_in_all' => true), - ), - ), - 'msg' => array('type' => 'string', 'include_in_all' => true), - 'tstamp' => array('type' => 'date', 'include_in_all' => false), - 'location' => array('type' => 'geo_point', 'include_in_all' => false), - '_boost' => array('type' => 'float', 'include_in_all' => false), - )); + 'properties' => [ + 'name' => ['type' => 'string', 'include_in_all' => true], + 'fullName' => ['type' => 'string', 'include_in_all' => true], + ], + ], + 'msg' => ['type' => 'string', 'include_in_all' => true], + 'tstamp' => ['type' => 'date', 'include_in_all' => false], + 'location' => ['type' => 'geo_point', 'include_in_all' => false], + '_boost' => ['type' => 'float', 'include_in_all' => false], + ]); $type->setMapping($mapping); $index->refresh(); - $times = array(); + $times = []; for ($i = 0; $i < $this->_max; ++$i) { $response = $type->request('_mapping', \Elastica\Request::GET); $times[] = $response->getQueryTime(); @@ -162,26 +161,26 @@ public function testGetMapping(array $config, $transport) public function providerTransport() { - return array( - array( - array( + return [ + [ + [ 'transport' => 'Http', 'host' => $this->_getHost(), 'port' => $this->_getPort(), 'persistent' => false, - ), + ], 'Http:NotPersistent', - ), - array( - array( + ], + [ + [ 'transport' => 'Http', 'host' => $this->_getHost(), 'port' => $this->_getPort(), 'persistent' => true, - ), + ], 'Http:Persistent', - ), - ); + ], + ]; } /** @@ -191,10 +190,10 @@ public function providerTransport() */ protected function getData($test) { - $data = array( + $data = [ 'test' => $test, - 'name' => array(), - ); + 'name' => [], + ]; for ($i = 0; $i < $this->_maxData; ++$i) { $data['name'][] = uniqid(); } @@ -209,12 +208,12 @@ protected function getData($test) */ protected static function logResults($name, $transport, array $times) { - self::$_results[$name][$transport] = array( + self::$_results[$name][$transport] = [ 'count' => count($times), 'max' => max($times) * 1000, 'min' => min($times) * 1000, 'mean' => (array_sum($times) / count($times)) * 1000, - ); + ]; } protected static function printResults() @@ -230,7 +229,7 @@ protected static function printResults() '%' ); foreach (self::$_results as $name => $values) { - $means = array(); + $means = []; foreach ($values as $times) { $means[] = $times['mean']; } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php index 0e8f81a..f944eb3 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php @@ -1,5 +1,4 @@ _getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); $mapping = new Mapping($type, - array( - 'firstname' => array('type' => 'string', 'store' => true), + [ + 'firstname' => ['type' => 'string', 'store' => true], // default is store => no expected - 'lastname' => array('type' => 'string'), - ) + 'lastname' => ['type' => 'string'], + ] ); $mapping->disableSource(); @@ -35,10 +34,10 @@ public function testMappingStoreFields() $firstname = 'Nicolas'; $doc = new Document(1, - array( + [ 'firstname' => $firstname, 'lastname' => 'Ruflin', - ) + ] ); $type->addDocument($doc); @@ -46,7 +45,7 @@ public function testMappingStoreFields() $index->refresh(); $queryString = new QueryString('ruflin'); $query = Query::create($queryString); - $query->setFields(array('*')); + $query->setFields(['*']); $resultSet = $type->search($query); $result = $resultSet->current(); @@ -72,7 +71,7 @@ public function testEnableAllField() $index = $this->_createIndex(); $type = $index->getType('test'); - $mapping = new Mapping($type, array()); + $mapping = new Mapping($type, []); $mapping->enableAllField(); @@ -93,10 +92,10 @@ public function testEnableTtl() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); - $mapping = new Mapping($type, array()); + $mapping = new Mapping($type, []); $mapping->enableTtl(); @@ -114,35 +113,35 @@ public function testNestedMapping() $client = $this->_getClient(); $index = $client->getIndex('test'); - $index->create(array(), true); + $index->create([], true); $type = $index->getType('test'); $mapping = new Mapping($type, - array( - 'test' => array( - 'type' => 'object', 'properties' => array( - 'user' => array( - 'properties' => array( - 'firstname' => array('type' => 'string', 'store' => true), - 'lastname' => array('type' => 'string', 'store' => true), - 'age' => array('type' => 'integer', 'store' => true), - ), - ), - ), - ), - ) + [ + 'test' => [ + 'type' => 'object', 'properties' => [ + 'user' => [ + 'properties' => [ + 'firstname' => ['type' => 'string', 'store' => true], + 'lastname' => ['type' => 'string', 'store' => true], + 'age' => ['type' => 'integer', 'store' => true], + ], + ], + ], + ], + ] ); $response = $type->setMapping($mapping); $this->assertFalse($response->hasError()); - $doc = new Document(1, array( - 'user' => array( + $doc = new Document(1, [ + 'user' => [ 'firstname' => 'Nicolas', 'lastname' => 'Ruflin', 'age' => 9, - ), - )); + ], + ]); $type->addDocument($doc); @@ -162,9 +161,9 @@ public function testParentMapping() $childtype = new Type($index, 'childtype'); $childmapping = new Mapping($childtype, - array( - 'name' => array('type' => 'string', 'store' => true), - ) + [ + 'name' => ['type' => 'string', 'store' => true], + ] ); $childmapping->setParent('parenttype'); @@ -175,9 +174,9 @@ public function testParentMapping() $parenttype = new Type($index, 'parenttype'); $parentmapping = new Mapping($parenttype, - array( - 'name' => array('type' => 'string', 'store' => true), - ) + [ + 'name' => ['type' => 'string', 'store' => true], + ] ); $parenttype->setMapping($parentmapping); @@ -192,30 +191,30 @@ public function testMappingExample() $type = $index->getType('notes'); $mapping = new Mapping($type, - array( - 'note' => array( - 'properties' => array( - 'titulo' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0), - 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0), - ), - ), - ) + [ + 'note' => [ + 'properties' => [ + 'titulo' => ['type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0], + 'contenido' => ['type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0], + ], + ], + ] ); $type->setMapping($mapping); - $doc = new Document(1, array( - 'note' => array( - array( + $doc = new Document(1, [ + 'note' => [ + [ 'titulo' => 'nota1', 'contenido' => 'contenido1', - ), - array( + ], + [ 'titulo' => 'nota2', 'contenido' => 'contenido2', - ), - ), - ) + ], + ], + ] ); $type->addDocument($doc); @@ -238,18 +237,18 @@ public function testDynamicTemplate() // set a dynamic template "template_1" which creates a multi field for multi* matches. $mapping = new Mapping($type); - $mapping->setParam('dynamic_templates', array( - array('template_1' => array( + $mapping->setParam('dynamic_templates', [ + ['template_1' => [ 'match' => 'multi*', - 'mapping' => array( + 'mapping' => [ 'type' => 'multi_field', - 'fields' => array( - '{name}' => array('type' => '{dynamic_type}', 'index' => 'analyzed'), - 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed'), - ), - ), - )), - )); + 'fields' => [ + '{name}' => ['type' => '{dynamic_type}', 'index' => 'analyzed'], + 'org' => ['type' => '{dynamic_type}', 'index' => 'not_analyzed'], + ], + ], + ]], + ]); $mapping->send(); @@ -257,8 +256,8 @@ public function testDynamicTemplate() $index->optimize(); // create a document which should create a mapping for the field: multiname. - $testDoc = new Document('person1', array('multiname' => 'Jasper van Wanrooy'), $type); - $index->addDocuments(array($testDoc)); + $testDoc = new Document('person1', ['multiname' => 'Jasper van Wanrooy'], $type); + $index->addDocuments([$testDoc]); sleep(1); //sleep 1 to ensure that the test passes every time // read the mapping from Elasticsearch and assert that the multiname.org field is "not_analyzed" @@ -287,11 +286,11 @@ public function testSetMeta() { $index = $this->_createIndex(); $type = $index->getType('test'); - $mapping = new Mapping($type, array( - 'firstname' => array('type' => 'string', 'store' => true), - 'lastname' => array('type' => 'string'), - )); - $mapping->setMeta(array('class' => 'test')); + $mapping = new Mapping($type, [ + 'firstname' => ['type' => 'string', 'store' => true], + 'lastname' => ['type' => 'string'], + ]); + $mapping->setMeta(['class' => 'test']); $type->setMapping($mapping); $mappingData = $type->getMapping(); @@ -307,15 +306,15 @@ public function testGetters() { $index = $this->_createIndex(); $type = $index->getType('test'); - $properties = array( - 'firstname' => array('type' => 'string', 'store' => true), - 'lastname' => array('type' => 'string'), - ); + $properties = [ + 'firstname' => ['type' => 'string', 'store' => true], + 'lastname' => ['type' => 'string'], + ]; $mapping = new Mapping($type, $properties); - $all = array( + $all = [ 'enabled' => true, 'store' => true, - ); + ]; $mapping->setParam('_all', $all); $get_all = $mapping->getParam('_all'); diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php index 15db226..ae925cd 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php @@ -1,5 +1,4 @@ 'hans', 'test' => array('2', '3', '5')) + ['username' => 'hans', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); // Adds a list of documents with _bulk upload to the index - $docs = array(); + $docs = []; $docs[] = new Document(2, - array('username' => 'john', 'test' => array('1', '3', '6')) + ['username' => 'john', 'test' => ['1', '3', '6']] ); $docs[] = new Document(3, - array('username' => 'rolf', 'test' => array('2', '3', '7')) + ['username' => 'rolf', 'test' => ['2', '3', '7']] ); $type->addDocuments($docs); $index->refresh(); @@ -66,29 +65,29 @@ public function testCreateSearch() $type = new Type($index, 'test_type'); $query = new Query\QueryString('test'); - $options = array( + $options = [ 'limit' => 5, 'explain' => true, - ); + ]; $search = $type->createSearch($query, $options); - $expected = array( - 'query' => array( - 'query_string' => array( + $expected = [ + 'query' => [ + 'query_string' => [ 'query' => 'test', - ), - ), + ], + ], 'size' => 5, 'explain' => true, - ); + ]; $this->assertEquals($expected, $search->getQuery()->toArray()); - $this->assertEquals(array('test_index'), $search->getIndices()); + $this->assertEquals(['test_index'], $search->getIndices()); $this->assertTrue($search->hasIndices()); $this->assertTrue($search->hasIndex($index)); $this->assertTrue($search->hasIndex('test_index')); $this->assertFalse($search->hasIndex('test')); - $this->assertEquals(array('test_type'), $search->getTypes()); + $this->assertEquals(['test_type'], $search->getTypes()); $this->assertTrue($search->hasTypes()); $this->assertTrue($search->hasType($type)); $this->assertTrue($search->hasType('test_type')); @@ -104,37 +103,37 @@ public function testCreateSearchWithArray() $index = new Index($client, 'test_index'); $type = new Type($index, 'test_type'); - $query = array( - 'query' => array( - 'query_string' => array( + $query = [ + 'query' => [ + 'query_string' => [ 'query' => 'test', - ), - ), - ); + ], + ], + ]; - $options = array( + $options = [ 'limit' => 5, 'explain' => true, - ); + ]; $search = $type->createSearch($query, $options); - $expected = array( - 'query' => array( - 'query_string' => array( + $expected = [ + 'query' => [ + 'query_string' => [ 'query' => 'test', - ), - ), + ], + ], 'size' => 5, 'explain' => true, - ); + ]; $this->assertEquals($expected, $search->getQuery()->toArray()); - $this->assertEquals(array('test_index'), $search->getIndices()); + $this->assertEquals(['test_index'], $search->getIndices()); $this->assertTrue($search->hasIndices()); $this->assertTrue($search->hasIndex($index)); $this->assertTrue($search->hasIndex('test_index')); $this->assertFalse($search->hasIndex('test')); - $this->assertEquals(array('test_type'), $search->getTypes()); + $this->assertEquals(['test_type'], $search->getTypes()); $this->assertTrue($search->hasTypes()); $this->assertTrue($search->hasType($type)); $this->assertTrue($search->hasType('test_type')); @@ -149,11 +148,11 @@ public function testNoSource() $index = $this->_createIndex(); $type = new Type($index, 'user'); - $mapping = new Mapping($type, array( - 'id' => array('type' => 'integer', 'store' => 'yes'), - 'username' => array('type' => 'string', 'store' => 'no'), - )); - $mapping->setSource(array('enabled' => false)); + $mapping = new Mapping($type, [ + 'id' => ['type' => 'integer', 'store' => 'yes'], + 'username' => ['type' => 'string', 'store' => 'no'], + ]); + $mapping->setSource(['enabled' => false]); $type->setMapping($mapping); $mapping = $type->getMapping(); @@ -166,17 +165,17 @@ public function testNoSource() // Adds 1 document to the index $doc1 = new Document(1, - array('username' => 'hans', 'test' => array('2', '3', '5')) + ['username' => 'hans', 'test' => ['2', '3', '5']] ); $type->addDocument($doc1); // Adds a list of documents with _bulk upload to the index - $docs = array(); + $docs = []; $docs[] = new Document(2, - array('username' => 'john', 'test' => array('1', '3', '6')) + ['username' => 'john', 'test' => ['1', '3', '6']] ); $docs[] = new Document(3, - array('username' => 'rolf', 'test' => array('2', '3', '7')) + ['username' => 'rolf', 'test' => ['2', '3', '7']] ); $type->addDocuments($docs); @@ -202,12 +201,12 @@ public function testDeleteById() $type = new Type($index, 'user'); // Adds hans, john and rolf to the index - $docs = array( - new Document(1, array('username' => 'hans', 'test' => array('2', '3', '5'))), - new Document(2, array('username' => 'john', 'test' => array('1', '3', '6'))), - new Document(3, array('username' => 'rolf', 'test' => array('2', '3', '7'))), - new Document('foo/bar', array('username' => 'georg', 'test' => array('4', '2', '5'))), - ); + $docs = [ + new Document(1, ['username' => 'hans', 'test' => ['2', '3', '5']]), + new Document(2, ['username' => 'john', 'test' => ['1', '3', '6']]), + new Document(3, ['username' => 'rolf', 'test' => ['2', '3', '7']]), + new Document('foo/bar', ['username' => 'georg', 'test' => ['4', '2', '5']]), + ]; $type->addDocuments($docs); $index->refresh(); @@ -260,7 +259,7 @@ public function testDeleteById() } try { - $type->deleteById(array()); + $type->deleteById([]); $this->fail('Delete with empty array id should fail'); } catch (\InvalidArgumentException $e) { $this->assertTrue(true); @@ -303,11 +302,11 @@ public function testDeleteDocument() $type = new Type($index, 'user'); // Adds hans, john and rolf to the index - $docs = array( - new Document(1, array('username' => 'hans', 'test' => array('2', '3', '5'))), - new Document(2, array('username' => 'john', 'test' => array('1', '3', '6'))), - new Document(3, array('username' => 'rolf', 'test' => array('2', '3', '7'))), - ); + $docs = [ + new Document(1, ['username' => 'hans', 'test' => ['2', '3', '5']]), + new Document(2, ['username' => 'john', 'test' => ['1', '3', '6']]), + new Document(3, ['username' => 'rolf', 'test' => ['2', '3', '7']]), + ]; $type->addDocuments($docs); $index->refresh(); @@ -337,7 +336,7 @@ public function testGetDocumentNotExist() { $index = $this->_createIndex(); $type = new Type($index, 'test'); - $type->addDocument(new Document(1, array('name' => 'ruflin'))); + $type->addDocument(new Document(1, ['name' => 'ruflin'])); $index->refresh(); $type->getDocument(1); @@ -367,8 +366,8 @@ public function testDeleteByQueryWithQueryString() $index = $this->_createIndex(); $type = new Type($index, 'test'); - $type->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type->addDocument(new Document(2, array('name' => 'ruflin'))); + $type->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type->addDocument(new Document(2, ['name' => 'ruflin'])); $index->refresh(); $response = $index->search('ruflin*'); @@ -400,8 +399,8 @@ public function testDeleteByQueryWithQuery() $index = $this->_createIndex(); $type = new Type($index, 'test'); - $type->addDocument(new Document(1, array('name' => 'ruflin nicolas'))); - $type->addDocument(new Document(2, array('name' => 'ruflin'))); + $type->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type->addDocument(new Document(2, ['name' => 'ruflin'])); $index->refresh(); $response = $index->search('ruflin*'); @@ -424,6 +423,38 @@ public function testDeleteByQueryWithQuery() $this->assertEquals(0, $response->count()); } + /** + * @group functional + */ + public function testDeleteByQueryWithArrayQuery() + { + $this->_checkPlugin('delete-by-query'); + + $index = $this->_createIndex(); + $type = new Type($index, 'test'); + $type->addDocument(new Document(1, ['name' => 'ruflin nicolas'])); + $type->addDocument(new Document(2, ['name' => 'ruflin'])); + $index->refresh(); + + $response = $index->search('ruflin*'); + $this->assertEquals(2, $response->count()); + $response = $index->search('nicolas'); + $this->assertEquals(1, $response->count()); + + // Delete first document + $response = $type->deleteByQuery(['query' => ['query_string' => ['query' => 'nicolas']]]); + $this->assertTrue($response->isOk()); + + $index->refresh(); + + // Makes sure, document is deleted + $response = $index->search('ruflin*'); + $this->assertEquals(1, $response->count()); + + $response = $index->search('nicolas'); + $this->assertEquals(0, $response->count()); + } + /** * @group functional */ @@ -433,10 +464,10 @@ public function testDeleteByQueryWithQueryAndOptions() $index = $this->_createIndex(null, true, 2); $type = new Type($index, 'test'); - $doc = new Document(1, array('name' => 'ruflin nicolas')); + $doc = new Document(1, ['name' => 'ruflin nicolas']); $doc->setRouting('first_routing'); $type->addDocument($doc); - $doc = new Document(2, array('name' => 'ruflin')); + $doc = new Document(2, ['name' => 'ruflin']); $doc->setRouting('second_routing'); $type->addDocument($doc); $index->refresh(); @@ -444,14 +475,14 @@ public function testDeleteByQueryWithQueryAndOptions() $response = $index->search('ruflin*'); $this->assertEquals(2, $response->count()); - $response = $index->search('ruflin*', array('routing' => 'first_routing')); + $response = $index->search('ruflin*', ['routing' => 'first_routing']); $this->assertEquals(1, $response->count()); $response = $index->search('nicolas'); $this->assertEquals(1, $response->count()); // Route to the wrong document id; should not delete - $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => 'second_routing')); + $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), ['routing' => 'second_routing']); $this->assertTrue($response->isOk()); $index->refresh(); @@ -463,7 +494,7 @@ public function testDeleteByQueryWithQueryAndOptions() $this->assertEquals(1, $response->count()); // Delete first document - $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => 'first_routing')); + $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), ['routing' => 'first_routing']); $this->assertTrue($response->isOk()); $index->refresh(); @@ -486,10 +517,10 @@ public function testGetDocumentWithFieldsSelection() { $index = $this->_createIndex(); $type = new Type($index, 'test'); - $type->addDocument(new Document(1, array('name' => 'loris', 'country' => 'FR', 'email' => 'test@test.com'))); + $type->addDocument(new Document(1, ['name' => 'loris', 'country' => 'FR', 'email' => 'test@test.com'])); $index->refresh(); - $document = $type->getDocument(1, array('fields' => 'name,email')); + $document = $type->getDocument(1, ['fields' => 'name,email']); $data = $document->getData(); $this->assertArrayHasKey('name', $data); @@ -506,20 +537,20 @@ public function testLimitDefaultType() { $client = $this->_getClient(); $index = $client->getIndex('zero'); - $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true); - - $docs = array(); - $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); - $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')); + $index->create(['index' => ['number_of_shards' => 1, 'number_of_replicas' => 0]], true); + + $docs = []; + $docs[] = new Document(1, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(2, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(3, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(4, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(5, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(6, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(7, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(8, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(9, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(10, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); + $docs[] = new Document(11, ['id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley']); $type = $index->getType('zeroType'); $type->addDocuments($docs); @@ -560,22 +591,22 @@ public function testUpdateDocument() $index = $client->getIndex('elastica_test'); $type = $index->getType('update_type'); $id = 1; - $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1))); + $type->addDocument(new Document($id, ['name' => 'bruce wayne batman', 'counter' => 1])); $newName = 'batman'; $document = new Document(); $script = new Script( 'ctx._source.name = name; ctx._source.counter += count', - array( + [ 'name' => $newName, 'count' => 2, - ), + ], null, $id ); $script->setUpsert($document); - $type->updateDocument($script, array('refresh' => true)); + $type->updateDocument($script, ['refresh' => true]); $updatedDoc = $type->getDocument($id)->getData(); $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated'); $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented'); @@ -591,22 +622,22 @@ public function testUpdateDocumentWithIdForwardSlashes() $index = $client->getIndex('elastica_test'); $type = $index->getType('update_type'); $id = '/id/with/forward/slashes'; - $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1))); + $type->addDocument(new Document($id, ['name' => 'bruce wayne batman', 'counter' => 1])); $newName = 'batman'; $document = new Document(); $script = new Script( 'ctx._source.name = name; ctx._source.counter += count', - array( + [ 'name' => $newName, 'count' => 2, - ), + ], null, $id ); $script->setUpsert($document); - $type->updateDocument($script, array('refresh' => true)); + $type->updateDocument($script, ['refresh' => true]); $updatedDoc = $type->getDocument($id)->getData(); $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated'); $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented'); @@ -621,23 +652,23 @@ public function testUpdateDocumentWithParameter() $index = $client->getIndex('elastica_test'); $type = $index->getType('update_type'); $id = 1; - $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1))); + $type->addDocument(new Document($id, ['name' => 'bruce wayne batman', 'counter' => 1])); $newName = 'batman'; $document = new Document(); $script = new Script( 'ctx._source.name = name; ctx._source.counter += count', - array( + [ 'name' => $newName, 'count' => 2, - ), + ], null, $id ); $script->setUpsert($document); try { - $type->updateDocument($script, array('version' => 999)); // Wrong version number to make the update fail + $type->updateDocument($script, ['version' => 999]); // Wrong version number to make the update fail } catch (ResponseException $e) { $error = $e->getResponse()->getFullError(); $this->assertContains('version_conflict_engine_exception', $error['type']); @@ -657,9 +688,9 @@ public function testUpdateDocumentWithFieldsSource() $index = $client->getIndex('elastica_test'); $type = $index->getType('update_type'); - $client->setConfigValue('document', array('autoPopulate' => true)); + $client->setConfigValue('document', ['autoPopulate' => true]); - $newDocument = new Document(null, array('counter' => 5, 'name' => 'Batman')); + $newDocument = new Document(null, ['counter' => 5, 'name' => 'Batman']); $this->assertFalse($newDocument->hasVersion()); @@ -721,15 +752,15 @@ public function testUpdateDocumentWithoutSource() $type = $index->getType('elastica_type'); $mapping = new Mapping(); - $mapping->setProperties(array( - 'name' => array( + $mapping->setProperties([ + 'name' => [ 'type' => 'string', - 'store' => 'yes', ), - 'counter' => array( + 'store' => 'yes', ], + 'counter' => [ 'type' => 'integer', 'store' => 'no', - ), - )); + ], + ]); $mapping->disableSource(); $type->setMapping($mapping); @@ -776,7 +807,7 @@ public function testAddDocumentHashId() $hashId = '#1'; - $doc = new Document($hashId, array('name' => 'ruflin')); + $doc = new Document($hashId, ['name' => 'ruflin']); $type->addDocument($doc); $index->refresh(); @@ -843,7 +874,7 @@ public function testAddObject() $userObject = new \stdClass(); $userObject->username = 'hans'; - $userObject->test = array('2', '3', '5'); + $userObject->test = ['2', '3', '5']; $type->addObject($userObject); @@ -880,7 +911,7 @@ public function testExists() $type = new Type($index, 'user'); $this->assertFalse($type->exists()); - $type->addDocument(new Document(1, array('name' => 'test name'))); + $type->addDocument(new Document(1, ['name' => 'test name'])); $index->optimize(); // sleep a moment to be sure that all nodes in cluster has new type @@ -903,15 +934,15 @@ public function testGetMapping() $index = $this->_createIndex(); $indexName = $index->getName(); $type = new Type($index, $typeName); - $mapping = new Mapping($type, $expect = array( - 'id' => array('type' => 'integer', 'store' => true), - )); + $mapping = new Mapping($type, $expect = [ + 'id' => ['type' => 'integer', 'store' => true], + ]); $type->setMapping($mapping); $client = $index->getClient(); $this->assertEquals( - array('test-type' => array('properties' => $expect)), + ['test-type' => ['properties' => $expect]], $client->getIndex($indexName)->getType($typeName)->getMapping() ); } @@ -927,15 +958,15 @@ public function testGetMappingAlias() $index = $this->_createIndex(); $index->addAlias($aliasName); $type = new Type($index, $typeName); - $mapping = new Mapping($type, $expect = array( - 'id' => array('type' => 'integer', 'store' => true), - )); + $mapping = new Mapping($type, $expect = [ + 'id' => ['type' => 'integer', 'store' => true], + ]); $type->setMapping($mapping); $client = $index->getClient(); $this->assertEquals( - array('test-alias-type' => array('properties' => $expect)), + ['test-alias-type' => ['properties' => $expect]], $client->getIndex($aliasName)->getType($typeName)->getMapping() ); } diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php index 249ab98..ff0c44e 100644 --- a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php @@ -1,5 +1,4 @@ 'params'); - $data = array('key' => 'value'); + $query = ['no' => 'params']; + $data = ['key' => 'value']; $connection = new Connection(); $connection->setHost($this->_getHost());