diff --git a/.php_cs b/.php_cs
new file mode 100644
index 0000000000..f876ca20ca
--- /dev/null
+++ b/.php_cs
@@ -0,0 +1,19 @@
+in(['lib', 'test']);
+
+$config = Symfony\CS\Config\Config::create()
+ ->setUsingCache(true)
+ ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
+ ->fixers([
+ // [contrib] Multi-line whitespace before closing semicolon are prohibited.
+ 'multiline_spaces_before_semicolon',
+ // [contrib] There should be no blank lines before a namespace declaration.
+ 'no_blank_lines_before_namespace',
+ // [contrib] Ordering use statements.
+ 'ordered_use',
+ ])
+ ->finder($finder);
+
+return $config;
diff --git a/composer.json b/composer.json
index e612fcf56e..a823c9b176 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,8 @@
"require-dev": {
"munkie/elasticsearch-thrift-php": "1.4.*",
"phpunit/phpunit": "4.1.*",
- "guzzlehttp/guzzle": "4.2.*"
+ "guzzlehttp/guzzle": "4.2.*",
+ "fabpot/php-cs-fixer": "~1.4"
},
"suggest": {
"munkie/elasticsearch-thrift-php": "Allow using thrift transport",
diff --git a/lib/Elastica/Aggregation/AbstractAggregation.php b/lib/Elastica/Aggregation/AbstractAggregation.php
index 501d9a3db8..4034690e88 100644
--- a/lib/Elastica/Aggregation/AbstractAggregation.php
+++ b/lib/Elastica/Aggregation/AbstractAggregation.php
@@ -2,8 +2,8 @@
namespace Elastica\Aggregation;
-use Elastica\Param;
use Elastica\Exception\InvalidException;
+use Elastica\Param;
abstract class AbstractAggregation extends Param
{
diff --git a/lib/Elastica/Bulk.php b/lib/Elastica/Bulk.php
index d2c527ea4b..236b13fc18 100644
--- a/lib/Elastica/Bulk.php
+++ b/lib/Elastica/Bulk.php
@@ -2,13 +2,13 @@
namespace Elastica;
-use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
-use Elastica\Exception\Bulk\UdpException;
-use Elastica\Exception\InvalidException;
use Elastica\Bulk\Action;
use Elastica\Bulk\Action\AbstractDocument as AbstractDocumentAction;
-use Elastica\Bulk\ResponseSet;
use Elastica\Bulk\Response as BulkResponse;
+use Elastica\Bulk\ResponseSet;
+use Elastica\Exception\Bulk\ResponseException as BulkResponseException;
+use Elastica\Exception\Bulk\UdpException;
+use Elastica\Exception\InvalidException;
class Bulk
{
diff --git a/lib/Elastica/Bulk/Action.php b/lib/Elastica/Bulk/Action.php
index bf79a5d5fa..dfcb3be326 100644
--- a/lib/Elastica/Bulk/Action.php
+++ b/lib/Elastica/Bulk/Action.php
@@ -3,8 +3,8 @@
namespace Elastica\Bulk;
use Elastica\Bulk;
-use Elastica\JSON;
use Elastica\Index;
+use Elastica\JSON;
use Elastica\Type;
class Action
diff --git a/lib/Elastica/Connection/ConnectionPool.php b/lib/Elastica/Connection/ConnectionPool.php
index 312a17e601..058fe34d22 100644
--- a/lib/Elastica/Connection/ConnectionPool.php
+++ b/lib/Elastica/Connection/ConnectionPool.php
@@ -24,7 +24,7 @@ class ConnectionPool
/**
* Strategy for connection
*
- * @var \Elastica\Connection\Strategy\StrategyInterface
+ * @var \Elastica\Connection\Strategy\StrategyInterface
*/
protected $_strategy;
diff --git a/lib/Elastica/Document.php b/lib/Elastica/Document.php
index 1dfa714a8d..04c6346c42 100644
--- a/lib/Elastica/Document.php
+++ b/lib/Elastica/Document.php
@@ -2,10 +2,10 @@
namespace Elastica;
-use Elastica\Exception\InvalidException;
use Elastica\Bulk\Action;
-use Elastica\Filter\Bool;
+use Elastica\Exception\InvalidException;
use Elastica\Exception\NotImplementedException;
+use Elastica\Filter\Bool;
/**
* Single document stored in elastic search
diff --git a/lib/Elastica/Exception/Bulk/Response/ActionException.php b/lib/Elastica/Exception/Bulk/Response/ActionException.php
index c058042a16..345bb82c79 100644
--- a/lib/Elastica/Exception/Bulk/Response/ActionException.php
+++ b/lib/Elastica/Exception/Bulk/Response/ActionException.php
@@ -2,9 +2,9 @@
namespace Elastica\Exception\Bulk\Response;
-use Elastica\Exception\BulkException;
use Elastica\Bulk\Action;
use Elastica\Bulk\Response;
+use Elastica\Exception\BulkException;
class ActionException extends BulkException
{
diff --git a/lib/Elastica/Facet/AbstractFacet.php b/lib/Elastica/Facet/AbstractFacet.php
index 7a0bc1f4ea..bc6021a1af 100644
--- a/lib/Elastica/Facet/AbstractFacet.php
+++ b/lib/Elastica/Facet/AbstractFacet.php
@@ -2,9 +2,9 @@
namespace Elastica\Facet;
-use Elastica\Param;
-use Elastica\Filter\AbstractFilter;
use Elastica\Exception\InvalidException;
+use Elastica\Filter\AbstractFilter;
+use Elastica\Param;
/**
* Abstract facet object. Should be extended by all facet types
diff --git a/lib/Elastica/Filter/GeoPolygon.php b/lib/Elastica/Filter/GeoPolygon.php
index ef44d7b18b..8917e35fd0 100644
--- a/lib/Elastica/Filter/GeoPolygon.php
+++ b/lib/Elastica/Filter/GeoPolygon.php
@@ -2,7 +2,6 @@
namespace Elastica\Filter;
-
/**
* Geo polygon filter
*
diff --git a/lib/Elastica/Index/Settings.php b/lib/Elastica/Index/Settings.php
index 24aa513d6b..4eb0472d4c 100644
--- a/lib/Elastica/Index/Settings.php
+++ b/lib/Elastica/Index/Settings.php
@@ -72,7 +72,7 @@ public function get($setting = '')
if (empty($data['settings']) || empty($data['settings']['index'])) {
// should not append, the request should throw a ResponseException
- throw new NotFoundException('Index ' . $this->getIndex()->getName() . ' not found');
+ throw new NotFoundException('Index '.$this->getIndex()->getName().' not found');
}
$settings = $data['settings']['index'];
@@ -91,12 +91,14 @@ public function get($setting = '')
if (isset($settings[$key])) {
$settings = $settings[$key];
} else {
- return null;
+ return;
}
}
+
return $settings;
}
- return null;
+
+ return;
}
}
diff --git a/lib/Elastica/Index/Status.php b/lib/Elastica/Index/Status.php
index 4c0450e499..3aa4825149 100644
--- a/lib/Elastica/Index/Status.php
+++ b/lib/Elastica/Index/Status.php
@@ -92,6 +92,7 @@ public function getAliases()
if (!empty($data['aliases'])) {
return array_keys($data['aliases']);
}
+
return [];
}
diff --git a/lib/Elastica/Multi/ResultSet.php b/lib/Elastica/Multi/ResultSet.php
index d04e39d900..aec25185aa 100644
--- a/lib/Elastica/Multi/ResultSet.php
+++ b/lib/Elastica/Multi/ResultSet.php
@@ -4,8 +4,8 @@
use Elastica\Exception\InvalidException;
use Elastica\Response;
-use Elastica\Search as BaseSearch;
use Elastica\ResultSet as BaseResultSet;
+use Elastica\Search as BaseSearch;
/**
* Elastica multi search result set
diff --git a/lib/Elastica/Percolator.php b/lib/Elastica/Percolator.php
index 975ca26c9d..10a0a8cbab 100644
--- a/lib/Elastica/Percolator.php
+++ b/lib/Elastica/Percolator.php
@@ -83,20 +83,20 @@ public function unregisterQuery($name)
/**
* Match a document to percolator queries
*
- * @param \Elastica\Document $doc
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
- * are executed.
- * @param string $type
- * @param array $params Supports setting additional request body options to the percolate request.
- * [ Percolator::EXTRA_FILTER,
- * Percolator::EXTRA_QUERY,
- * Percolator::EXTRA_SIZE,
- * Percolator::EXTRA_TRACK_SCORES,
- * Percolator::EXTRA_SORT,
- * Percolator::EXTRA_FACETS,
- * Percolator::EXTRA_AGGS,
- * Percolator::EXTRA_HIGHLIGHT ]
- * @return array With matching registered queries.
+ * @param \Elastica\Document $doc
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
+ * are executed.
+ * @param string $type
+ * @param array $params Supports setting additional request body options to the percolate request.
+ * [ Percolator::EXTRA_FILTER,
+ * Percolator::EXTRA_QUERY,
+ * Percolator::EXTRA_SIZE,
+ * Percolator::EXTRA_TRACK_SCORES,
+ * Percolator::EXTRA_SORT,
+ * Percolator::EXTRA_FACETS,
+ * Percolator::EXTRA_AGGS,
+ * Percolator::EXTRA_HIGHLIGHT ]
+ * @return array With matching registered queries.
*/
public function matchDoc(Document $doc, $query = null, $type = 'type', $params = array())
{
@@ -111,20 +111,20 @@ public function matchDoc(Document $doc, $query = null, $type = 'type', $params =
/**
* Percolating an existing document
*
- * @param string $id
- * @param string $type
- * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
- * are executed.
- * @param array $params Supports setting additional request body options to the percolate request.
- * [ Percolator::EXTRA_FILTER,
- * Percolator::EXTRA_QUERY,
- * Percolator::EXTRA_SIZE,
- * Percolator::EXTRA_TRACK_SCORES,
- * Percolator::EXTRA_SORT,
- * Percolator::EXTRA_FACETS,
- * Percolator::EXTRA_AGGS,
- * Percolator::EXTRA_HIGHLIGHT ]
- * @return array With matching registered queries.
+ * @param string $id
+ * @param string $type
+ * @param string|\Elastica\Query|\Elastica\Query\AbstractQuery $query Query to filter the percolator queries which
+ * are executed.
+ * @param array $params Supports setting additional request body options to the percolate request.
+ * [ Percolator::EXTRA_FILTER,
+ * Percolator::EXTRA_QUERY,
+ * Percolator::EXTRA_SIZE,
+ * Percolator::EXTRA_TRACK_SCORES,
+ * Percolator::EXTRA_SORT,
+ * Percolator::EXTRA_FACETS,
+ * Percolator::EXTRA_AGGS,
+ * Percolator::EXTRA_HIGHLIGHT ]
+ * @return array With matching registered queries.
*/
public function matchExistingDoc($id, $type, $query = null, $params = array())
{
@@ -139,7 +139,7 @@ public function matchExistingDoc($id, $type, $query = null, $params = array())
/**
* Process the provided parameters and apply them to the data array.
- *
+ *
* @param &$params
* @param &$data
*/
diff --git a/lib/Elastica/Query/Filtered.php b/lib/Elastica/Query/Filtered.php
index 75de232b1d..26df75d7f6 100644
--- a/lib/Elastica/Query/Filtered.php
+++ b/lib/Elastica/Query/Filtered.php
@@ -2,8 +2,8 @@
namespace Elastica\Query;
-use Elastica\Filter\AbstractFilter;
use Elastica\Exception\InvalidException;
+use Elastica\Filter\AbstractFilter;
/**
* Filtered query. Needs a query and a filter
diff --git a/lib/Elastica/Query/FunctionScore.php b/lib/Elastica/Query/FunctionScore.php
index a2a7809ce6..f2a666f556 100644
--- a/lib/Elastica/Query/FunctionScore.php
+++ b/lib/Elastica/Query/FunctionScore.php
@@ -72,6 +72,7 @@ public function addFunction($functionType, $functionParams, AbstractFilter $filt
}
$this->_functions[] = $function;
+
return $this;
}
@@ -141,8 +142,8 @@ public function addBoostFactorFunction($boostFactor, AbstractFilter $filter = nu
}
/**
- * @param float $weight the weight of the function
- * @param AbstractFilter $filter a filter associated with this function
+ * @param float $weight the weight of the function
+ * @param AbstractFilter $filter a filter associated with this function
*
* @return void
*/
diff --git a/lib/Elastica/Query/Regexp.php b/lib/Elastica/Query/Regexp.php
index ca62d45875..a7258373d8 100644
--- a/lib/Elastica/Query/Regexp.php
+++ b/lib/Elastica/Query/Regexp.php
@@ -29,9 +29,9 @@ public function __construct($key = '', $value = null, $boost = 1.0)
/**
* Sets the query expression for a key with its boost value
*
- * @param string $key
- * @param string $value
- * @param float $boost
+ * @param string $key
+ * @param string $value
+ * @param float $boost
* @return \Elastica\Query\Regexp
*/
public function setValue($key, $value, $boost = 1.0)
diff --git a/lib/Elastica/QueryBuilder/DSL/Aggregation.php b/lib/Elastica/QueryBuilder/DSL/Aggregation.php
index afbfc2c4a8..c2abd77495 100644
--- a/lib/Elastica/QueryBuilder/DSL/Aggregation.php
+++ b/lib/Elastica/QueryBuilder/DSL/Aggregation.php
@@ -181,7 +181,7 @@ public function geo_bounds($name)
* top hits aggregation
*
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-top-hits-aggregation.html
- * @param string $name
+ * @param string $name
* @return TopHits
*/
public function top_hits($name)
diff --git a/lib/Elastica/QueryBuilder/DSL/Query.php b/lib/Elastica/QueryBuilder/DSL/Query.php
index 2c76fff39a..579d06bec7 100644
--- a/lib/Elastica/QueryBuilder/DSL/Query.php
+++ b/lib/Elastica/QueryBuilder/DSL/Query.php
@@ -4,7 +4,6 @@
use Elastica\Exception\NotImplementedException;
use Elastica\Filter\AbstractFilter;
-use Elastica\Query\HasChild;
use Elastica\Query\AbstractQuery;
use Elastica\Query\Bool;
use Elastica\Query\Boosting;
@@ -15,6 +14,7 @@
use Elastica\Query\FunctionScore;
use Elastica\Query\Fuzzy;
use Elastica\Query\FuzzyLikeThis;
+use Elastica\Query\HasChild;
use Elastica\Query\HasParent;
use Elastica\Query\Ids;
use Elastica\Query\Match;
@@ -389,10 +389,10 @@ public function range($fieldName, array $args)
/**
* regexp query
- * @param string $fieldName
- * @param string $value
- * @param float $boost
- * @return Regexp
+ * @param string $fieldName
+ * @param string $value
+ * @param float $boost
+ * @return Regexp
*
* @link http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html
*/
diff --git a/lib/Elastica/QueryBuilder/Version.php b/lib/Elastica/QueryBuilder/Version.php
index e04a38fb74..71ebf8e615 100644
--- a/lib/Elastica/QueryBuilder/Version.php
+++ b/lib/Elastica/QueryBuilder/Version.php
@@ -2,7 +2,6 @@
namespace Elastica\QueryBuilder;
-
/**
* Abstract Version class
*
diff --git a/lib/Elastica/QueryBuilder/Version/Version140.php b/lib/Elastica/QueryBuilder/Version/Version140.php
index 7c03786005..a257094e80 100644
--- a/lib/Elastica/QueryBuilder/Version/Version140.php
+++ b/lib/Elastica/QueryBuilder/Version/Version140.php
@@ -2,7 +2,6 @@
namespace Elastica\QueryBuilder\Version;
-
/**
* elasticsearch 1.4 DSL
*
diff --git a/lib/Elastica/Transport/AbstractTransport.php b/lib/Elastica/Transport/AbstractTransport.php
index 9c389a0691..c58c350a90 100644
--- a/lib/Elastica/Transport/AbstractTransport.php
+++ b/lib/Elastica/Transport/AbstractTransport.php
@@ -3,9 +3,9 @@
namespace Elastica\Transport;
use Elastica\Connection;
-use Elastica\Request;
use Elastica\Exception\InvalidException;
use Elastica\Param;
+use Elastica\Request;
/**
* Elastica Abstract Transport object
diff --git a/lib/Elastica/Transport/Guzzle.php b/lib/Elastica/Transport/Guzzle.php
index 819c790715..508599e5dc 100644
--- a/lib/Elastica/Transport/Guzzle.php
+++ b/lib/Elastica/Transport/Guzzle.php
@@ -2,17 +2,16 @@
namespace Elastica\Transport;
-use Elastica\Exception\Connection\HttpException;
+use Elastica\Connection;
use Elastica\Exception\Connection\GuzzleException;
+use Elastica\Exception\Connection\HttpException;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Exception\ResponseException;
-use Elastica\Connection;
+use Elastica\JSON;
use Elastica\Request;
use Elastica\Response;
-use Elastica\JSON;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException;
-use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Stream\Stream;
/**
diff --git a/lib/Elastica/Transport/HttpAdapter.php b/lib/Elastica/Transport/HttpAdapter.php
index add3596912..76e0898963 100644
--- a/lib/Elastica/Transport/HttpAdapter.php
+++ b/lib/Elastica/Transport/HttpAdapter.php
@@ -9,9 +9,9 @@
use Elastica\Request as ElasticaRequest;
use Elastica\Response as ElasticaResponse;
use Ivory\HttpAdapter\HttpAdapterInterface;
-use Ivory\HttpAdapter\Message\Stream\StringStream;
use Ivory\HttpAdapter\Message\Request as HttpAdapterRequest;
use Ivory\HttpAdapter\Message\Response as HttpAdapterResponse;
+use Ivory\HttpAdapter\Message\Stream\StringStream;
class HttpAdapter extends AbstractTransport
{
diff --git a/lib/Elastica/Transport/Null.php b/lib/Elastica/Transport/Null.php
index 6dfe1885db..f97a233402 100644
--- a/lib/Elastica/Transport/Null.php
+++ b/lib/Elastica/Transport/Null.php
@@ -24,20 +24,20 @@ class Null extends AbstractTransport
public function exec(Request $request, array $params)
{
$response = array(
- "took" => 0,
- "timed_out" => false,
- "_shards" => array(
- "total" => 0,
- "successful" => 0,
- "failed" => 0,
- ),
- "hits" => array(
- "total" => 0,
- "max_score" => null,
- "hits" => array(),
- ),
- "params" => $params,
- );
+ "took" => 0,
+ "timed_out" => false,
+ "_shards" => array(
+ "total" => 0,
+ "successful" => 0,
+ "failed" => 0,
+ ),
+ "hits" => array(
+ "total" => 0,
+ "max_score" => null,
+ "hits" => array(),
+ ),
+ "params" => $params,
+ );
return new Response(JSON::stringify($response));
}
diff --git a/lib/Elastica/Transport/Thrift.php b/lib/Elastica/Transport/Thrift.php
index 61f4ec5917..5ca6cff230 100644
--- a/lib/Elastica/Transport/Thrift.php
+++ b/lib/Elastica/Transport/Thrift.php
@@ -2,6 +2,7 @@
namespace Elastica\Transport;
+use Elastica\Connection;
use Elastica\Exception\Connection\ThriftException;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Exception\ResponseException;
@@ -9,16 +10,15 @@
use Elastica\JSON;
use Elastica\Request;
use Elastica\Response;
-use Elastica\Connection;
use Elasticsearch\Method;
-use Elasticsearch\RestResponse;
use Elasticsearch\RestClient;
use Elasticsearch\RestRequest;
-use Thrift\Transport\TSocket;
-use Thrift\Transport\TFramedTransport;
-use Thrift\Transport\TBufferedTransport;
-use Thrift\Protocol\TBinaryProtocolAccelerated;
+use Elasticsearch\RestResponse;
use Thrift\Exception\TException;
+use Thrift\Protocol\TBinaryProtocolAccelerated;
+use Thrift\Transport\TBufferedTransport;
+use Thrift\Transport\TFramedTransport;
+use Thrift\Transport\TSocket;
/**
* Elastica Thrift Transport object
diff --git a/lib/Elastica/Type.php b/lib/Elastica/Type.php
index 599c85b0e7..2b44e4df48 100644
--- a/lib/Elastica/Type.php
+++ b/lib/Elastica/Type.php
@@ -2,10 +2,10 @@
namespace Elastica;
-use Elastica\Exception\RuntimeException;
use Elastica\Exception\InvalidException;
use Elastica\Exception\NotFoundException;
use Elastica\Exception\ResponseException;
+use Elastica\Exception\RuntimeException;
use Elastica\Type\Mapping;
/**
diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php
index 75c11fc264..94896a74fa 100644
--- a/lib/Elastica/Util.php
+++ b/lib/Elastica/Util.php
@@ -2,7 +2,6 @@
namespace Elastica;
-
/**
* Elastica tools
*
diff --git a/test/benchmark/ClientTest.php b/test/benchmark/ClientTest.php
index e7a040f7b3..dac5d88777 100644
--- a/test/benchmark/ClientTest.php
+++ b/test/benchmark/ClientTest.php
@@ -26,6 +26,5 @@ public function testServersArray()
$end = microtime(true);
//echo $end - $start;
-
}
}
diff --git a/test/benchmark/TransportTest.php b/test/benchmark/TransportTest.php
index b6c187cccc..343f3ff0de 100644
--- a/test/benchmark/TransportTest.php
+++ b/test/benchmark/TransportTest.php
@@ -1,12 +1,12 @@
getIndex('test');
+
return $index->getType('test');
}
@@ -99,7 +100,7 @@ public function testBulk(array $config, $transport)
for ($i = 0; $i < $this->_max; $i++) {
$docs = array();
for ($j = 0; $j < 10; $j++) {
- $data = $this->getData($i . $j);
+ $data = $this->getData($i.$j);
$docs[] = new Document($i, $data);
}
@@ -124,18 +125,18 @@ public function testGetMapping(array $config, $transport)
$mapping = new Mapping();
$mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
$mapping->setProperties(array(
- 'id' => array('type' => 'integer', 'include_in_all' => FALSE),
+ 'id' => array('type' => 'integer', 'include_in_all' => false),
'user' => array(
'type' => 'object',
'properties' => array(
- 'name' => array('type' => 'string', 'include_in_all' => TRUE),
- 'fullName' => array('type' => 'string', 'include_in_all' => TRUE)
+ '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)
+ '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),
));
$type->setMapping($mapping);
@@ -159,7 +160,7 @@ public function providerTransport()
'port' => 9200,
'persistent' => false,
),
- 'Http:NotPersistent'
+ 'Http:NotPersistent',
),
array(
array(
@@ -168,7 +169,7 @@ public function providerTransport()
'port' => 9200,
'persistent' => true,
),
- 'Http:Persistent'
+ 'Http:Persistent',
),
array(
array(
@@ -179,13 +180,13 @@ public function providerTransport()
'framedTransport' => false,
),
),
- 'Thrift:Buffered'
+ 'Thrift:Buffered',
),
);
}
/**
- * @param string $test
+ * @param string $test
* @return array
*/
protected function getData($test)
@@ -197,6 +198,7 @@ protected function getData($test)
for ($i = 0; $i < $this->_maxData; $i++) {
$data['name'][] = uniqid();
}
+
return $data;
}
diff --git a/test/benchmark/phpunit.benchmark.xml b/test/benchmark/phpunit.benchmark.xml
index a530de3598..383594e17d 100644
--- a/test/benchmark/phpunit.benchmark.xml
+++ b/test/benchmark/phpunit.benchmark.xml
@@ -7,4 +7,4 @@
TransportTest.php
-
\ No newline at end of file
+
diff --git a/test/benchmark/phpunit.xhprof.xml b/test/benchmark/phpunit.xhprof.xml
index 2293155a16..41a057bcda 100644
--- a/test/benchmark/phpunit.xhprof.xml
+++ b/test/benchmark/phpunit.xhprof.xml
@@ -36,4 +36,4 @@
-
\ No newline at end of file
+
diff --git a/test/bootstrap.php b/test/bootstrap.php
index 5903f80528..8a29cf0fae 100644
--- a/test/bootstrap.php
+++ b/test/bootstrap.php
@@ -2,4 +2,4 @@
defined('BASE_PATH') || define('BASE_PATH', realpath(__DIR__));
-require dirname(__DIR__) . '/vendor/autoload.php';
+require dirname(__DIR__).'/vendor/autoload.php';
diff --git a/test/lib/Elastica/Test/Aggregation/AvgTest.php b/test/lib/Elastica/Test/Aggregation/AvgTest.php
index 5c6fe13d59..dc0800d1cf 100644
--- a/test/lib/Elastica/Test/Aggregation/AvgTest.php
+++ b/test/lib/Elastica/Test/Aggregation/AvgTest.php
@@ -2,10 +2,8 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Document;
-use Elastica\Index;
use Elastica\Query;
class AvgTest extends BaseAggregationTest
@@ -35,4 +33,3 @@ public function testAvgAggregation()
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php b/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
index 5569ca789f..e7b5734a16 100644
--- a/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
+++ b/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Index;
use Elastica\Test\Base;
@@ -23,6 +22,6 @@ protected function tearDown()
protected function _createIndex($name = 'test', $delete = true, $shards = 1)
{
- return parent::_createIndex('test_aggregation_' . $name, $delete, $shards);
+ return parent::_createIndex('test_aggregation_'.$name, $delete, $shards);
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/Aggregation/CardinalityTest.php b/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
index d2f4d2be55..c591021451 100644
--- a/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
+++ b/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Cardinality;
use Elastica\Document;
use Elastica\Query;
@@ -35,4 +34,3 @@ public function testCardinalityAggregation()
$this->assertEquals(3, $results['value']);
}
}
-
diff --git a/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php b/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
index d5bd878c5a..b27cb2f2b6 100644
--- a/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
+++ b/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateHistogram;
use Elastica\Document;
use Elastica\Query;
@@ -16,7 +15,7 @@ protected function setUp()
$this->_index = $this->_createIndex("date_histogram");
$mapping = new Mapping();
$mapping->setProperties(array(
- "created" => array("type" => "date")
+ "created" => array("type" => "date"),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -40,4 +39,3 @@ public function testDateHistogramAggregation()
$this->assertEquals(3, sizeof($results['buckets']));
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/DateRangeTest.php b/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
index 781f211250..6dcfc60c5b 100644
--- a/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
+++ b/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateRange;
use Elastica\Document;
use Elastica\Query;
@@ -16,7 +15,7 @@ protected function setUp()
$this->_index = $this->_createIndex("date_range");
$mapping = new Mapping();
$mapping->setProperties(array(
- "created" => array("type" => "date")
+ "created" => array("type" => "date"),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -42,10 +41,9 @@ public function testDateRangeAggregation()
foreach ($results['buckets'] as $bucket) {
if (array_key_exists('to', $bucket)) {
$this->assertEquals(1, $bucket['doc_count']);
- } else if (array_key_exists('from', $bucket)) {
+ } elseif (array_key_exists('from', $bucket)) {
$this->assertEquals(2, $bucket['doc_count']);
}
}
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php b/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
index e125c9c9c2..e7561606c6 100644
--- a/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
+++ b/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ExtendedStats;
use Elastica\Document;
use Elastica\Query;
@@ -40,4 +39,3 @@ public function testExtendedStatsAggregation()
$this->assertTrue(array_key_exists('sum_of_squares', $results));
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/FilterTest.php b/test/lib/Elastica/Test/Aggregation/FilterTest.php
index dd4d4c2dd7..f3fca151df 100644
--- a/test/lib/Elastica/Test/Aggregation/FilterTest.php
+++ b/test/lib/Elastica/Test/Aggregation/FilterTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\Filter;
use Elastica\Document;
@@ -31,8 +30,8 @@ public function testToArray()
$expected = array(
"filter" => array("range" => array("stock" => array("gt" => 0))),
"aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ "avg_price" => array("avg" => array("field" => "price")),
+ ),
);
$agg = new Filter("in_stock_products");
@@ -75,4 +74,3 @@ public function testFilterNoSubAggregation()
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php b/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
index 7fd677b13c..7dbff9d3ce 100644
--- a/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
+++ b/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeoDistance;
use Elastica\Document;
use Elastica\Query;
@@ -16,7 +15,7 @@ protected function setUp()
$this->_index = $this->_createIndex("geo_distance");
$mapping = new Mapping();
$mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ "location" => array("type" => "geo_point"),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -42,4 +41,3 @@ public function testGeoDistanceAggregation()
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php b/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
index 38a047f7bd..95104d53a6 100644
--- a/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
+++ b/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeohashGrid;
use Elastica\Document;
use Elastica\Query;
@@ -16,7 +15,7 @@ protected function setUp()
$this->_index = $this->_createIndex("geohash_grid");
$mapping = new Mapping();
$mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ "location" => array("type" => "geo_point"),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -42,4 +41,3 @@ public function testGeohashGridAggregation()
$this->assertEquals(1, $results['buckets'][1]['doc_count']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php b/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
index 80366f505b..240982dbf3 100644
--- a/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
+++ b/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\GlobalAggregation;
@@ -13,8 +12,8 @@ public function testToArray()
$expected = array(
"global" => new \stdClass(),
"aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ "avg_price" => array("avg" => array("field" => "price")),
+ ),
);
$agg = new GlobalAggregation("all_products");
@@ -24,4 +23,3 @@ public function testToArray()
$this->assertEquals($expected, $agg->toArray());
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/HistogramTest.php b/test/lib/Elastica/Test/Aggregation/HistogramTest.php
index 35032f43ad..47e15fa744 100644
--- a/test/lib/Elastica/Test/Aggregation/HistogramTest.php
+++ b/test/lib/Elastica/Test/Aggregation/HistogramTest.php
@@ -2,9 +2,8 @@
namespace Elastica\Test\Aggregation;
-
-use Elastica\Document;
use Elastica\Aggregation\Histogram;
+use Elastica\Document;
use Elastica\Query;
class HistogramTest extends BaseAggregationTest
@@ -42,4 +41,3 @@ public function testHistogramAggregation()
$this->assertEquals(2, $buckets[3]['doc_count']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/IpRangeTest.php b/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
index fce6f8578b..25ebca401d 100644
--- a/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
+++ b/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\IpRange;
use Elastica\Document;
use Elastica\Query;
@@ -16,7 +15,7 @@ protected function setUp()
$this->_index = $this->_createIndex("ip_range");
$mapping = new Mapping();
$mapping->setProperties(array(
- "address" => array("type" => "ip")
+ "address" => array("type" => "ip"),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -34,14 +33,14 @@ public function testIpRangeAggregation()
$agg = new IpRange("ip", "address");
$agg->addRange("192.168.1.101");
$agg->addRange(null, "192.168.1.200");
-
+
$cidrRange = "192.168.1.0/24";
$agg->addMaskRange($cidrRange);
$query = new Query();
$query->addAggregation($agg);
$results = $this->_index->search($query)->getAggregation("ip");
-
+
foreach ($results['buckets'] as $bucket) {
if (array_key_exists('key', $bucket) && $bucket['key'] == $cidrRange) {
// the CIDR mask
@@ -53,4 +52,3 @@ public function testIpRangeAggregation()
}
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/MaxTest.php b/test/lib/Elastica/Test/Aggregation/MaxTest.php
index 0f5475b3fd..ebbacf43b0 100644
--- a/test/lib/Elastica/Test/Aggregation/MaxTest.php
+++ b/test/lib/Elastica/Test/Aggregation/MaxTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Max;
use Elastica\Document;
use Elastica\Query;
@@ -31,12 +30,12 @@ public function testToArray()
"field" => "price",
"script" => "_value * conversion_rate",
"params" => array(
- "conversion_rate" => 1.2
- )
+ "conversion_rate" => 1.2,
+ ),
),
"aggs" => array(
- "subagg" => array("max" => array("field" => "foo"))
- )
+ "subagg" => array("max" => array("field" => "foo")),
+ ),
);
$agg = new Max("min_price_in_euros");
@@ -69,4 +68,3 @@ public function testMaxAggregation()
$this->assertEquals(8 * 1.2, $results['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/MinTest.php b/test/lib/Elastica/Test/Aggregation/MinTest.php
index 44b52fb443..c07a83f7fb 100644
--- a/test/lib/Elastica/Test/Aggregation/MinTest.php
+++ b/test/lib/Elastica/Test/Aggregation/MinTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Document;
use Elastica\Query;
@@ -35,4 +34,3 @@ public function testMinAggregation()
$this->assertEquals(1, $results['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/MissingTest.php b/test/lib/Elastica/Test/Aggregation/MissingTest.php
index 2a852ed07c..613ba243a9 100644
--- a/test/lib/Elastica/Test/Aggregation/MissingTest.php
+++ b/test/lib/Elastica/Test/Aggregation/MissingTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Missing;
use Elastica\Document;
use Elastica\Query;
@@ -34,4 +33,3 @@ public function testMissingAggregation()
$this->assertEquals(1, $results['doc_count']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/NestedTest.php b/test/lib/Elastica/Test/Aggregation/NestedTest.php
index ed6de99ead..b7a25af7da 100644
--- a/test/lib/Elastica/Test/Aggregation/NestedTest.php
+++ b/test/lib/Elastica/Test/Aggregation/NestedTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Aggregation\Nested;
use Elastica\Document;
@@ -21,9 +20,9 @@ protected function setUp()
"type" => "nested",
"properties" => array(
"name" => array("type" => "string"),
- "price" => array("type" => "double")
- )
- )
+ "price" => array("type" => "double"),
+ ),
+ ),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -31,15 +30,15 @@ protected function setUp()
new Document("1", array(
"resellers" => array(
"name" => "spacely sprockets",
- "price" => 5.55
- )
+ "price" => 5.55,
+ ),
)),
new Document("1", array(
"resellers" => array(
"name" => "cogswell cogs",
- "price" => 4.98
- )
- ))
+ "price" => 4.98,
+ ),
+ )),
);
$type->addDocuments($docs);
$this->_index->refresh();
@@ -59,4 +58,3 @@ public function testNestedAggregation()
$this->assertEquals(4.98, $results['min_price']['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/RangeTest.php b/test/lib/Elastica/Test/Aggregation/RangeTest.php
index 789099101e..02dcb51065 100644
--- a/test/lib/Elastica/Test/Aggregation/RangeTest.php
+++ b/test/lib/Elastica/Test/Aggregation/RangeTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Range;
use Elastica\Document;
use Elastica\Query;
@@ -38,7 +37,6 @@ public function testRangeAggregation()
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
-
public function testRangeAggregationWithKey()
{
$agg = new Range("range");
@@ -47,22 +45,20 @@ public function testRangeAggregationWithKey()
$agg->addRange(50, 100, "average");
$agg->addRange(100, null, "expensive");
- $expected = array (
- 'range' =>
- array (
+ $expected = array(
+ 'range' => array(
'field' => 'price',
- 'ranges' =>
- array (
- array (
+ 'ranges' => array(
+ array(
'to' => 50,
'key' => 'cheap',
),
- array (
+ array(
'from' => 50,
'to' => 100,
'key' => 'average',
),
- array (
+ array(
'from' => 100,
'key' => 'expensive',
),
@@ -71,4 +67,5 @@ public function testRangeAggregationWithKey()
);
$this->assertEquals($expected, $agg->toArray());
- }}
+ }
+}
diff --git a/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
index 215dac63fd..0649e6b185 100644
--- a/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
+++ b/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
@@ -2,9 +2,9 @@
namespace Elastica\Test\Aggregation;
-use Elastica\Aggregation\Terms;
use Elastica\Aggregation\Nested;
use Elastica\Aggregation\ReverseNested;
+use Elastica\Aggregation\Terms;
use Elastica\Document;
use Elastica\Query;
use Elastica\Type\Mapping;
@@ -21,9 +21,9 @@ protected function setUp()
"type" => "nested",
"properties" => array(
"name" => array("type" => "string"),
- "body" => array("type" => "string")
- )
- )
+ "body" => array("type" => "string"),
+ ),
+ ),
));
$type = $this->_index->getType("test");
$type->setMapping($mapping);
@@ -53,7 +53,7 @@ protected function setUp()
),
),
"tags" => array("foo", "baz"),
- ))
+ )),
);
$type->addDocuments($docs);
$this->_index->refresh();
diff --git a/test/lib/Elastica/Test/Aggregation/ScriptTest.php b/test/lib/Elastica/Test/Aggregation/ScriptTest.php
index 0b31848bd6..912dddd085 100644
--- a/test/lib/Elastica/Test/Aggregation/ScriptTest.php
+++ b/test/lib/Elastica/Test/Aggregation/ScriptTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Sum;
use Elastica\Document;
use Elastica\Query;
@@ -10,68 +9,69 @@
class ScriptTest extends BaseAggregationTest
{
- protected function setUp()
- {
- parent::setUp();
- $this->_index = $this->_createIndex('script');
- $docs = 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)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
- }
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->_index = $this->_createIndex('script');
+ $docs = 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)),
+ );
+ $this->_index->getType('test')->addDocuments($docs);
+ $this->_index->refresh();
+ }
- public function testAggregationScript()
- {
- $agg = new Sum("sum");
- // x = (0..1) is groovy-specific syntax, to see if lang is recognized
- $script = new Script("x = (0..1); return doc['price'].value", null, "groovy");
- $agg->setScript($script);
+ public function testAggregationScript()
+ {
+ $agg = new Sum("sum");
+ // x = (0..1) is groovy-specific syntax, to see if lang is recognized
+ $script = new Script("x = (0..1); return doc['price'].value", null, "groovy");
+ $agg->setScript($script);
- $query = new Query();
- $query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("sum");
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_index->search($query)->getAggregation("sum");
- $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
- }
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
- public function testAggregationScriptAsString()
- {
- $agg = new Sum("sum");
- $agg->setScript("doc['price'].value");
+ public function testAggregationScriptAsString()
+ {
+ $agg = new Sum("sum");
+ $agg->setScript("doc['price'].value");
- $query = new Query();
- $query->addAggregation( $agg );
- $results = $this->_index->search($query)->getAggregation("sum");
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_index->search($query)->getAggregation("sum");
- $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
- }
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
- public function testSetScript() {
- $aggregation = "sum";
- $string = "doc['price'].value";
- $params = array(
- 'param1' => 'one',
- 'param2' => 1,
- );
- $lang = "groovy";
+ public function testSetScript()
+ {
+ $aggregation = "sum";
+ $string = "doc['price'].value";
+ $params = array(
+ 'param1' => 'one',
+ 'param2' => 1,
+ );
+ $lang = "groovy";
- $agg = new Sum($aggregation);
- $script = new Script($string, $params, $lang);
- $agg->setScript($script);
+ $agg = new Sum($aggregation);
+ $script = new Script($string, $params, $lang);
+ $agg->setScript($script);
- $array = $agg->toArray();
+ $array = $agg->toArray();
- $expected = array(
- $aggregation => array(
- 'script' => $string,
- 'params' => $params,
- 'lang' => $lang,
- )
- );
- $this->assertEquals($expected, $array);
- }
+ $expected = array(
+ $aggregation => array(
+ 'script' => $string,
+ 'params' => $params,
+ 'lang' => $lang,
+ ),
+ );
+ $this->assertEquals($expected, $array);
+ }
}
diff --git a/test/lib/Elastica/Test/Aggregation/StatsTest.php b/test/lib/Elastica/Test/Aggregation/StatsTest.php
index 2d315abfa3..9add17e41a 100644
--- a/test/lib/Elastica/Test/Aggregation/StatsTest.php
+++ b/test/lib/Elastica/Test/Aggregation/StatsTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Stats;
use Elastica\Document;
use Elastica\Query;
@@ -39,4 +38,3 @@ public function testStatsAggregation()
$this->assertEquals((5 + 8 + 1 + 3), $results['sum']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/SumTest.php b/test/lib/Elastica/Test/Aggregation/SumTest.php
index 3b3c56a2f2..b94e6f775d 100644
--- a/test/lib/Elastica/Test/Aggregation/SumTest.php
+++ b/test/lib/Elastica/Test/Aggregation/SumTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Sum;
use Elastica\Document;
use Elastica\Query;
@@ -35,4 +34,3 @@ public function testSumAggregation()
$this->assertEquals(5 + 8 + 1 + 3, $results['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/TermsTest.php b/test/lib/Elastica/Test/Aggregation/TermsTest.php
index d9f37a2027..b5eee91264 100644
--- a/test/lib/Elastica/Test/Aggregation/TermsTest.php
+++ b/test/lib/Elastica/Test/Aggregation/TermsTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Terms;
use Elastica\Document;
use Elastica\Query;
@@ -36,4 +35,3 @@ public function testTermsAggregation()
$this->assertEquals("blue", $results['buckets'][0]['key']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Aggregation/ValueCountTest.php b/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
index 5eba9ea4e5..01f0e855c6 100644
--- a/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
+++ b/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
@@ -35,4 +34,3 @@ public function testValueCountAggregation()
$this->assertEquals(5, $results['value']);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Base.php b/test/lib/Elastica/Test/Base.php
index c6c995ec02..6376d6e2cd 100644
--- a/test/lib/Elastica/Test/Base.php
+++ b/test/lib/Elastica/Test/Base.php
@@ -16,15 +16,15 @@ protected function _getClient()
}
/**
- * @param string $name Index name
- * @param bool $delete Delete index if it exists
- * @param int $shards Number of shards to create
+ * @param string $name Index name
+ * @param bool $delete Delete index if it exists
+ * @param int $shards Number of shards to create
* @return \Elastica\Index
*/
protected function _createIndex($name = 'test', $delete = true, $shards = 1)
{
$client = $this->_getClient();
- $index = $client->getIndex('elastica_' . $name);
+ $index = $client->getIndex('elastica_'.$name);
$index->create(array('index' => array('number_of_shards' => $shards, 'number_of_replicas' => 0)), $delete);
return $index;
diff --git a/test/lib/Elastica/Test/Bulk/ActionTest.php b/test/lib/Elastica/Test/Bulk/ActionTest.php
index 178883a89b..774bd45a1f 100644
--- a/test/lib/Elastica/Test/Bulk/ActionTest.php
+++ b/test/lib/Elastica/Test/Bulk/ActionTest.php
@@ -3,13 +3,9 @@
namespace Elastica\Test\Bulk;
use Elastica\Bulk\Action;
-use Elastica\Bulk;
use Elastica\Client;
-use Elastica\Exception\Bulk\ResponseException;
use Elastica\Index;
use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\ResponseSet;
-use Elastica\Response;
use Elastica\Type;
class ActionTest extends BaseTest
@@ -20,25 +16,25 @@ public function testAction()
$this->assertEquals('index', $action->getOpType());
$this->assertFalse($action->hasSource());
- $expected = '{"index":{}}' . "\n";
+ $expected = '{"index":{}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setIndex('index');
- $expected = '{"index":{"_index":"index"}}' . "\n";
+ $expected = '{"index":{"_index":"index"}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setType('type');
- $expected = '{"index":{"_index":"index","_type":"type"}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type"}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setId(1);
- $expected = '{"index":{"_index":"index","_type":"type","_id":1}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type","_id":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setRouting(1);
- $expected = '{"index":{"_index":"index","_type":"type","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index","_type":"type","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$client = new Client();
@@ -47,18 +43,18 @@ public function testAction()
$action->setIndex($index);
- $expected = '{"index":{"_index":"index2","_type":"type","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setType($type);
- $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n";
$this->assertEquals($expected, $action->toString());
$action->setSource(array('user' => 'name'));
- $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}' . "\n";
- $expected.= '{"user":"name"}' . "\n";
+ $expected = '{"index":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n";
+ $expected .= '{"user":"name"}'."\n";
$this->assertEquals($expected, $action->toString());
$this->assertTrue($action->hasSource());
diff --git a/test/lib/Elastica/Test/Bulk/ResponseSetTest.php b/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
index d1495fce82..d661154281 100644
--- a/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
+++ b/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
@@ -2,12 +2,12 @@
namespace Elastica\Test\Bulk;
-use Elastica\Bulk\Action;
use Elastica\Bulk;
-use Elastica\Exception\Bulk\ResponseException;
-use Elastica\Test\Base as BaseTest;
+use Elastica\Bulk\Action;
use Elastica\Bulk\ResponseSet;
+use Elastica\Exception\Bulk\ResponseException;
use Elastica\Response;
+use Elastica\Test\Base as BaseTest;
class ResponseSetTest extends BaseTest
{
@@ -119,12 +119,13 @@ public function isOkDataProvider()
$return[] = array($responseData, $actions, true);
$responseData['items'][2]['index']['ok'] = false;
$return[] = array($responseData, $actions, false);
+
return $return;
}
/**
- * @param array $responseData
- * @param array $actions
+ * @param array $responseData
+ * @param array $actions
* @return \Elastica\Bulk\ResponseSet
*/
protected function _createResponseSet(array $responseData, array $actions)
@@ -138,6 +139,7 @@ protected function _createResponseSet(array $responseData, array $actions)
$bulk = new Bulk($client);
$bulk->addActions($actions);
+
return $bulk->send();
}
@@ -156,7 +158,7 @@ protected function _getFixture()
'_id' => '1',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -165,7 +167,7 @@ protected function _getFixture()
'_id' => '2',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -174,15 +176,16 @@ protected function _getFixture()
'_id' => '3',
'_version' => 1,
'ok' => true,
- )
- )
- )
+ ),
+ ),
+ ),
);
$bulkResponses = array(
new Action(),
new Action(),
new Action(),
);
+
return array($responseData, $bulkResponses);
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/BulkTest.php b/test/lib/Elastica/Test/BulkTest.php
index 3396fe863c..7a27ba8a1c 100644
--- a/test/lib/Elastica/Test/BulkTest.php
+++ b/test/lib/Elastica/Test/BulkTest.php
@@ -4,14 +4,14 @@
use Elastica\Bulk;
use Elastica\Bulk\Action;
+use Elastica\Bulk\Action\AbstractDocument;
use Elastica\Client;
use Elastica\Document;
use Elastica\Exception\Bulk\ResponseException;
use Elastica\Exception\InvalidException;
use Elastica\Exception\NotFoundException;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\Action\AbstractDocument;
use Elastica\Filter\Script;
+use Elastica\Test\Base as BaseTest;
class BulkTest extends BaseTest
{
@@ -35,7 +35,7 @@ public function testSend()
$newDocument1,
$newDocument2,
$newDocument3,
- $newDocument4
+ $newDocument4,
);
$bulk = new Bulk($client);
@@ -85,7 +85,7 @@ public function testSend()
';
$expected = str_replace(PHP_EOL, "\n", $expected);
- $this->assertEquals($expected, (string)str_replace(PHP_EOL, "\n", (string)$bulk));
+ $this->assertEquals($expected, (string) str_replace(PHP_EOL, "\n", (string) $bulk));
$response = $bulk->send();
@@ -107,7 +107,6 @@ public function testSend()
$this->assertEquals(3, $type->count());
$this->assertEquals(1, $type2->count());
-
$bulk = new Bulk($client);
$bulk->addDocument($newDocument3, Action::OP_TYPE_DELETE);
@@ -146,7 +145,7 @@ public function testUnicodeBulkSend()
$documents = array(
$newDocument1,
$newDocument2,
- $newDocument3
+ $newDocument3,
);
$bulk = new Bulk($client);
@@ -216,7 +215,7 @@ public function testAddActions()
$actions = array(
$action1,
- $action2
+ $action2,
);
$bulk->addActions($actions);
@@ -298,7 +297,7 @@ public function invalidRawDataProvider()
array('user' => array('name' => 'hans')),
array('user' => array('name' => 'mans')),
),
- 'Two sources for one action'
+ 'Two sources for one action',
),
array(
array(
@@ -306,26 +305,26 @@ public function invalidRawDataProvider()
array('user' => array('name' => 'hans')),
array('upsert' => array('_index' => 'test', '_type' => 'user', '_id' => '2')),
),
- 'Invalid optype for action'
+ 'Invalid optype for action',
),
array(
array(
array('user' => array('name' => 'mans')),
),
- 'Source without action'
+ 'Source without action',
),
array(
array(
array(),
),
- 'Empty array'
+ 'Empty array',
),
array(
array(
'dummy',
),
- 'String as data'
- )
+ 'String as data',
+ ),
);
}
@@ -609,11 +608,11 @@ public function testGetPath()
$indexName = 'testIndex';
$bulk->setIndex($indexName);
- $this->assertEquals($indexName . '/_bulk', $bulk->getPath());
+ $this->assertEquals($indexName.'/_bulk', $bulk->getPath());
$typeName = 'testType';
$bulk->setType($typeName);
- $this->assertEquals($indexName . '/' . $typeName . '/_bulk', $bulk->getPath());
+ $this->assertEquals($indexName.'/'.$typeName.'/_bulk', $bulk->getPath());
}
public function testRetry()
@@ -634,7 +633,7 @@ public function testRetry()
$metadata = $actions[0]->getMetadata();
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
- $script = new \Elastica\Script( '' );
+ $script = new \Elastica\Script('');
$script->setRetryOnConflict(5);
$bulk = new Bulk($client);
@@ -652,59 +651,59 @@ public function udpDataProvider()
array(
array(),
null,
- null
+ null,
),
array(
array(),
'localhost',
- null
+ null,
),
array(
array(),
null,
- 9700
+ 9700,
),
array(
array(),
'localhost',
- 9700
+ 9700,
),
array(
array(
'udp' => array(
'host' => 'localhost',
'port' => 9700,
- )
+ ),
),
null,
- null
+ null,
),
array(
array(
'udp' => array(
'host' => 'localhost',
'port' => 9800,
- )
+ ),
),
'localhost',
- 9700
+ 9700,
),
array(
array(
'udp' => array(
'host' => 'localhost',
'port' => 9800,
- )
+ ),
),
null,
null,
- true
+ true,
),
array(
array(),
'localhost',
9800,
- true
+ true,
),
);
}
diff --git a/test/lib/Elastica/Test/ClientTest.php b/test/lib/Elastica/Test/ClientTest.php
index 94ee2eadbd..26b49a9ebd 100644
--- a/test/lib/Elastica/Test/ClientTest.php
+++ b/test/lib/Elastica/Test/ClientTest.php
@@ -5,11 +5,10 @@
use Elastica\Client;
use Elastica\Connection;
use Elastica\Document;
-use Elastica\Exception\ClientException;
use Elastica\Exception\Connection\HttpException;
-use Elastica\Script;
use Elastica\Index;
use Elastica\Request;
+use Elastica\Script;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
@@ -159,7 +158,7 @@ public function testBulkIndex()
$index->updateDocuments(array(
new Document(1, array('name' => 'AnonCoin'), 'altcoin'),
- new Document(2, array('name' => 'iXcoin'), 'altcoin')
+ new Document(2, array('name' => 'iXcoin'), 'altcoin'),
));
$this->assertEquals('AnonCoin', $index->getType('altcoin')->getDocument(1)->get('name'));
@@ -190,7 +189,7 @@ public function testBulkType()
$type->updateDocuments(array(
new Document(1, array('name' => 'LiteCoin')),
- new Document(2, array('name' => 'NameCoin'))
+ new Document(2, array('name' => 'NameCoin')),
));
$this->assertEquals('LiteCoin', $type->getDocument(1)->get('name'));
@@ -243,21 +242,21 @@ public function testUpdateDocuments()
}
/**
- * Test deleteIds method using string parameters
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter and $type parameter that are
- * strings
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using string parameters
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter and $type parameter that are
+ * strings
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ */
public function testDeleteIdsIdxStringTypeString()
{
$data = array('username' => 'hans');
@@ -289,8 +288,8 @@ public function testDeleteIdsIdxStringTypeString()
// deleteIds are the type we are testing for
$idxString = $index->getName();
$typeString = $type->getName();
- $this->assertEquals(true, is_string($idxString));
- $this->assertEquals(true, is_string($typeString));
+ $this->assertTrue(is_string($idxString));
+ $this->assertTrue(is_string($typeString));
// Try to delete doc with a routing value which hashes to
// a different shard then the id.
@@ -318,22 +317,22 @@ public function testDeleteIdsIdxStringTypeString()
}
/**
- * Test deleteIds method using string parameter for $index
- * and object parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is a string and a $type
- * parameter that is of type \Elastica\Type
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using string parameter for $index
+ * and object parameter for $type
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is a string and a $type
+ * parameter that is of type \Elastica\Type
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ */
public function testDeleteIdsIdxStringTypeObject()
{
$data = array('username' => 'hans');
@@ -363,8 +362,8 @@ public function testDeleteIdsIdxStringTypeObject()
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
$idxString = $index->getName();
- $this->assertEquals(true, is_string($idxString));
- $this->assertEquals(true, ($type instanceof Type));
+ $this->assertTrue(is_string($idxString));
+ $this->assertInstanceOf('Elastica\Type', $type);
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -380,22 +379,22 @@ public function testDeleteIdsIdxStringTypeObject()
}
/**
- * Test deleteIds method using object parameter for $index
- * and string parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is of type Elasitca_Index
- * and a $type parameter that is a string
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using object parameter for $index
+ * and string parameter for $type
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is of type Elasitca_Index
+ * and a $type parameter that is a string
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ */
public function testDeleteIdsIdxObjectTypeString()
{
$data = array('username' => 'hans');
@@ -425,8 +424,8 @@ public function testDeleteIdsIdxObjectTypeString()
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
$typeString = $type->getName();
- $this->assertEquals(true, ($index instanceof Index));
- $this->assertEquals(true, is_string($typeString));
+ $this->assertInstanceOf('Elastica\Index', $index);
+ $this->assertTrue(is_string($typeString));
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -442,22 +441,22 @@ public function testDeleteIdsIdxObjectTypeString()
}
/**
- * Test deleteIds method using object parameter for $index
- * and object parameter for $type
- *
- * This test ensures that the deleteIds method of
- * the \Elastica\Client can properly accept and use
- * an $index parameter that is an object and a $type
- * parameter that is of type \Elastica\Type
- *
- * This test is a bit more verbose than just sending the
- * values to deleteIds and checking for exceptions or
- * warnings.
- *
- * It will add a document, search for it, then delete it
- * using the parameter types we are interested in, and then
- * re-search to verify that they have been deleted
- */
+ * Test deleteIds method using object parameter for $index
+ * and object parameter for $type
+ *
+ * This test ensures that the deleteIds method of
+ * the \Elastica\Client can properly accept and use
+ * an $index parameter that is an object and a $type
+ * parameter that is of type \Elastica\Type
+ *
+ * This test is a bit more verbose than just sending the
+ * values to deleteIds and checking for exceptions or
+ * warnings.
+ *
+ * It will add a document, search for it, then delete it
+ * using the parameter types we are interested in, and then
+ * re-search to verify that they have been deleted
+ */
public function testDeleteIdsIdxObjectTypeObject()
{
$data = array('username' => 'hans');
@@ -486,8 +485,8 @@ public function testDeleteIdsIdxObjectTypeObject()
// And verify that the variables we are doing to send to
// deleteIds are the type we are testing for
- $this->assertEquals(true, ($index instanceof Index));
- $this->assertEquals(true, ($type instanceof Type));
+ $this->assertInstanceOf('Elastica\Index', $index);
+ $this->assertInstanceOf('Elastica\Type', $type);
// Using the existing $index and $type variables which
// are \Elastica\Index and \Elastica\Type objects respectively
@@ -537,7 +536,6 @@ public function testTwoInvalidConnection()
$client->request('_status', Request::GET);
$this->fail('Should throw exception as no connection valid');
} catch (HttpException $e) {
- $this->assertTrue(true);
}
$connections = $client->getConnections();
@@ -558,7 +556,7 @@ public function testCallback()
$object = $this;
// Callback function which verifies that disabled connection objects are returned
- $callback = function($connection, $exception, $client) use (&$object, &$count) {
+ $callback = function ($connection, $exception, $client) use (&$object, &$count) {
$object->assertInstanceOf('Elastica\Connection', $connection);
$object->assertInstanceOf('Elastica\Exception\ConnectionException', $exception);
$object->assertInstanceOf('Elastica\Client', $client);
@@ -701,7 +699,7 @@ public function testUpdateDocumentByRawData()
$rawData = array(
'doc' => array(
'field2' => 'value2',
- )
+ ),
);
$response = $client->updateDocument(1, $rawData, $index->getName(), $type->getName(), array('retry_on_conflict' => 1));
@@ -940,9 +938,9 @@ public function testConfigValue()
'level2' => array(
'level3' => 'value3',
),
- 'level21' => 'value21'
+ 'level21' => 'value21',
),
- 'level11' => 'value11'
+ 'level11' => 'value11',
);
$client = new Client($config);
@@ -958,51 +956,50 @@ public function testConfigValue()
$this->assertEquals('value3', $client->getConfigValue(array('level1', 'level2', 'level3')));
$this->assertInternalType('array', $client->getConfigValue(array('level1', 'level2')));
}
-
-
+
public function testArrayQuery()
{
$client = new Client();
-
+
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('username' => 'ruflin')));
$index->refresh();
-
+
$query = array(
'query' => array(
'query_string' => array(
'query' => 'ruflin',
- )
- )
+ ),
+ ),
);
-
- $path = $index->getName() . '/' . $type->getName() . '/_search';
-
+
+ $path = $index->getName().'/'.$type->getName().'/_search';
+
$response = $client->request($path, Request::GET, $query);
$responseArray = $response->getData();
-
+
$this->assertEquals(1, $responseArray['hits']['total']);
}
-
+
public function testJSONQuery()
{
$client = new Client();
-
+
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('username' => 'ruflin')));
$index->refresh();
-
+
$query = '{"query":{"query_string":{"query":"ruflin"}}}';
- $path = $index->getName() . '/' . $type->getName() . '/_search';
-
+ $path = $index->getName().'/'.$type->getName().'/_search';
+
$response = $client->request($path, Request::GET, $query);
$responseArray = $response->getData();
-
+
$this->assertEquals(1, $responseArray['hits']['total']);
}
}
diff --git a/test/lib/Elastica/Test/Cluster/Health/IndexTest.php b/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
index 085ac13a03..9703f70236 100644
--- a/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
+++ b/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
@@ -30,7 +30,7 @@ public function setUp()
"active_shards" => 0,
"relocating_shards" => 1,
"initializing_shards" => 0,
- "unassigned_shards" => 1
+ "unassigned_shards" => 1,
),
"1" => array(
"status" => "yellow",
@@ -38,7 +38,7 @@ public function setUp()
"active_shards" => 1,
"relocating_shards" => 0,
"initializing_shards" => 0,
- "unassigned_shards" => 1
+ "unassigned_shards" => 1,
),
"2" => array(
"status" => "green",
@@ -48,7 +48,7 @@ public function setUp()
"initializing_shards" => 0,
"unassigned_shards" => 0,
),
- )
+ ),
);
$this->_index = new HealthIndex('test', $data);
diff --git a/test/lib/Elastica/Test/Cluster/SettingsTest.php b/test/lib/Elastica/Test/Cluster/SettingsTest.php
index 2705e4baee..97329b31f3 100644
--- a/test/lib/Elastica/Test/Cluster/SettingsTest.php
+++ b/test/lib/Elastica/Test/Cluster/SettingsTest.php
@@ -2,10 +2,10 @@
namespace Elastica\Test\Cluster;
+use Elastica\Cluster\Settings;
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Test\Base as BaseTest;
-use Elastica\Cluster\Settings;
class SettingsTest extends BaseTest
{
@@ -55,7 +55,6 @@ public function testSetReadOnly()
$index1 = $this->_createIndex('test1');
$index2 = $this->_createIndex('test2');
-
$doc1 = new Document(null, array('hello' => 'world'));
$doc2 = new Document(null, array('hello' => 'world'));
$doc3 = new Document(null, array('hello' => 'world'));
diff --git a/test/lib/Elastica/Test/Connection/ConnectionPollTest.php b/test/lib/Elastica/Test/Connection/ConnectionPollTest.php
index 81c250ca50..12e97cc9ab 100644
--- a/test/lib/Elastica/Test/Connection/ConnectionPollTest.php
+++ b/test/lib/Elastica/Test/Connection/ConnectionPollTest.php
@@ -2,14 +2,11 @@
namespace Elastica\Test\Connection;
+use Elastica\Connection;
+use Elastica\Connection\ConnectionPool;
+use Elastica\Connection\Strategy\StrategyFactory;
use Elastica\Test\Base as BaseTest;
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
/**
* Description of ConnectionPollTest
*
@@ -20,63 +17,63 @@ class ConnectionPollTest extends BaseTest
public function testConstruct()
{
$pool = $this->createPool();
-
+
$this->assertEquals($this->getConnections(), $pool->getConnections());
}
-
+
public function testSetConnections()
{
$pool = $this->createPool();
-
+
$connections = $this->getConnections(5);
-
+
$pool->setConnections($connections);
-
+
$this->assertEquals($connections, $pool->getConnections());
}
-
+
public function testHasConnection()
{
$pool = $this->createPool();
-
+
$this->assertTrue($pool->hasConnection());
}
-
+
public function testFailHasConnections()
{
$pool = $this->createPool();
-
+
$pool->setConnections(array());
-
+
$this->assertFalse($pool->hasConnection());
}
-
+
public function testGetConnection()
{
$pool = $this->createPool();
-
- $this->assertTrue($pool->getConnection() instanceof \Elastica\Connection);
+
+ $this->assertInstanceOf('Elastica\Connection', $pool->getConnection());
}
-
+
protected function getConnections($quantity = 1)
{
$params = array();
$connections = array();
-
+
for ($i = 0; $i<$quantity; $i++) {
- $connections[] = new \Elastica\Connection($params);
+ $connections[] = new Connection($params);
}
-
+
return $connections;
}
-
+
protected function createPool()
{
$connections = $this->getConnections();
- $strategy = \Elastica\Connection\Strategy\StrategyFactory::create('Simple');
-
- $pool = new \Elastica\Connection\ConnectionPool($connections, $strategy);
-
+ $strategy = StrategyFactory::create('Simple');
+
+ $pool = new ConnectionPool($connections, $strategy);
+
return $pool;
}
}
diff --git a/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php b/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
index 7f5aa84d49..cff8967b48 100644
--- a/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
+++ b/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
@@ -2,6 +2,7 @@
namespace Elastica\Test\Connection\Strategy;
+use Elastica\Client;
use Elastica\Connection\Strategy\CallbackStrategy;
use Elastica\Test\Base;
@@ -15,55 +16,54 @@ class CallbackStrategyTest extends Base
public function testInvoke()
{
$count = 0;
-
- $callback = function ($connections) use(&$count) {
+
+ $callback = function ($connections) use (&$count) {
$count++;
};
-
+
$strategy = new CallbackStrategy($callback);
$strategy->getConnection(array());
-
+
$this->assertEquals(1, $count);
}
-
+
public function testIsValid()
{
- $callback = function(){};
-
+ $callback = function () {};
+
$isValid = CallbackStrategy::isValid($callback);
-
+
$this->assertTrue($isValid);
}
-
+
public function testFailIsValid()
{
$callback = new \stdClass();
-
+
$isValid = CallbackStrategy::isValid($callback);
-
+
$this->assertFalse($isValid);
}
-
+
public function testConnection()
{
$count = 0;
-
- $config = array('connectionStrategy' => function ($connections) use(&$count) {
+
+ $config = array('connectionStrategy' => function ($connections) use (&$count) {
++$count;
+
return current($connections);
});
-
- $client = new \Elastica\Client($config);
- $resonse = $client->request('/_aliases');
-
- $this->assertEquals(1, $count);
-
- $this->assertTrue($resonse->isOk());
-
- $strategy = $client->getConnectionStrategy();
-
- $condition = ($strategy instanceof CallbackStrategy);
-
- $this->assertTrue($condition);
+
+ $client = new Client($config);
+ $response = $client->request('/_aliases');
+
+ $this->assertEquals(1, $count);
+
+ $this->assertTrue($response->isOk());
+
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\CallbackStrategy', $strategy);
}
}
diff --git a/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php b/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
index 85acf54701..7a264de1f5 100644
--- a/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
+++ b/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
@@ -13,6 +13,6 @@ class EmptyStrategy implements StrategyInterface
{
public function getConnection($connections)
{
- return null;
+ return;
}
}
diff --git a/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php b/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
index 1bb36029bf..8ff61cbbb8 100644
--- a/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
+++ b/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
@@ -3,6 +3,7 @@
namespace Elastica\Test\Connection\Strategy;
use Elastica\Client;
+use Elastica\Connection;
use Elastica\Connection\Strategy\RoundRobin;
use Elastica\Exception\ConnectionException;
use Elastica\Response;
@@ -20,10 +21,10 @@ public function testConnection()
{
$config = array('connectionStrategy' => 'RoundRobin');
$client = new Client($config);
- $resonse = $client->request('/_aliases');
- /* @var $resonse Response */
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
- $this->_checkResponse($resonse);
+ $this->_checkResponse($response);
$this->_checkStrategy($client);
}
@@ -43,76 +44,70 @@ public function testFailConnection()
{
$config = array('connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0');
$client = new Client($config);
-
+
$this->_checkStrategy($client);
-
+
$client->request('/_aliases');
-
}
-
+
public function testWithOneFailConnection()
{
$connections = array(
- new \Elastica\Connection(array('host' => '255.255.255.0')),
- new \Elastica\Connection(array('host' => 'localhost')),
+ new Connection(array('host' => '255.255.255.0')),
+ new Connection(array('host' => 'localhost')),
);
-
+
$count = 0;
- $callback = function($connection, $exception, $client) use(&$count) {
+ $callback = function ($connection, $exception, $client) use (&$count) {
++$count;
};
-
+
$client = new Client(array('connectionStrategy' => 'RoundRobin'), $callback);
$client->setConnections($connections);
-
- $resonse = $client->request('/_aliases');
- /* @var $resonse Response */
- $this->_checkResponse($resonse);
-
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
$this->_checkStrategy($client);
-
-
+
$this->assertLessThan(count($connections), $count);
}
-
+
public function testWithNoValidConnection()
{
$connections = array(
- new \Elastica\Connection(array('host' => '255.255.255.0', 'timeout' => 2)),
- new \Elastica\Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => 2)),
- new \Elastica\Connection(array('host' => '10.123.213.123', 'timeout' => 2)),
+ new Connection(array('host' => '255.255.255.0', 'timeout' => 2)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => 2)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => 2)),
);
$count = 0;
- $client = new Client(array('roundRobin' => true), function() use (&$count) {
+ $client = new Client(array('roundRobin' => true), function () use (&$count) {
++$count;
});
-
+
$client->setConnections($connections);
try {
$client->request('/_aliases');
$this->fail('Should throw exception as no connection valid');
- } catch (\Elastica\Exception\ConnectionException $e) {
+ } catch (ConnectionException $e) {
$this->assertEquals(count($connections), $count);
$this->_checkStrategy($client);
}
-
}
-
+
protected function _checkStrategy($client)
{
$strategy = $client->getConnectionStrategy();
- $condition = ($strategy instanceof RoundRobin);
-
- $this->assertTrue($condition);
+ $this->assertInstanceOf('Elastica\Connection\Strategy\RoundRobin', $strategy);
}
-
- protected function _checkResponse($resonse)
+
+ protected function _checkResponse($response)
{
- $this->assertTrue($resonse->isOk());
+ $this->assertTrue($response->isOk());
}
-
}
diff --git a/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php b/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
index bd22f82faa..fcccbc0be8 100644
--- a/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
+++ b/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
@@ -3,7 +3,9 @@
namespace Elastica\Test\Connection\Strategy;
use Elastica\Client;
+use Elastica\Connection;
use Elastica\Connection\Strategy\Simple;
+use Elastica\Exception\ConnectionException;
use Elastica\Test\Base;
/**
@@ -16,14 +18,14 @@ class SimpleTest extends Base
public function testConnection()
{
$client = new Client();
- $resonse = $client->request('/_aliases');
- /* @var $resonse \Elastica\Response */
-
- $this->_checkResponse($resonse);
-
+ $response = $client->request('/_aliases');
+ /* @var $response \Elastica\Response */
+
+ $this->_checkResponse($response);
+
$this->_checkStrategy($client);
}
-
+
/**
* @expectedException \Elastica\Exception\ConnectionException
*/
@@ -31,74 +33,69 @@ public function testFailConnection()
{
$config = array('host' => '255.255.255.0');
$client = new Client($config);
-
+
$this->_checkStrategy($client);
$client->request('/_aliases');
-
}
-
+
public function testWithOneFailConnection()
{
$connections = array(
- new \Elastica\Connection(array('host' => '255.255.255.0')),
- new \Elastica\Connection(array('host' => 'localhost')),
+ new Connection(array('host' => '255.255.255.0')),
+ new Connection(array('host' => 'localhost')),
);
-
+
$count = 0;
- $callback = function($connection, $exception, $client) use(&$count) {
+ $callback = function ($connection, $exception, $client) use (&$count) {
++$count;
};
-
+
$client = new Client(array(), $callback);
$client->setConnections($connections);
-
- $resonse = $client->request('/_aliases');
- /* @var $resonse Response */
- $this->_checkResponse($resonse);
-
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
$this->_checkStrategy($client);
-
-
+
$this->assertLessThan(count($connections), $count);
}
-
+
public function testWithNoValidConnection()
{
$connections = array(
- new \Elastica\Connection(array('host' => '255.255.255.0', 'timeout' => 2)),
- new \Elastica\Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => 2)),
- new \Elastica\Connection(array('host' => '10.123.213.123', 'timeout' => 2)),
+ new Connection(array('host' => '255.255.255.0', 'timeout' => 2)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => 2)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => 2)),
);
$count = 0;
- $client = new Client(array(), function() use (&$count) {
+ $client = new Client(array(), function () use (&$count) {
++$count;
});
-
+
$client->setConnections($connections);
try {
$client->request('/_aliases');
$this->fail('Should throw exception as no connection valid');
- } catch (\Elastica\Exception\ConnectionException $e) {
+ } catch (ConnectionException $e) {
$this->assertEquals(count($connections), $count);
}
-
}
-
+
protected function _checkStrategy($client)
{
$strategy = $client->getConnectionStrategy();
- $condition = ($strategy instanceof Simple);
-
- $this->assertTrue($condition);
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
}
-
- protected function _checkResponse($resonse)
+
+ protected function _checkResponse($response)
{
- $this->assertTrue($resonse->isOk());
+ $this->assertTrue($response->isOk());
}
}
diff --git a/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php b/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
index bab7fab8d4..5a7c03ad52 100644
--- a/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
+++ b/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
@@ -2,17 +2,9 @@
namespace Elastica\Test\Connection\Strategy;
-use Elastica\Connection\Strategy\CallbackStrategy;
-use Elastica\Connection\Strategy\Simple;
use Elastica\Connection\Strategy\StrategyFactory;
use Elastica\Test\Base;
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-
/**
* Description of StrategyFactoryTest
*
@@ -20,53 +12,48 @@
*/
class StrategyFactoryTest extends Base
{
- public function testCreateCallbackStrategy()
- {
- $callback = function ($connections)
- {
-
- };
-
- $strategy = StrategyFactory::create($callback);
-
- $condition = $strategy instanceof CallbackStrategy;
-
- $this->assertTrue($condition);
- }
-
- public function testCreateByName()
- {
- $strategyName = 'Simple';
-
- $strategy = StrategyFactory::create($strategyName);
-
- $this->assertTrue($strategy instanceof Simple);
- }
-
- public function testCreateByClass()
- {
- $strategy = new EmptyStrategy();
-
- $this->assertEquals($strategy, StrategyFactory::create($strategy));
- }
-
- public function testCreateByClassName()
- {
- $strategyName = '\\Elastica\Test\Connection\Strategy\\EmptyStrategy';
-
- $strategy = StrategyFactory::create($strategyName);
-
- $condition = $strategy instanceof $strategyName;
-
- $this->assertTrue($condition);
- }
- /**
- * @expectedException \InvalidArgumentException
- */
- public function testFailCreate()
- {
- $strategy = new \stdClass();
-
- StrategyFactory::create($strategy);
- }
+ public function testCreateCallbackStrategy()
+ {
+ $callback = function ($connections) {
+ };
+
+ $strategy = StrategyFactory::create($callback);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\CallbackStrategy', $strategy);
+ }
+
+ public function testCreateByName()
+ {
+ $strategyName = 'Simple';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+
+ public function testCreateByClass()
+ {
+ $strategy = new EmptyStrategy();
+
+ $this->assertEquals($strategy, StrategyFactory::create($strategy));
+ }
+
+ public function testCreateByClassName()
+ {
+ $strategyName = '\\Elastica\Test\Connection\Strategy\\EmptyStrategy';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf($strategyName, $strategy);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testFailCreate()
+ {
+ $strategy = new \stdClass();
+
+ StrategyFactory::create($strategy);
+ }
}
diff --git a/test/lib/Elastica/Test/DocumentTest.php b/test/lib/Elastica/Test/DocumentTest.php
index 27fc518476..e34f603ec5 100644
--- a/test/lib/Elastica/Test/DocumentTest.php
+++ b/test/lib/Elastica/Test/DocumentTest.php
@@ -4,17 +4,16 @@
use Elastica\Document;
use Elastica\Exception\InvalidException;
-use Elastica\Script;
use Elastica\Index;
-use Elastica\Type;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class DocumentTest extends BaseTest
{
public function testAddFile()
{
$fileName = '/dev/null';
- if(!file_exists($fileName)){
+ if (!file_exists($fileName)) {
$this->markTestSkipped("File {$fileName} does not exist.");
}
$doc = new Document();
diff --git a/test/lib/Elastica/Test/ExampleTest.php b/test/lib/Elastica/Test/ExampleTest.php
index 0331e38921..a01acd33bf 100644
--- a/test/lib/Elastica/Test/ExampleTest.php
+++ b/test/lib/Elastica/Test/ExampleTest.php
@@ -11,20 +11,19 @@
*/
class ExampleTest extends BaseTest
{
- public function testBasicGettingStarted() {
-
- $client = new \Elastica\Client();
- $index = $client->getIndex('ruflin');
- $type = $index->getType('users');
-
- $id = 2;
- $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin');
- $doc = new \Elastica\Document($id, $data);
-
- $type->addDocument($doc);
-
- }
-
+ public function testBasicGettingStarted()
+ {
+ $client = new Client();
+ $index = $client->getIndex('ruflin');
+ $type = $index->getType('users');
+
+ $id = 2;
+ $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin');
+ $doc = new Document($id, $data);
+
+ $type->addDocument($doc);
+ }
+
public function testExample()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
diff --git a/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php b/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
index 7e40cbc228..cc2ea67a3d 100644
--- a/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
+++ b/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
@@ -25,8 +25,8 @@ public function testPartialFailure()
$index->create(array(
'index' => array(
'number_of_shards' => 5,
- 'number_of_replicas' => 0
- )
+ 'number_of_replicas' => 0,
+ ),
), true);
$type = $index->getType('folks');
@@ -58,5 +58,4 @@ public function testPartialFailure()
$this->assertEquals(0, count($resultSet->getResults()));
}
}
-
}
diff --git a/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php b/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
index 050fdf0bc6..2f7eb2a11e 100644
--- a/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
+++ b/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
@@ -36,8 +36,8 @@ public function testBadType()
$type->setMapping(array(
'num' => array(
- 'type' => 'long'
- )
+ 'type' => 'long',
+ ),
));
try {
@@ -63,5 +63,4 @@ public function testWhatever()
$this->assertEquals(404, $ex->getElasticsearchException()->getCode());
}
}
-
}
diff --git a/test/lib/Elastica/Test/Facet/DateHistogramTest.php b/test/lib/Elastica/Test/Facet/DateHistogramTest.php
index 46dcdbf976..e65db9dd85 100644
--- a/test/lib/Elastica/Test/Facet/DateHistogramTest.php
+++ b/test/lib/Elastica/Test/Facet/DateHistogramTest.php
@@ -28,7 +28,7 @@ public function testTest()
$mapping = new Mapping($type, array(
'name' => array('type' => 'string', 'store' => 'no'),
- 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss')
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
));
$type->setMapping($mapping);
diff --git a/test/lib/Elastica/Test/Facet/FilterTest.php b/test/lib/Elastica/Test/Facet/FilterTest.php
index ca6f5ba300..c953a53c00 100644
--- a/test/lib/Elastica/Test/Facet/FilterTest.php
+++ b/test/lib/Elastica/Test/Facet/FilterTest.php
@@ -3,8 +3,8 @@
namespace Elastica\Test\Facet;
use Elastica\Document;
-use Elastica\Filter\Term;
use Elastica\Facet\Filter;
+use Elastica\Filter\Term;
use Elastica\Query;
use Elastica\Test\Base as BaseTest;
diff --git a/test/lib/Elastica/Test/Facet/GeoClusterTest.php b/test/lib/Elastica/Test/Facet/GeoClusterTest.php
index a82379f1b5..125c1db6be 100644
--- a/test/lib/Elastica/Test/Facet/GeoClusterTest.php
+++ b/test/lib/Elastica/Test/Facet/GeoClusterTest.php
@@ -2,13 +2,19 @@
namespace Elastica\Test\Facet;
+use Elastica\Document;
+use Elastica\Facet\GeoCluster;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
-class GeoClusterTest extends BaseTest{
- public function testQuery() {
+class GeoClusterTest extends BaseTest
+{
+ public function testQuery()
+ {
$client = $this->_getClient();
$nodes = $client->getCluster()->getNodes();
- if(!$nodes[0]->getInfo()->hasPlugin('geocluster-facet')){
+ if (!$nodes[0]->getInfo()->hasPlugin('geocluster-facet')) {
$this->markTestSkipped('geocluster-facet plugin not installed');
}
@@ -16,30 +22,29 @@ public function testQuery() {
$type = $index->getType('testQuery');
$geoField = 'location';
- $type->setMapping(new \Elastica\Type\Mapping($type, array(
- $geoField => array( 'type' => 'geo_point', 'lat_lon' => true )
+ $type->setMapping(new Mapping($type, array(
+ $geoField => array( 'type' => 'geo_point', 'lat_lon' => true ),
)));
- $doc = new \Elastica\Document(1, array('name' => 'item1', 'location' => array(20,20)));
+ $doc = new Document(1, array('name' => 'item1', 'location' => array(20, 20)));
$type->addDocument($doc);
- $doc = new \Elastica\Document(2, array('name' => 'item2', 'location' => array(20,20)));
+ $doc = new Document(2, array('name' => 'item2', 'location' => array(20, 20)));
$type->addDocument($doc);
- $doc = new \Elastica\Document(3, array('name' => 'item3', 'location' => array(20,20)));
+ $doc = new Document(3, array('name' => 'item3', 'location' => array(20, 20)));
$type->addDocument($doc);
$index->refresh();
- $facet = new \Elastica\Facet\GeoCluster('clusters');
+ $facet = new GeoCluster('clusters');
$facet
->setField($geoField)
->setFactor(1)
->setShowIds(false);
- $query = new \Elastica\Query();
+ $query = new Query();
$query->setFacets(array($facet));
-
$response = $type->search($query);
$facets = $response->getFacets();
diff --git a/test/lib/Elastica/Test/Facet/StatisticalTest.php b/test/lib/Elastica/Test/Facet/StatisticalTest.php
index 0b528a7930..55416cd803 100644
--- a/test/lib/Elastica/Test/Facet/StatisticalTest.php
+++ b/test/lib/Elastica/Test/Facet/StatisticalTest.php
@@ -56,7 +56,7 @@ public function testStatisticalWithSetFields()
$type->addDocument($doc);
$facet = new Statistical('stats');
- $facet->setFields(array('price','price2'));
+ $facet->setFields(array('price', 'price2'));
$query = new Query();
$query->addFacet($facet);
diff --git a/test/lib/Elastica/Test/Facet/TermsStatsTest.php b/test/lib/Elastica/Test/Facet/TermsStatsTest.php
index bea9b78d26..57bb26978e 100644
--- a/test/lib/Elastica/Test/Facet/TermsStatsTest.php
+++ b/test/lib/Elastica/Test/Facet/TermsStatsTest.php
@@ -13,93 +13,93 @@ class TermsStatsTest extends BaseTest
public function testOrder()
{
$client = $this->_getClient();
- $index = $client->getIndex( 'test' );
- $index->create( array( ), true );
- $type = $index->getType( 'helloworld' );
-
- $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) );
- $type->addDocument( $doc );
- $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) );
- $type->addDocument( $doc );
- $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) );
- $type->addDocument( $doc );
- $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) );
- $type->addDocument( $doc );
- $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) );
- $type->addDocument( $doc );
- $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) );
- $type->addDocument( $doc );
-
- $facet = new TermsStats( 'test' );
- $facet->setKeyField( 'name' );
- $facet->setValueField( 'paid' );
- $facet->setOrder( 'reverse_total' );
+ $index = $client->getIndex('test');
+ $index->create(array( ), true);
+ $type = $index->getType('helloworld');
+
+ $doc = new Document(1, array( 'name' => 'tom', 'paid' => 7 ));
+ $type->addDocument($doc);
+ $doc = new Document(2, array( 'name' => 'tom', 'paid' => 2 ));
+ $type->addDocument($doc);
+ $doc = new Document(3, array( 'name' => 'tom', 'paid' => 5 ));
+ $type->addDocument($doc);
+ $doc = new Document(4, array( 'name' => 'mike', 'paid' => 13 ));
+ $type->addDocument($doc);
+ $doc = new Document(5, array( 'name' => 'mike', 'paid' => 1 ));
+ $type->addDocument($doc);
+ $doc = new Document(6, array( 'name' => 'mike', 'paid' => 15 ));
+ $type->addDocument($doc);
+
+ $facet = new TermsStats('test');
+ $facet->setKeyField('name');
+ $facet->setValueField('paid');
+ $facet->setOrder('reverse_total');
$query = new Query();
- $query->addFacet( $facet );
- $query->setQuery( new MatchAll() );
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
$index->refresh();
- $response = $type->search( $query );
+ $response = $type->search($query);
$facets = $response->getFacets();
- $this->assertEquals(14, $facets[ 'test' ][ 'terms' ][0]['total'] );
- $this->assertEquals(29, $facets[ 'test' ][ 'terms' ][1]['total'] );
+ $this->assertEquals(14, $facets[ 'test' ][ 'terms' ][0]['total']);
+ $this->assertEquals(29, $facets[ 'test' ][ 'terms' ][1]['total']);
}
public function testQuery()
{
$client = $this->_getClient();
- $index = $client->getIndex( 'test' );
- $index->create( array( ), true );
- $type = $index->getType( 'helloworld' );
-
- $doc = new Document( 1, array( 'name' => 'tom', 'paid' => 7 ) );
- $type->addDocument( $doc );
- $doc = new Document( 2, array( 'name' => 'tom', 'paid' => 2 ) );
- $type->addDocument( $doc );
- $doc = new Document( 3, array( 'name' => 'tom', 'paid' => 5 ) );
- $type->addDocument( $doc );
- $doc = new Document( 4, array( 'name' => 'mike', 'paid' => 13 ) );
- $type->addDocument( $doc );
- $doc = new Document( 5, array( 'name' => 'mike', 'paid' => 1 ) );
- $type->addDocument( $doc );
- $doc = new Document( 6, array( 'name' => 'mike', 'paid' => 15 ) );
- $type->addDocument( $doc );
-
- $facet = new TermsStats( 'test' );
- $facet->setKeyField( 'name' );
- $facet->setValueField( 'paid' );
+ $index = $client->getIndex('test');
+ $index->create(array( ), true);
+ $type = $index->getType('helloworld');
+
+ $doc = new Document(1, array( 'name' => 'tom', 'paid' => 7 ));
+ $type->addDocument($doc);
+ $doc = new Document(2, array( 'name' => 'tom', 'paid' => 2 ));
+ $type->addDocument($doc);
+ $doc = new Document(3, array( 'name' => 'tom', 'paid' => 5 ));
+ $type->addDocument($doc);
+ $doc = new Document(4, array( 'name' => 'mike', 'paid' => 13 ));
+ $type->addDocument($doc);
+ $doc = new Document(5, array( 'name' => 'mike', 'paid' => 1 ));
+ $type->addDocument($doc);
+ $doc = new Document(6, array( 'name' => 'mike', 'paid' => 15 ));
+ $type->addDocument($doc);
+
+ $facet = new TermsStats('test');
+ $facet->setKeyField('name');
+ $facet->setValueField('paid');
$query = new Query();
- $query->addFacet( $facet );
- $query->setQuery( new MatchAll() );
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
$index->refresh();
- $response = $type->search( $query );
+ $response = $type->search($query);
$facets = $response->getFacets();
- $this->assertEquals( 2, count( $facets[ 'test' ][ 'terms' ] ) );
+ $this->assertEquals(2, count($facets[ 'test' ][ 'terms' ]));
foreach ($facets[ 'test' ][ 'terms' ] as $facet) {
if ($facet[ 'term' ] === 'tom') {
- $this->assertEquals( 14, $facet[ 'total' ] );
+ $this->assertEquals(14, $facet[ 'total' ]);
}
if ($facet[ 'term' ] === 'mike') {
- $this->assertEquals( 29, $facet[ 'total' ] );
+ $this->assertEquals(29, $facet[ 'total' ]);
}
}
}
- public function testSetSize()
- {
- $facet = new TermsStats( 'test' );
- $facet->setSize(100);
+ public function testSetSize()
+ {
+ $facet = new TermsStats('test');
+ $facet->setSize(100);
- $data = $facet->toArray();
+ $data = $facet->toArray();
- $this->assertArrayHasKey('size', $data['terms_stats']);
- $this->assertEquals(100, $data['terms_stats']['size']);
- }
+ $this->assertArrayHasKey('size', $data['terms_stats']);
+ $this->assertEquals(100, $data['terms_stats']['size']);
+ }
}
diff --git a/test/lib/Elastica/Test/Filter/BoolAndTest.php b/test/lib/Elastica/Test/Filter/BoolAndTest.php
index 672c6c6752..3258eaaf73 100644
--- a/test/lib/Elastica/Test/Filter/BoolAndTest.php
+++ b/test/lib/Elastica/Test/Filter/BoolAndTest.php
@@ -23,8 +23,8 @@ public function testToArray()
$expectedArray = array(
'and' => array(
$idsFilter->toArray(),
- $idsFilter->toArray()
- )
+ $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $and->toArray());
diff --git a/test/lib/Elastica/Test/Filter/BoolNotTest.php b/test/lib/Elastica/Test/Filter/BoolNotTest.php
index adcebf4547..57d73f3300 100644
--- a/test/lib/Elastica/Test/Filter/BoolNotTest.php
+++ b/test/lib/Elastica/Test/Filter/BoolNotTest.php
@@ -2,8 +2,8 @@
namespace Elastica\Test\Filter;
-use Elastica\Filter\Ids;
use Elastica\Filter\BoolNot;
+use Elastica\Filter\Ids;
use Elastica\Test\Base as BaseTest;
class BoolNotTest extends BaseTest
@@ -16,8 +16,8 @@ public function testToArray()
$expectedArray = array(
'not' => array(
- 'filter' => $idsFilter->toArray()
- )
+ 'filter' => $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/test/lib/Elastica/Test/Filter/BoolOrTest.php b/test/lib/Elastica/Test/Filter/BoolOrTest.php
index 25234a8c70..e4db03f042 100644
--- a/test/lib/Elastica/Test/Filter/BoolOrTest.php
+++ b/test/lib/Elastica/Test/Filter/BoolOrTest.php
@@ -33,8 +33,8 @@ public function testToArray()
$expectedArray = array(
'or' => array(
$filter1->toArray(),
- $filter2->toArray()
- )
+ $filter2->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $orFilter->toArray());
diff --git a/test/lib/Elastica/Test/Filter/BoolTest.php b/test/lib/Elastica/Test/Filter/BoolTest.php
index 8c1643a092..4b61bc097e 100644
--- a/test/lib/Elastica/Test/Filter/BoolTest.php
+++ b/test/lib/Elastica/Test/Filter/BoolTest.php
@@ -2,11 +2,12 @@
namespace Elastica\Test\Filter;
-use Elastica\Filter\Terms;
-use \Elastica\Query;
+use Elastica\Document;
use Elastica\Filter\Bool;
-use Elastica\Filter\Term;
use Elastica\Filter\Ids;
+use Elastica\Filter\Term;
+use Elastica\Filter\Terms;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class BoolTest extends BaseTest
@@ -42,15 +43,15 @@ public function getTestToArrayData()
'should' => array(
array(
$idsFilter1->toArray(),
- $idsFilter2->toArray()
- )
- )
- )
+ $idsFilter2->toArray(),
+ ),
+ ),
+ ),
),
- $idsFilter3->toArray()
- )
- )
- )
+ $idsFilter3->toArray(),
+ ),
+ ),
+ ),
);
$out[] = array($mainBool, $expectedArray);
@@ -65,14 +66,14 @@ public function getTestToArrayData()
$expected = array(
'bool' => array(
'must' => array(
- $terms->toArray()
+ $terms->toArray(),
),
'must_not' => array(
- $termsNot->toArray()
+ $termsNot->toArray(),
),
'_cache' => true,
- '_cache_key' => 'my-cache-key'
- )
+ '_cache_key' => 'my-cache-key',
+ ),
);
$out[] = array($bool, $expected);
@@ -81,7 +82,7 @@ public function getTestToArrayData()
/**
* @dataProvider getTestToArrayData()
- * @param Bool $bool
+ * @param Bool $bool
* @param array $expectedArray
*/
public function testToArray(Bool $bool, $expectedArray)
@@ -95,11 +96,11 @@ public function testBoolFilter()
$type = $index->getType('book');
//index some test data
- $type->addDocument(new \Elastica\Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')));
- $type->addDocument(new \Elastica\Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')));
- $type->addDocument(new \Elastica\Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')));
- $type->addDocument(new \Elastica\Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')));
- $type->addDocument(new \Elastica\Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')));
+ $type->addDocument(new Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')));
+ $type->addDocument(new Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')));
+ $type->addDocument(new Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')));
+ $type->addDocument(new Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')));
+ $type->addDocument(new Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')));
$index->refresh();
@@ -138,10 +139,10 @@ public function testBoolFilter()
//count compare the id's
$ids = array();
/** @var \Elastica\Result $result **/
- foreach($results as $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, array("2", "4"), 'Bool filter with child Bool filters: result ID check');
$index->delete();
}
diff --git a/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php b/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
index 84dce8afa7..ac011c2e69 100644
--- a/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
+++ b/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
@@ -130,7 +130,7 @@ public function invalidLocationDataProvider()
),
array(
false,
- )
+ ),
);
}
@@ -149,8 +149,8 @@ public function constructDataProvider()
'from' => '10km',
'to' => '20km',
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -168,8 +168,8 @@ public function constructDataProvider()
'from' => '10km',
'include_lower' => true,
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -189,8 +189,8 @@ public function constructDataProvider()
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -210,9 +210,9 @@ public function constructDataProvider()
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
- )
+ ),
+ ),
+ ),
);
}
}
diff --git a/test/lib/Elastica/Test/Filter/GeoDistanceTest.php b/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
index ac2b1123e7..d8ba24645d 100644
--- a/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
+++ b/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
@@ -67,7 +67,7 @@ public function testConstructLatlon()
$key = 'location';
$location = array(
'lat' => 48.86,
- 'lon' => 2.35
+ 'lon' => 2.35,
);
$distance = '10km';
@@ -76,8 +76,8 @@ public function testConstructLatlon()
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
@@ -96,8 +96,8 @@ public function testConstructGeohash()
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
diff --git a/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php b/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
index 21afec1a1f..d817fa4a9e 100644
--- a/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
+++ b/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
@@ -5,8 +5,8 @@
use Elastica\Filter\AbstractGeoShape;
use Elastica\Filter\GeoShapePreIndexed;
-use Elastica\Query\MatchAll;
use Elastica\Query\Filtered;
+use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
class GeoShapePreIndexedTest extends BaseTest
@@ -21,16 +21,16 @@ public function testGeoProvided()
// create mapping
$mapping = new \Elastica\Type\Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$type->setMapping($mapping);
// create other type mapping
$otherMapping = new \Elastica\Type\Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$otherType->setMapping($otherMapping);
@@ -40,9 +40,9 @@ public function testGeoProvided()
"type" => "envelope",
"coordinates" => array(
array(0.0, 50.0),
- array(50.0, 0.0)
- )
- )
+ array(50.0, 0.0),
+ ),
+ ),
)));
// add other type docs
@@ -51,9 +51,9 @@ public function testGeoProvided()
"type" => "envelope",
"coordinates" => array(
array(25.0, 75.0),
- array(75.0, 25.0)
- )
- )
+ array(75.0, 25.0),
+ ),
+ ),
)));
$index->optimize();
@@ -71,11 +71,11 @@ public function testGeoProvided()
'id' => '1',
'type' => 'type',
'index' => 'elastica_'.$indexName,
- 'path' => 'location'
+ 'path' => 'location',
),
- 'relation' => $gsp->getRelation()
- )
- )
+ 'relation' => $gsp->getRelation(),
+ ),
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
@@ -87,4 +87,4 @@ public function testGeoProvided()
$index->delete();
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php b/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
index 146150a30a..baae3260d7 100644
--- a/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
+++ b/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
@@ -19,8 +19,8 @@ public function testConstructEnvelope()
// create mapping
$mapping = new \Elastica\Type\Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$type->setMapping($mapping);
@@ -30,9 +30,9 @@ public function testConstructEnvelope()
"type" => "envelope",
"coordinates" => array(
array(-50.0, 50.0),
- array(50.0, -50.0)
- )
- )
+ array(50.0, -50.0),
+ ),
+ ),
)));
$index->optimize();
@@ -40,7 +40,7 @@ public function testConstructEnvelope()
$envelope = array(
array(25.0, 75.0),
- array(75.0, 25.0)
+ array(75.0, 25.0),
);
$gsp = new GeoShapeProvided('location', $envelope);
@@ -49,11 +49,11 @@ public function testConstructEnvelope()
'location' => array(
'shape' => array(
'type' => GeoShapeProvided::TYPE_ENVELOPE,
- 'coordinates' => $envelope
+ 'coordinates' => $envelope,
),
- 'relation' => AbstractGeoShape::RELATION_INTERSECT
+ 'relation' => AbstractGeoShape::RELATION_INTERSECT,
),
- )
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
@@ -76,13 +76,13 @@ public function testConstructPolygon()
'location' => array(
'shape' => array(
'type' => GeoShapeProvided::TYPE_POLYGON,
- 'coordinates' => $polygon
+ 'coordinates' => $polygon,
),
- 'relation' => $gsp->getRelation()
+ 'relation' => $gsp->getRelation(),
),
- )
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/Filter/GeohashCellTest.php b/test/lib/Elastica/Test/Filter/GeohashCellTest.php
index 767a6c4cec..2f637a81a8 100644
--- a/test/lib/Elastica/Test/Filter/GeohashCellTest.php
+++ b/test/lib/Elastica/Test/Filter/GeohashCellTest.php
@@ -2,8 +2,8 @@
namespace Elastica\Test\Filter;
-use Elastica\Test\Base as BaseTest;
use Elastica\Filter\GeohashCell;
+use Elastica\Test\Base as BaseTest;
class GeohashCellTest extends BaseTest
{
@@ -14,11 +14,11 @@ public function testToArray()
'geohash_cell' => array(
'pin' => array(
'lat' => 37.789018,
- 'lon' => -122.391506
+ 'lon' => -122.391506,
),
'precision' => '50m',
- 'neighbors' => false
- )
+ 'neighbors' => false,
+ ),
);
$this->assertEquals($expected, $filter->toArray());
}
@@ -31,8 +31,8 @@ public function testFilter()
'pin' => array(
'type' => 'geo_point',
'geohash' => true,
- 'geohash_prefix' => true
- )
+ 'geohash_prefix' => true,
+ ),
));
$type->setMapping($mapping);
diff --git a/test/lib/Elastica/Test/Filter/HasChildTest.php b/test/lib/Elastica/Test/Filter/HasChildTest.php
index dfa3f999d5..bf89939192 100644
--- a/test/lib/Elastica/Test/Filter/HasChildTest.php
+++ b/test/lib/Elastica/Test/Filter/HasChildTest.php
@@ -20,8 +20,8 @@ public function testToArray()
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
@@ -51,7 +51,7 @@ public function testSetType()
public function testSetMinimumChildrenCount()
{
- $query = new MatchAll;
+ $query = new MatchAll();
$filter = new HasChild($query, 'test');
$filter->setMinimumChildrenCount(2);
@@ -63,7 +63,7 @@ public function testSetMinimumChildrenCount()
public function testSetMaximumChildrenCount()
{
- $query = new MatchAll;
+ $query = new MatchAll();
$filter = new HasChild($query, 'test');
$filter->setMaximumChildrenCount(10);
@@ -84,12 +84,11 @@ public function testFilterInsideHasChild()
$expectedArray = array(
'has_child' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
public function testFilterInsideHasChildSearch()
@@ -131,24 +130,24 @@ public function testQueryInsideHasChildSearch()
$this->assertEquals($expected, $result);
}
-
+
public function testTypeInsideHasChildSearch()
{
$index = $this->prepareSearchData();
-
+
$f = new \Elastica\Query\Match();
$f->setField('alt.name', 'testname');
$filter = new HasChild($f, 'child');
-
+
$searchQuery = new \Elastica\Query();
$searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
-
+
$this->assertEquals(1, $searchResults->count());
-
+
$result = $searchResults->current()->getData();
$expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com');
-
+
$this->assertEquals($expected, $result);
}
@@ -159,7 +158,7 @@ private function prepareSearchData()
$index->create(array(), true);
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
$childMapping = new \Elastica\Type\Mapping($childType);
$childMapping->setParent('parent');
@@ -168,7 +167,7 @@ private function prepareSearchData()
$altType = $index->getType('alt');
$altDoc = new Document('alt1', array('name' => 'altname'));
$altType->addDocument($altDoc);
-
+
$parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'));
$parentType->addDocument($parent1);
$parent2 = new Document('parent2', array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com'));
@@ -185,6 +184,7 @@ private function prepareSearchData()
$childType->addDocument($child3);
$index->refresh();
+
return $index;
}
}
diff --git a/test/lib/Elastica/Test/Filter/HasParentTest.php b/test/lib/Elastica/Test/Filter/HasParentTest.php
index b6bb6836b9..7b4fbe52f3 100644
--- a/test/lib/Elastica/Test/Filter/HasParentTest.php
+++ b/test/lib/Elastica/Test/Filter/HasParentTest.php
@@ -20,8 +20,8 @@ public function testToArray()
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
@@ -60,12 +60,11 @@ public function testFilterInsideHasParent()
$expectedArray = array(
'has_parent' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
public function testFilterInsideHasParentSearch()
@@ -134,6 +133,7 @@ private function prepareSearchData()
$childType->addDocument($child2);
$index->refresh();
+
return $index;
}
}
diff --git a/test/lib/Elastica/Test/Filter/IdsTest.php b/test/lib/Elastica/Test/Filter/IdsTest.php
index b24f0646a3..b41a174465 100644
--- a/test/lib/Elastica/Test/Filter/IdsTest.php
+++ b/test/lib/Elastica/Test/Filter/IdsTest.php
@@ -192,7 +192,7 @@ public function testSetTypeArraySearchSingle()
public function testFilterTypeAndTypeCollision()
{
// This test ensures that Elastica\Type and Elastica\Filter\Type
- // do not collide when used together, which at one point
+ // do not collide when used together, which at one point
// happened because of a use statement in Elastica\Filter\Ids
// Test goal is to make sure a Fatal Error is not triggered
$filterType = new Type();
diff --git a/test/lib/Elastica/Test/Filter/IndicesTest.php b/test/lib/Elastica/Test/Filter/IndicesTest.php
index 8f41260eaa..4cb99fe0bb 100644
--- a/test/lib/Elastica/Test/Filter/IndicesTest.php
+++ b/test/lib/Elastica/Test/Filter/IndicesTest.php
@@ -54,12 +54,12 @@ public function testToArray()
"indices" => array(
"indices" => array("index1", "index2"),
"filter" => array(
- "term" => array("tag" => "wow")
+ "term" => array("tag" => "wow"),
),
"no_match_filter" => array(
- "term" => array("tag" => "such filter")
- )
- )
+ "term" => array("tag" => "such filter"),
+ ),
+ ),
);
$filter = new Indices(new Term(array("tag" => "wow")), array("index1", "index2"));
$filter->setNoMatchFilter(new Term(array("tag" => "such filter")));
diff --git a/test/lib/Elastica/Test/Filter/MultiTest.php b/test/lib/Elastica/Test/Filter/MultiTest.php
index f6513338f8..15decb1482 100644
--- a/test/lib/Elastica/Test/Filter/MultiTest.php
+++ b/test/lib/Elastica/Test/Filter/MultiTest.php
@@ -23,7 +23,7 @@ public function testAddFilter()
$stub->addFilter($filter);
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
@@ -37,7 +37,7 @@ public function testSetFilters()
$stub->setFilters(array($filter));
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
@@ -52,8 +52,8 @@ public function testToArray()
$expected = array(
$stub->getBaseName() => array(
- $filter->toArray()
- )
+ $filter->toArray(),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
@@ -72,9 +72,9 @@ public function testToArrayWithParam()
$stub->getBaseName() => array(
'_cache' => true,
'filters' => array(
- $filter->toArray()
- )
- )
+ $filter->toArray(),
+ ),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
diff --git a/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php b/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
index 12dbb5985e..498e435213 100644
--- a/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
+++ b/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
@@ -6,8 +6,8 @@
use Elastica\Filter\Nested;
use Elastica\Filter\Terms;
use Elastica\Search;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class NestedFilterWithSetFilterTest extends BaseTest
{
@@ -26,8 +26,8 @@ public function setUp()
'hobbies' => array(
'type' => 'nested',
'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
)
);
$type->setMapping($mapping);
@@ -39,8 +39,8 @@ public function setUp()
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
'hobbies' => array(
- array('hobby' => 'opensource')
- )
+ array('hobby' => 'opensource'),
+ ),
)
);
$docs[] = new Document(2,
@@ -50,7 +50,7 @@ public function setUp()
'hobbies' => array(
array('hobby' => 'opensource'),
array('hobby' => 'guitar'),
- )
+ ),
)
);
$response = $type->addDocuments($docs);
@@ -79,9 +79,9 @@ public function testToArray()
'nested' => array(
'path' => 'hobbies',
'filter' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
$this->assertEquals($expectedArray, $f->toArray());
diff --git a/test/lib/Elastica/Test/Filter/NestedTest.php b/test/lib/Elastica/Test/Filter/NestedTest.php
index 176810185f..6ecb10fc2c 100644
--- a/test/lib/Elastica/Test/Filter/NestedTest.php
+++ b/test/lib/Elastica/Test/Filter/NestedTest.php
@@ -6,8 +6,8 @@
use Elastica\Filter\Nested;
use Elastica\Query\Terms;
use Elastica\Search;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class NestedTest extends BaseTest
{
@@ -26,8 +26,8 @@ public function setUp()
'hobbies' => array(
'type' => 'nested',
'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
)
);
$type->setMapping($mapping);
@@ -39,8 +39,8 @@ public function setUp()
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
'hobbies' => array(
- array('hobby' => 'opensource')
- )
+ array('hobby' => 'opensource'),
+ ),
)
);
$docs[] = new Document(2,
@@ -50,7 +50,7 @@ public function setUp()
'hobbies' => array(
array('hobby' => 'opensource'),
array('hobby' => 'guitar'),
- )
+ ),
)
);
$response = $type->addDocuments($docs);
@@ -79,9 +79,9 @@ public function testToArray()
'nested' => array(
'path' => 'hobbies',
'query' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
$this->assertEquals($expectedArray, $f->toArray());
diff --git a/test/lib/Elastica/Test/Filter/NumericRangeTest.php b/test/lib/Elastica/Test/Filter/NumericRangeTest.php
index 6cc2de065b..aa287a48a7 100644
--- a/test/lib/Elastica/Test/Filter/NumericRangeTest.php
+++ b/test/lib/Elastica/Test/Filter/NumericRangeTest.php
@@ -23,8 +23,8 @@ public function testToArray()
$expectedArray = array(
'numeric_range' => array(
- 'name' => $fromTo
- )
+ 'name' => $fromTo,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/test/lib/Elastica/Test/Filter/PrefixTest.php b/test/lib/Elastica/Test/Filter/PrefixTest.php
index 16362140a2..355309b7a4 100644
--- a/test/lib/Elastica/Test/Filter/PrefixTest.php
+++ b/test/lib/Elastica/Test/Filter/PrefixTest.php
@@ -4,8 +4,8 @@
use Elastica\Document;
use Elastica\Filter\Prefix;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class PrefixTest extends BaseTest
{
@@ -18,8 +18,8 @@ public function testToArray()
$expectedArray = array(
'prefix' => array(
- $field => $prefix
- )
+ $field => $prefix,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
@@ -97,10 +97,10 @@ public function testDifferentPrefixesLowercase()
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
diff --git a/test/lib/Elastica/Test/Filter/QueryTest.php b/test/lib/Elastica/Test/Filter/QueryTest.php
index 0a3310986d..28d334a839 100644
--- a/test/lib/Elastica/Test/Filter/QueryTest.php
+++ b/test/lib/Elastica/Test/Filter/QueryTest.php
@@ -2,8 +2,8 @@
namespace Elastica\Test\Filter;
-use Elastica\Query\QueryString;
use Elastica\Filter\Query;
+use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
class QueryTest extends BaseTest
@@ -17,8 +17,8 @@ public function testSimple()
'query' => array(
'query_string' => array(
'query' => 'foo bar',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expected, $filter->toArray());
@@ -37,8 +37,8 @@ public function testExtended()
'query' => 'foo bar',
),
),
- '_cache' => true
- )
+ '_cache' => true,
+ ),
);
$this->assertEquals($expected, $filter->toArray());
diff --git a/test/lib/Elastica/Test/Filter/RegexpTest.php b/test/lib/Elastica/Test/Filter/RegexpTest.php
index e06064dd12..b278fdac68 100644
--- a/test/lib/Elastica/Test/Filter/RegexpTest.php
+++ b/test/lib/Elastica/Test/Filter/RegexpTest.php
@@ -4,8 +4,8 @@
use Elastica\Document;
use Elastica\Filter\Regexp;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class RegexpTest extends BaseTest
{
@@ -18,8 +18,8 @@ public function testToArray()
$expectedArray = array(
'regexp' => array(
- $field => $regexp
- )
+ $field => $regexp,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
@@ -85,10 +85,10 @@ public function testDifferentRegexpLowercase()
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
diff --git a/test/lib/Elastica/Test/Filter/ScriptTest.php b/test/lib/Elastica/Test/Filter/ScriptTest.php
index 65ea628e9b..109dadc129 100644
--- a/test/lib/Elastica/Test/Filter/ScriptTest.php
+++ b/test/lib/Elastica/Test/Filter/ScriptTest.php
@@ -2,8 +2,8 @@
namespace Elastica\Test\Filter;
-use Elastica\Script;
use Elastica\Filter\Script as ScriptFilter;
+use Elastica\Script;
use Elastica\Test\Base as BaseTest;
class ScriptTest extends BaseTest
@@ -20,7 +20,7 @@ public function testToArray()
$expected = array(
'script' => array(
'script' => $string,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
@@ -45,7 +45,7 @@ public function testSetScript()
'script' => $string,
'params' => $params,
'lang' => $lang,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
diff --git a/test/lib/Elastica/Test/Filter/TermsTest.php b/test/lib/Elastica/Test/Filter/TermsTest.php
index 77f65584c1..70d7e7aeb7 100644
--- a/test/lib/Elastica/Test/Filter/TermsTest.php
+++ b/test/lib/Elastica/Test/Filter/TermsTest.php
@@ -26,29 +26,29 @@ public function testLookup()
//use the terms lookup feature to query for some data
$termsFilter = new Terms();
- $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', NULL);
+ $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', null);
$query = new \Elastica\Query();
$query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with null index');
-
+
$termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', $index);
$query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with index as object');
-
+
//Query with index given as string
$termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', $index->getName());
$query->setPostFilter($termsFilter);
$results = $index->search($query);
$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, 'cache' => false));
$query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with options array');
-
+
$index->delete();
}
diff --git a/test/lib/Elastica/Test/Filter/TypeTest.php b/test/lib/Elastica/Test/Filter/TypeTest.php
index fcada826a8..0f202bcf98 100644
--- a/test/lib/Elastica/Test/Filter/TypeTest.php
+++ b/test/lib/Elastica/Test/Filter/TypeTest.php
@@ -19,7 +19,7 @@ public function testToArray()
$typeFilter = new Type('type_name');
$expectedArray = array(
- 'type' => array('value' => 'type_name')
+ 'type' => array('value' => 'type_name'),
);
$this->assertEquals($expectedArray, $typeFilter->toArray());
diff --git a/test/lib/Elastica/Test/Index/SettingsTest.php b/test/lib/Elastica/Test/Index/SettingsTest.php
index eb710a10d2..10d3ede778 100644
--- a/test/lib/Elastica/Test/Index/SettingsTest.php
+++ b/test/lib/Elastica/Test/Index/SettingsTest.php
@@ -11,7 +11,7 @@
class SettingsTest extends BaseTest
{
- public function testGet()
+ public function testGet()
{
$indexName = 'elasticatest';
@@ -184,12 +184,11 @@ public function testSetMergePolicyType()
public function testSetReadOnly()
{
- $index = $this->_createIndex('test' . rand());;
+ $index = $this->_createIndex('test'.rand());
//wait for the shards to be allocated
$this->_waitForAllocation($index);
$index->getSettings()->setReadOnly(false);
-
// Add document to normal index
$doc1 = new Document(null, array('hello' => 'world'));
$doc2 = new Document(null, array('hello' => 'world'));
@@ -224,10 +223,9 @@ public function testSetReadOnly()
$index->delete();
}
-
public function testGetSetBlocksRead()
{
- $index = $this->_createIndex('elastica-test' . '123');
+ $index = $this->_createIndex('elastica-test'.'123');
$index->refresh();
$settings = $index->getSettings();
@@ -247,7 +245,7 @@ public function testGetSetBlocksRead()
public function testGetSetBlocksWrite()
{
- $index = $this->_createIndex('elastica-test' . '432');
+ $index = $this->_createIndex('elastica-test'.'432');
$index->refresh();
$settings = $index->getSettings();
@@ -267,7 +265,7 @@ public function testGetSetBlocksWrite()
public function testGetSetBlocksMetadata()
{
- $index = $this->_createIndex('elastica-test' . '534');
+ $index = $this->_createIndex('elastica-test'.'534');
$index->refresh();
$settings = $index->getSettings();
diff --git a/test/lib/Elastica/Test/IndexTest.php b/test/lib/Elastica/Test/IndexTest.php
index 8601ecb97f..728d39c6db 100644
--- a/test/lib/Elastica/Test/IndexTest.php
+++ b/test/lib/Elastica/Test/IndexTest.php
@@ -6,13 +6,13 @@
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Index;
+use Elastica\Query\HasChild;
use Elastica\Query\QueryString;
use Elastica\Query\Term;
use Elastica\Status;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Query\HasChild;
-use Elastica\Test\Base as BaseTest;
class IndexTest extends BaseTest
{
@@ -41,8 +41,8 @@ public function testMapping()
$result = $type->search('hanswurst');
}
- public function testGetMappingAlias() {
-
+ public function testGetMappingAlias()
+ {
$indexName = 'test-mapping';
$aliasName = 'test-mapping-alias';
@@ -111,9 +111,9 @@ public function testParent()
public function testAddPdfFile()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'test');
@@ -122,7 +122,7 @@ public function testAddPdfFile()
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFile('file', BASE_PATH . '/data/test.pdf', 'application/pdf');
+ $doc1->addFile('file', BASE_PATH.'/data/test.pdf', 'application/pdf');
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
@@ -150,9 +150,9 @@ public function testAddPdfFile()
public function testAddPdfFileContent()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment', 'store' => 'no'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'test');
@@ -161,7 +161,7 @@ public function testAddPdfFileContent()
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFileContent('file', file_get_contents(BASE_PATH . '/data/test.pdf'));
+ $doc1->addFileContent('file', file_get_contents(BASE_PATH.'/data/test.pdf'));
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
@@ -189,9 +189,9 @@ public function testAddPdfFileContent()
public function testAddWordxFile()
{
$this->_checkAttachmentsPlugin();
- $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => 'no'),);
+ $indexMapping = array('file' => array('type' => 'attachment'), 'text' => array('type' => 'string', 'store' => 'no'));
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'content');
@@ -200,7 +200,7 @@ public function testAddWordxFile()
$type->setMapping($indexMapping);
$doc1 = new Document(1);
- $doc1->addFile('file', BASE_PATH . '/data/test.docx');
+ $doc1->addFile('file', BASE_PATH.'/data/test.docx');
$doc1->set('text', 'basel world');
$type->addDocument($doc1);
@@ -226,7 +226,7 @@ public function testExcludeFileSource()
$indexMapping = array('file' => array('type' => 'attachment', 'store' => 'yes'), 'text' => array('type' => 'string', 'store' => 'yes'),
'title' => array('type' => 'string', 'store' => 'yes'),);
- $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0),);
+ $indexParams = array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0));
$index = $this->_createIndex();
$type = new Type($index, 'content');
@@ -244,7 +244,7 @@ public function testExcludeFileSource()
$title = 'No Title';
$doc1 = new Document($docId);
- $doc1->addFile('file', BASE_PATH . '/data/test.docx');
+ $doc1->addFile('file', BASE_PATH.'/data/test.docx');
$doc1->set('text', $text);
$doc1->set('title', $title);
$type->addDocument($doc1);
@@ -309,7 +309,6 @@ public function testCount()
$type->addDocument($doc1);
$type->addDocument($doc2);
-
$index->refresh();
$this->assertEquals(2, $index->count());
@@ -368,7 +367,6 @@ public function testAddAliasTwoIndices()
$status = new Status($client);
-
$this->assertTrue($status->indexExists($indexName1));
$this->assertTrue($status->indexExists($indexName2));
@@ -594,10 +592,10 @@ public function testCreateSearch()
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
- 'size' => 5
+ 'size' => 5,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test'), $search->getIndices());
@@ -682,7 +680,7 @@ public function testAnalyze()
'end_offset' => 3,
'type' => '',
'position' => 1,
- )
+ ),
);
$this->assertEquals($tokens, $returnedTokens);
diff --git a/test/lib/Elastica/Test/LogTest.php b/test/lib/Elastica/Test/LogTest.php
index 188be933ee..90d503870c 100644
--- a/test/lib/Elastica/Test/LogTest.php
+++ b/test/lib/Elastica/Test/LogTest.php
@@ -70,7 +70,7 @@ public function testGetLastMessage2()
// Set log path temp path as otherwise test fails with output
$errorLog = ini_get('error_log');
- ini_set('error_log', sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'php.log');
+ ini_set('error_log', sys_get_temp_dir().DIRECTORY_SEPARATOR.'php.log');
$this->_context['error_message'] = $this->_message;
$message = json_encode($this->_context);
diff --git a/test/lib/Elastica/Test/Node/InfoTest.php b/test/lib/Elastica/Test/Node/InfoTest.php
index 10886b2d1d..fd75aecbb2 100644
--- a/test/lib/Elastica/Test/Node/InfoTest.php
+++ b/test/lib/Elastica/Test/Node/InfoTest.php
@@ -22,7 +22,7 @@ public function testGet()
// Load os infos
$info = new NodeInfo($node, array('os'));
- $this->assertTrue(!is_null($info->get('os', 'mem', 'total_in_bytes')));
+ $this->assertNotNull($info->get('os', 'mem', 'total_in_bytes'));
$this->assertInternalType('array', $info->get('os', 'mem'));
$this->assertNull($info->get('test', 'notest', 'notexist'));
}
@@ -35,7 +35,7 @@ public function testHasPlugin()
$info = $node->getInfo();
$pluginName = 'mapper-attachments';
-
+
$this->assertTrue($info->hasPlugin($pluginName));
$this->assertFalse($info->hasPlugin('foo'));
}
diff --git a/test/lib/Elastica/Test/ParamTest.php b/test/lib/Elastica/Test/ParamTest.php
index fab7760067..24e9e3e889 100644
--- a/test/lib/Elastica/Test/ParamTest.php
+++ b/test/lib/Elastica/Test/ParamTest.php
@@ -3,8 +3,8 @@
namespace Elastica\Test;
use Elastica\Param;
-use Elastica\Util;
use Elastica\Test\Base as BaseTest;
+use Elastica\Util;
class ParamTest extends BaseTest
{
diff --git a/test/lib/Elastica/Test/PercolatorTest.php b/test/lib/Elastica/Test/PercolatorTest.php
index 37e9f0e270..677929df73 100644
--- a/test/lib/Elastica/Test/PercolatorTest.php
+++ b/test/lib/Elastica/Test/PercolatorTest.php
@@ -2,12 +2,11 @@
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Index;
use Elastica\Percolator;
-use Elastica\Query\Term;
use Elastica\Query;
+use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
@@ -31,7 +30,7 @@ public function testConstruct()
'_index' => $index->getName(),
'_id' => $percolatorName,
'_version' => 1,
- 'created' => 1
+ 'created' => 1,
);
$this->assertEquals($expectedArray, $data);
@@ -143,7 +142,6 @@ public function testRegisterAndUnregisterPercolator()
$matches = $percolator->matchDoc($doc, new Term(array('color' => 'green')));
$this->assertCount(0, $matches, 'A registered query matched, although nothing should match at all.');
-
// unregister percolator query
$response = $percolator->unregisterQuery('kuku');
@@ -170,7 +168,7 @@ protected function _getDefaultPercolator($percolatorName = 'existingDoc')
return $percolator;
}
- protected function _addDefaultDocuments($index, $type='testing')
+ protected function _addDefaultDocuments($index, $type = 'testing')
{
$type = $index->getType('testing');
$doc1 = new Document(1, array('name' => 'foobar'));
@@ -178,6 +176,7 @@ protected function _addDefaultDocuments($index, $type='testing')
$type->addDocument($doc1);
$type->addDocument($doc2);
$index->refresh();
+
return $type;
}
@@ -258,7 +257,7 @@ public function testPercolateWithAdditionalRequestBodyOptions()
$this->assertCount(1, $matches);
$this->assertEquals('percotest1', $matches[0]['_id']);
- $this->assertTrue(array_key_exists('_score', $matches[0]));
+ $this->assertArrayHasKey('_score', $matches[0]);
}
public function testPercolateExistingDocWithAdditionalRequestBodyOptions()
@@ -282,7 +281,7 @@ public function testPercolateExistingDocWithAdditionalRequestBodyOptions()
$this->assertCount(1, $matches);
$this->assertEquals('existingDoc1', $matches[0]['_id']);
- $this->assertTrue(array_key_exists('_score', $matches[0]));
+ $this->assertArrayHasKey('_score', $matches[0]);
$index->delete();
}
diff --git a/test/lib/Elastica/Test/Query/BoolTest.php b/test/lib/Elastica/Test/Query/BoolTest.php
index d3bd90cd23..706b2c94c9 100644
--- a/test/lib/Elastica/Test/Query/BoolTest.php
+++ b/test/lib/Elastica/Test/Query/BoolTest.php
@@ -41,7 +41,7 @@ public function testToArray()
'minimum_number_should_match' => $minMatch,
'must_not' => array($idsQuery2->toArray()),
'boost' => $boost,
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/BoostingTest.php b/test/lib/Elastica/Test/Query/BoostingTest.php
index f5af87403d..6644cee18e 100644
--- a/test/lib/Elastica/Test/Query/BoostingTest.php
+++ b/test/lib/Elastica/Test/Query/BoostingTest.php
@@ -18,7 +18,7 @@ class BoostingTest extends BaseTest
*/
protected $type;
- /*
+ /**
* @var array
*/
protected $sampleData;
@@ -30,7 +30,7 @@ protected function setUp()
$this->type = $this->index->getType('test');
$this->type->setMapping(array(
'name' => array('type' => 'string', 'index' => 'analyzed'),
- 'price' => array('type' => 'float')
+ 'price' => array('type' => 'float'),
));
$this->sampleData = array(
@@ -38,10 +38,10 @@ protected function setUp()
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)
+ array("name" => "Lama Vital 2nd", "price" => 3.2),
);
- foreach($this->sampleData as $key => $value) {
+ foreach ($this->sampleData as $key => $value) {
$this->type->addDocument(new Document($key, $value));
}
@@ -70,8 +70,8 @@ public function testToArray()
'boosting' => array(
'positive' => $positiveQuery->toArray(),
'negative' => $negativeQuery->toArray(),
- 'negative_boost' => 0.3
- )
+ 'negative_boost' => 0.3,
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
diff --git a/test/lib/Elastica/Test/Query/BuilderTest.php b/test/lib/Elastica/Test/Query/BuilderTest.php
index 45a2ee96c4..79a7cac2e2 100644
--- a/test/lib/Elastica/Test/Query/BuilderTest.php
+++ b/test/lib/Elastica/Test/Query/BuilderTest.php
@@ -171,7 +171,7 @@ public function testQueryTypes($method, $queryType)
{
$this->assertSame($this->builder, $this->builder->$method()); // open
$this->assertSame($this->builder, $this->builder->{$method."Close"}()); // close
- $this->assertSame('{"' . $queryType . '":{}}', (string) $this->builder);
+ $this->assertSame('{"'.$queryType.'":{}}', (string) $this->builder);
}
/**
@@ -263,9 +263,9 @@ public function testToArray()
$this->assertEquals(array(
'query' => array(
'term' => array(
- 'category.id' => array(1, 2, 3)
- )
- )
+ 'category.id' => array(1, 2, 3),
+ ),
+ ),
), $this->builder->toArray());
}
}
diff --git a/test/lib/Elastica/Test/Query/CommonTest.php b/test/lib/Elastica/Test/Query/CommonTest.php
index a84d639724..84b66f7d72 100644
--- a/test/lib/Elastica/Test/Query/CommonTest.php
+++ b/test/lib/Elastica/Test/Query/CommonTest.php
@@ -17,9 +17,9 @@ public function testToArray()
'body' => array(
'query' => 'test query',
'cutoff_frequency' => .001,
- 'low_freq_operator' => 'and'
- )
- )
+ 'low_freq_operator' => 'and',
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/ConstantScoreTest.php b/test/lib/Elastica/Test/Query/ConstantScoreTest.php
index 27143eb67b..cd6ca9df9f 100644
--- a/test/lib/Elastica/Test/Query/ConstantScoreTest.php
+++ b/test/lib/Elastica/Test/Query/ConstantScoreTest.php
@@ -2,13 +2,13 @@
namespace Elastica\Test\Query;
-use Elastica\Filter\Term;
+use Elastica\Document;
use Elastica\Filter\Ids;
+use Elastica\Filter\Term;
+use Elastica\Index;
use Elastica\Query\ConstantScore;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
-use Elastica\Index;
-use Elastica\Document;
use Elastica\Type;
class ConstantScoreTest extends BaseTest
@@ -81,8 +81,8 @@ public function testToArray()
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -98,16 +98,14 @@ public function testConstruct()
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
-
}
public function testQuery()
{
-
$client = $this->_getClient();
$index = new Index($client, 'test');
$index->create(array(), true);
@@ -134,8 +132,8 @@ public function testQuery()
$expectedArray = array(
'constant_score' => array(
'query' => $query_match->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -145,7 +143,6 @@ public function testQuery()
$this->assertEquals($resultSet->count(), 3);
$this->assertEquals($results[1]->getScore(), 1);
-
}
public function testConstructEmpty()
diff --git a/test/lib/Elastica/Test/Query/DisMaxTest.php b/test/lib/Elastica/Test/Query/DisMaxTest.php
index 31c8437ddf..6e7564bc4a 100644
--- a/test/lib/Elastica/Test/Query/DisMaxTest.php
+++ b/test/lib/Elastica/Test/Query/DisMaxTest.php
@@ -39,9 +39,9 @@ public function testToArray()
'queries' => array(
$idsQuery1->toArray(),
$idsQuery2->toArray(),
- $idsQuery3->toArray()
- )
- )
+ $idsQuery3->toArray(),
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/EscapeStringTest.php b/test/lib/Elastica/Test/Query/EscapeStringTest.php
index 7af9d114cc..fa84d9b6e4 100644
--- a/test/lib/Elastica/Test/Query/EscapeStringTest.php
+++ b/test/lib/Elastica/Test/Query/EscapeStringTest.php
@@ -4,10 +4,10 @@
use Elastica\Document;
use Elastica\Index;
-use Elastica\Type;
-use Elastica\Util;
use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
+use Elastica\Util;
class EscapeStringTest extends BaseTest
{
@@ -22,14 +22,14 @@ public function testSearch()
$type = new Type($index, 'helloworld');
$doc = new Document(1, array(
- 'email' => 'test@test.com', 'username' => 'test 7/6 123', 'test' => array('2', '3', '5'))
+ 'email' => 'test@test.com', 'username' => 'test 7/6 123', 'test' => array('2', '3', '5'), )
);
$type->addDocument($doc);
// Refresh index
$index->refresh();
- $queryString = new QueryString( Util::escapeTerm('test 7/6') );
+ $queryString = new QueryString(Util::escapeTerm('test 7/6'));
$resultSet = $type->search($queryString);
$this->assertEquals(1, $resultSet->count());
diff --git a/test/lib/Elastica/Test/Query/FilteredTest.php b/test/lib/Elastica/Test/Query/FilteredTest.php
index c6bd90967a..4e891dd01b 100644
--- a/test/lib/Elastica/Test/Query/FilteredTest.php
+++ b/test/lib/Elastica/Test/Query/FilteredTest.php
@@ -69,7 +69,7 @@ public function testFilteredWithoutArgumentsShouldRaiseException()
$query = new Filtered();
$query->toArray();
}
-
+
public function testFilteredSearchNoQuery()
{
$index = $this->_createIndex();
@@ -89,7 +89,7 @@ public function testFilteredSearchNoQuery()
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
+
public function testFilteredSearchNoFilter()
{
$index = $this->_createIndex();
@@ -108,5 +108,4 @@ public function testFilteredSearchNoFilter()
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
}
diff --git a/test/lib/Elastica/Test/Query/FunctionScoreTest.php b/test/lib/Elastica/Test/Query/FunctionScoreTest.php
index 7063e152ef..faaa828ca9 100644
--- a/test/lib/Elastica/Test/Query/FunctionScoreTest.php
+++ b/test/lib/Elastica/Test/Query/FunctionScoreTest.php
@@ -4,7 +4,6 @@
* Date: 9/16/13
* Time: 5:05 PM
*/
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -35,18 +34,18 @@ protected function setUp()
$this->type->setMapping(array(
'name' => array('type' => 'string', 'index' => 'not_analyzed'),
'location' => array('type' => 'geo_point'),
- 'price' => array('type' => 'float')
+ 'price' => array('type' => 'float'),
));
$this->type->addDocument(new Document(1, array(
'name' => "Mr. Frostie's",
'location' => array('lat' => 32.799605, 'lon' => -117.243027),
- 'price' => 4.5
+ 'price' => 4.5,
)));
$this->type->addDocument(new Document(2, array(
'name' => "Miller's Field",
'location' => array('lat' => 32.795964, 'lon' => -117.255028),
- 'price' => 9.5
+ 'price' => 9.5,
)));
$this->index->refresh();
@@ -76,20 +75,20 @@ public function testToArray()
'gauss' => array(
'location' => array(
'origin' => $this->locationOrigin,
- 'scale' => $locationScale
- )
- )
+ 'scale' => $locationScale,
+ ),
+ ),
),
array(
'gauss' => array(
'price' => array(
'origin' => $priceOrigin,
- 'scale' => $priceScale
- )
- )
- )
- )
- )
+ 'scale' => $priceScale,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
@@ -120,8 +119,8 @@ public function testDecayWeight()
'gauss' => array(
'location' => array(
'origin' => $this->locationOrigin,
- 'scale' => $locationScale
- )
+ 'scale' => $locationScale,
+ ),
),
'weight' => .5,
),
@@ -129,13 +128,13 @@ public function testDecayWeight()
'gauss' => array(
'price' => array(
'origin' => $priceOrigin,
- 'scale' => $priceScale
- )
+ 'scale' => $priceScale,
+ ),
),
'weight' => 2,
- )
- )
- )
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
@@ -165,12 +164,12 @@ public function testWeight()
'weight' => 5.0,
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
- )
- )
- )
- )
+ 'price' => 4.5,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
@@ -193,16 +192,16 @@ public function testRandomScore()
'functions' => array(
array(
'random_score' => array(
- 'seed' => 2
+ 'seed' => 2,
),
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
- )
- )
- )
- )
+ 'price' => 4.5,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
@@ -226,17 +225,17 @@ public function testRandomScoreWeight()
'functions' => array(
array(
'random_score' => array(
- 'seed' => 2
+ 'seed' => 2,
),
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
+ 'price' => 4.5,
+ ),
),
'weight' => 2,
- )
- )
- )
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
@@ -263,11 +262,11 @@ public function testScriptScore()
'functions' => array(
array(
'script_score' => array(
- 'script' => $scriptString
- )
- )
- )
- )
+ 'script' => $scriptString,
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php b/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
index 310a380d39..8804e9e03b 100644
--- a/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
+++ b/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
@@ -5,9 +5,9 @@
use Elastica\Document;
use Elastica\Index;
use Elastica\Query\FuzzyLikeThis;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class FuzzyLikeThisTest extends BaseTest
{
@@ -20,7 +20,7 @@ public function testSearch()
//$index->getSettings()->setNumberOfShards(1);
$type = new Type($index, 'helloworldfuzzy');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
@@ -36,7 +36,7 @@ public function testSearch()
$fltQuery = new FuzzyLikeThis();
$fltQuery->setLikeText("sample gmail");
- $fltQuery->addFields(array("email","content"));
+ $fltQuery->addFields(array("email", "content"));
$fltQuery->setMinSimilarity(0.3);
$fltQuery->setMaxQueryTerms(3);
$resultSet = $type->search($fltQuery);
@@ -177,26 +177,26 @@ public function testSearchSetAnalyzer()
'searchAnalyzer' => array(
'type' => 'custom',
'tokenizer' => 'standard',
- 'filter' => array('myStopWords')
- )
+ 'filter' => array('myStopWords'),
+ ),
),
'filter' => array(
'myStopWords' => array(
'type' => 'stop',
- 'stopwords' => array('The')
- )
- )
+ 'stopwords' => array('The'),
+ ),
+ ),
)), true);
$index->getSettings()->setNumberOfReplicas(0);
//$index->getSettings()->setNumberOfShards(1);
-
+
$type = new Type($index, 'helloworldfuzzy');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
-
+
$mapping->setSource(array('enabled' => false));
$type->setMapping($mapping);
@@ -210,7 +210,7 @@ public function testSearchSetAnalyzer()
$index->refresh();
$fltQuery = new FuzzyLikeThis();
- $fltQuery->addFields(array("email","content"));
+ $fltQuery->addFields(array("email", "content"));
$fltQuery->setLikeText("The");
$fltQuery->setMinSimilarity(0.1);
@@ -234,7 +234,7 @@ public function testNoLikeTextProvidedShouldReturnNoResults()
$index->getSettings()->setNumberOfReplicas(0);
$type = new Type($index, 'helloworldfuzzy');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
@@ -250,7 +250,7 @@ public function testNoLikeTextProvidedShouldReturnNoResults()
$fltQuery = new FuzzyLikeThis();
$fltQuery->setLikeText("");
- $fltQuery->addFields(array("email","content"));
+ $fltQuery->addFields(array("email", "content"));
$fltQuery->setMinSimilarity(0.3);
$fltQuery->setMaxQueryTerms(3);
$resultSet = $type->search($fltQuery);
diff --git a/test/lib/Elastica/Test/Query/FuzzyTest.php b/test/lib/Elastica/Test/Query/FuzzyTest.php
index 576592938a..afbebd3531 100644
--- a/test/lib/Elastica/Test/Query/FuzzyTest.php
+++ b/test/lib/Elastica/Test/Query/FuzzyTest.php
@@ -16,9 +16,9 @@ public function testToArray()
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray(), 'Deprecated method failed');
@@ -27,8 +27,8 @@ public function testToArray()
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
@@ -38,9 +38,9 @@ public function testToArray()
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
}
@@ -73,7 +73,7 @@ public function testQuery()
$this->assertEquals(2, $resultSet->count());
}
- public function testBadArguments ()
+ public function testBadArguments()
{
$this->setExpectedException('Elastica\Exception\InvalidException');
$query = new Fuzzy();
@@ -88,9 +88,9 @@ public function testBadArguments ()
$query->setField('name', 'value');
$query->setField('name1', 'value1');
}
-
- public function testFuzzyWithFacets() {
+ public function testFuzzyWithFacets()
+ {
$index = $this->_createIndex();
$type = $index->getType('test');
@@ -109,21 +109,21 @@ public function testFuzzyWithFacets() {
$fuzzyQuery = new Fuzzy();
$fuzzyQuery->setField($field, 'Baden');
-
+
$facet = new \Elastica\Facet\Terms('test');
$facet->setField('name');
-
- $query = new \Elastica\Query($fuzzyQuery);
- $query->addFacet($facet);
+
+ $query = new \Elastica\Query($fuzzyQuery);
+ $query->addFacet($facet);
$resultSet = $index->search($query);
-
- // Assert query worked ok
+
+ // Assert query worked ok
$this->assertEquals(2, $resultSet->count());
-
- // Check Facets
- $this->assertTrue($resultSet->hasFacets());
- $facets = $resultSet->getFacets();
- $this->assertEquals(2, $facets['test']['total']);
- }
+
+ // Check Facets
+ $this->assertTrue($resultSet->hasFacets());
+ $facets = $resultSet->getFacets();
+ $this->assertEquals(2, $facets['test']['total']);
+ }
}
diff --git a/test/lib/Elastica/Test/Query/HasChildTest.php b/test/lib/Elastica/Test/Query/HasChildTest.php
index bb1b5b96b1..1870ffc7ad 100644
--- a/test/lib/Elastica/Test/Query/HasChildTest.php
+++ b/test/lib/Elastica/Test/Query/HasChildTest.php
@@ -20,8 +20,8 @@ public function testToArray()
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -42,55 +42,55 @@ public function testSetScope()
'has_child' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
-
+
public function testTypeInsideHasChildSearch()
{
$index = $this->prepareSearchData();
-
+
$f = new \Elastica\Query\Match();
$f->setField('alt.name', 'testname');
$query = new HasChild($f, 'child');
-
+
$searchQuery = new \Elastica\Query();
$searchQuery->setQuery($query);
$searchResults = $index->search($searchQuery);
-
+
$this->assertEquals(1, $searchResults->count());
-
+
$result = $searchResults->current()->getData();
$expected = array('id' => 'parent2', 'user' => 'parent2', 'email' => 'parent2@test.com');
-
+
$this->assertEquals($expected, $result);
- }
-
+ }
+
private function prepareSearchData()
{
$client = $this->_getClient();
$index = $client->getIndex('has_child_test');
$index->create(array(), true);
-
+
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
$childMapping = new \Elastica\Type\Mapping($childType);
$childMapping->setParent('parent');
$childMapping->send();
-
+
$altType = $index->getType('alt');
$altDoc = new Document('alt1', array('name' => 'altname'));
$altType->addDocument($altDoc);
-
+
$parent1 = new Document('parent1', array('id' => 'parent1', 'user' => 'parent1', 'email' => 'parent1@test.com'));
$parentType->addDocument($parent1);
$parent2 = new Document('parent2', array('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->setParent('parent1');
$childType->addDocument($child1);
@@ -100,8 +100,9 @@ private function prepareSearchData()
$child3 = new Document('child3', array('id' => 'child3', 'user' => 'child3', 'email' => 'child3@test.com', 'alt' => array(array('name' => 'testname'))));
$child3->setParent('parent2');
$childType->addDocument($child3);
-
+
$index->refresh();
+
return $index;
}
}
diff --git a/test/lib/Elastica/Test/Query/HasParentTest.php b/test/lib/Elastica/Test/Query/HasParentTest.php
index d417c88770..16cb74f99f 100644
--- a/test/lib/Elastica/Test/Query/HasParentTest.php
+++ b/test/lib/Elastica/Test/Query/HasParentTest.php
@@ -19,8 +19,8 @@ public function testToArray()
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -41,8 +41,8 @@ public function testSetScope()
'has_parent' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/HighlightTest.php b/test/lib/Elastica/Test/Query/HighlightTest.php
index 4b1b6c5e13..acfeae1ec2 100644
--- a/test/lib/Elastica/Test/Query/HighlightTest.php
+++ b/test/lib/Elastica/Test/Query/HighlightTest.php
@@ -44,6 +44,5 @@ public function testHightlightSearch()
$this->assertEquals(array('phrase' => array(0 => 'My name is ruflin')), $highlight);
}
$this->assertEquals(2, $resultSet->count());
-
}
}
diff --git a/test/lib/Elastica/Test/Query/MatchTest.php b/test/lib/Elastica/Test/Query/MatchTest.php
index ed164663f2..5a779f2c50 100644
--- a/test/lib/Elastica/Test/Query/MatchTest.php
+++ b/test/lib/Elastica/Test/Query/MatchTest.php
@@ -46,9 +46,9 @@ public function testToArray()
'fuzziness' => $fuzziness,
'fuzzy_rewrite' => $fuzzyRewrite,
'prefix_length' => $prefixLength,
- 'max_expansions' => $maxExpansions
- )
- )
+ 'max_expansions' => $maxExpansions,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -164,24 +164,22 @@ public function testMatchPhrasePrefix()
$this->assertEquals(2, $resultSet->count());
}
-
-
+
public function testMatchFuzzinessType()
{
$field = 'test';
$query = new Match();
-
+
$fuzziness = "AUTO";
$query->setFieldFuzziness($field, $fuzziness);
-
+
$parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
-
-
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
+
$fuzziness = 0.3;
$query->setFieldFuzziness($field, $fuzziness);
-
+
$parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
}
}
diff --git a/test/lib/Elastica/Test/Query/MoreLikeThisTest.php b/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
index b352e23aca..74c70faf9a 100644
--- a/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
+++ b/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
@@ -6,9 +6,9 @@
use Elastica\Index;
use Elastica\Query;
use Elastica\Query\MoreLikeThis;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class MoreLikeThisTest extends BaseTest
{
@@ -21,7 +21,7 @@ public function testSearch()
//$index->getSettings()->setNumberOfShards(1);
$type = new Type($index, 'helloworldmlt');
- $mapping = new Mapping($type , array(
+ $mapping = new Mapping($type, array(
'email' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
'content' => array('store' => 'yes', 'type' => 'string', 'index' => 'analyzed'),
));
@@ -40,7 +40,7 @@ public function testSearch()
$mltQuery = new MoreLikeThis();
$mltQuery->setLikeText('fake gmail sample');
- $mltQuery->setFields(array('email','content'));
+ $mltQuery->setFields(array('email', 'content'));
$mltQuery->setMaxQueryTerms(1);
$mltQuery->setMinDocFrequency(1);
$mltQuery->setMinTermFrequency(1);
diff --git a/test/lib/Elastica/Test/Query/MultiMatchTest.php b/test/lib/Elastica/Test/Query/MultiMatchTest.php
index 78a8a8febc..e9b07403d6 100644
--- a/test/lib/Elastica/Test/Query/MultiMatchTest.php
+++ b/test/lib/Elastica/Test/Query/MultiMatchTest.php
@@ -85,10 +85,11 @@ public function testFuzzyWithOptions1()
$this->multiMatch->setPrefixLength(6);
$resultSet = $this->_getResults();
- $this->assertEquals(0, $resultSet->count());
+ $this->assertEquals(0, $resultSet->count());
}
-
- public function testFuzzyWithOptions2() {
+
+ public function testFuzzyWithOptions2()
+ {
// Here with a 'M' search we should hit 'Moraes' first
// and then stop because MaxExpansion = 1.
@@ -155,14 +156,14 @@ private function _generateIndex()
'analyzer' => array(
'noStops' => array(
'type' => 'standard',
- 'stopwords' => '_none_'
+ 'stopwords' => '_none_',
),
'stops' => array(
'type' => 'standard',
- 'stopwords' => array('not')
+ 'stopwords' => array('not'),
),
),
- )
+ ),
), true);
$type = $index->getType('test');
diff --git a/test/lib/Elastica/Test/Query/NestedTest.php b/test/lib/Elastica/Test/Query/NestedTest.php
index 310a728b58..a4b08b62b5 100644
--- a/test/lib/Elastica/Test/Query/NestedTest.php
+++ b/test/lib/Elastica/Test/Query/NestedTest.php
@@ -20,7 +20,7 @@ public function testSetQuery()
'nested' => array(
'query' => $queryString->toArray(),
'path' => $path,
- )
+ ),
);
$this->assertEquals($expected, $nested->toArray());
diff --git a/test/lib/Elastica/Test/Query/PostFilterTest.php b/test/lib/Elastica/Test/Query/PostFilterTest.php
index ea7efa0666..690d4ee79e 100644
--- a/test/lib/Elastica/Test/Query/PostFilterTest.php
+++ b/test/lib/Elastica/Test/Query/PostFilterTest.php
@@ -5,8 +5,8 @@
use Elastica\Document;
use Elastica\Filter\Term;
use Elastica\Index;
-use Elastica\Query\Match;
use Elastica\Query;
+use Elastica\Query\Match;
use Elastica\Test\Base as BaseTest;
class PostFilterTest extends BaseTest
@@ -28,7 +28,6 @@ protected function setUp()
);
$this->_index->getType("test")->addDocuments($docs);
$this->_index->refresh();
-
}
protected function tearDown()
@@ -50,7 +49,6 @@ public function testToArray()
$this->assertArrayHasKey('post_filter', $data);
$this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']);
-
}
public function testQuery()
@@ -70,11 +68,10 @@ public function testQuery()
$results = $this->_index->search($query);
$this->assertEquals(1, $results->getTotalHits());
-
}
protected function _createIndex($name = 'test', $delete = true, $shards = 1)
{
- return parent::_createIndex('test_postfilter_' . $name, $delete, $shards);
+ return parent::_createIndex('test_postfilter_'.$name, $delete, $shards);
}
}
diff --git a/test/lib/Elastica/Test/Query/QueryStringTest.php b/test/lib/Elastica/Test/Query/QueryStringTest.php
index 059bad2d2b..99b429fffb 100644
--- a/test/lib/Elastica/Test/Query/QueryStringTest.php
+++ b/test/lib/Elastica/Test/Query/QueryStringTest.php
@@ -4,9 +4,9 @@
use Elastica\Document;
use Elastica\Index;
-use Elastica\Type;
use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class QueryStringTest extends BaseTest
{
@@ -16,7 +16,7 @@ public function testSearchMultipleFields()
$query = new QueryString($str);
$expected = array(
- 'query' => $str
+ 'query' => $str,
);
$this->assertEquals(array('query_string' => $expected), $query->toArray());
@@ -106,13 +106,13 @@ public function testSetDefaultField()
public function testSetRewrite()
{
- $rewrite = 'scoring_boolean';
- $query = new QueryString('test');
- $query->setRewrite($rewrite);
+ $rewrite = 'scoring_boolean';
+ $query = new QueryString('test');
+ $query->setRewrite($rewrite);
- $data = $query->toArray();
+ $data = $query->toArray();
- $this->assertEquals($data['query_string']['rewrite'], $rewrite);
+ $this->assertEquals($data['query_string']['rewrite'], $rewrite);
}
/**
diff --git a/test/lib/Elastica/Test/Query/RangeTest.php b/test/lib/Elastica/Test/Query/RangeTest.php
index 4cd75bc868..89271d1e60 100644
--- a/test/lib/Elastica/Test/Query/RangeTest.php
+++ b/test/lib/Elastica/Test/Query/RangeTest.php
@@ -48,7 +48,7 @@ public function testToArray()
$expectedArray = array(
'range' => array(
'age' => $field,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
@@ -65,7 +65,7 @@ public function testConstruct()
$expectedArray = array(
'range' => array(
'age' => $ranges,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
diff --git a/test/lib/Elastica/Test/Query/RegexpTest.php b/test/lib/Elastica/Test/Query/RegexpTest.php
index 6fc154efce..c0014bd445 100644
--- a/test/lib/Elastica/Test/Query/RegexpTest.php
+++ b/test/lib/Elastica/Test/Query/RegexpTest.php
@@ -20,9 +20,9 @@ public function testToArray()
'regexp' => array(
$field => array(
'value' => $value,
- 'boost' => $boost
- )
- )
+ 'boost' => $boost,
+ ),
+ ),
);
$this->assertequals($expectedArray, $query->toArray());
diff --git a/test/lib/Elastica/Test/Query/RescoreTest.php b/test/lib/Elastica/Test/Query/RescoreTest.php
index 4396ceb4c5..16ef05edd3 100644
--- a/test/lib/Elastica/Test/Query/RescoreTest.php
+++ b/test/lib/Elastica/Test/Query/RescoreTest.php
@@ -2,10 +2,10 @@
namespace Elastica\Test\Query;
-use Elastica\Rescore\Query as QueryRescore;
-use Elastica\Query\Term;
-use Elastica\Query\Match;
use Elastica\Query;
+use Elastica\Query\Match;
+use Elastica\Query\Term;
+use Elastica\Rescore\Query as QueryRescore;
use Elastica\Test\Base as BaseTest;
class RescoreTest extends BaseTest
@@ -133,7 +133,7 @@ public function testSetWeights()
),
),
'query_weight' => 0.7,
- 'rescore_query_weight' => 1.2
+ 'rescore_query_weight' => 1.2,
),
),
);
diff --git a/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php b/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
index eff9b8a1ab..85da04338e 100644
--- a/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
+++ b/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test\Query;
-
use Elastica\Document;
use Elastica\Index;
use Elastica\Query\SimpleQueryString;
@@ -24,7 +23,7 @@ protected function setUp()
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'))
+ new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')),
);
$this->_index->getType("guitars")->addDocuments($docs);
$this->_index->refresh();
@@ -49,8 +48,8 @@ public function testToArray()
"query" => $string,
"fields" => $fields,
"analyzer" => "whitespace",
- "default_operator" => SimpleQueryString::OPERATOR_OR
- )
+ "default_operator" => SimpleQueryString::OPERATOR_OR,
+ ),
);
$this->assertEquals($expected, $query->toArray());
@@ -70,4 +69,3 @@ public function testQuery()
$this->assertEquals(0, $results->getTotalHits());
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/Query/WildcardTest.php b/test/lib/Elastica/Test/Query/WildcardTest.php
index 077e6d4f80..345037f2de 100644
--- a/test/lib/Elastica/Test/Query/WildcardTest.php
+++ b/test/lib/Elastica/Test/Query/WildcardTest.php
@@ -27,9 +27,9 @@ public function testToArray()
'wildcard' => array(
$key => array(
'value' => $value,
- 'boost' => $boost
- )
- )
+ 'boost' => $boost,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $wildcard->toArray());
@@ -46,10 +46,10 @@ public function testSearchWithAnalyzer()
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
diff --git a/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php b/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
index 0438215089..59ecea39f1 100644
--- a/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
+++ b/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
@@ -41,24 +41,27 @@ class AggregationTest extends \PHPUnit_Framework_TestCase
'geohash_grid' => array('name', 'field'),
);
- public function __construct() {
+ public function __construct()
+ {
$this->aggregations['filter'] = array('name', new Exists('field'));
}
- public function testType() {
+ public function testType()
+ {
$aggregationDSL = new DSL\Aggregation();
$this->assertInstanceOf('Elastica\QueryBuilder\DSL', $aggregationDSL);
$this->assertEquals(DSL::TYPE_AGGREGATION, $aggregationDSL->getType());
}
- public function testAggregations() {
+ public function testAggregations()
+ {
$aggregationDSL = new DSL\Aggregation();
- foreach($this->aggregations as $methodName => $arguments) {
+ foreach ($this->aggregations as $methodName => $arguments) {
$this->assertTrue(
method_exists($aggregationDSL, $methodName),
- 'method for aggregation "' . $methodName . '" not found'
+ 'method for aggregation "'.$methodName.'" not found'
);
try {
@@ -68,9 +71,9 @@ public function testAggregations() {
$this->assertInstanceOf(
'Elastica\Exception\NotImplementedException',
$exception,
- 'breaking change in aggregation "' . $methodName . '" found: ' . $exception->getMessage()
+ 'breaking change in aggregation "'.$methodName.'" found: '.$exception->getMessage()
);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php b/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
index de43eb9a21..c040a6340d 100644
--- a/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
+++ b/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
@@ -36,7 +36,8 @@ class FilterTest extends \PHPUnit_Framework_TestCase
'type' => array('type'),
);
- public function __construct() {
+ public function __construct()
+ {
$this->filters['bool_and'] = array(array(new Exists('field')));
$this->filters['bool_or'] = array(array(new Exists('field')));
$this->filters['bool_not'] = array(new Exists('field'));
@@ -46,20 +47,22 @@ public function __construct() {
$this->filters['query'] = array(new Match());
}
- public function testType() {
+ public function testType()
+ {
$filterDSL = new DSL\Filter();
$this->assertInstanceOf('Elastica\QueryBuilder\DSL', $filterDSL);
$this->assertEquals(DSL::TYPE_FILTER, $filterDSL->getType());
}
- public function testFilters() {
+ public function testFilters()
+ {
$filterDSL = new DSL\Filter();
- foreach($this->filters as $methodName => $arguments) {
+ foreach ($this->filters as $methodName => $arguments) {
$this->assertTrue(
method_exists($filterDSL, $methodName),
- 'method for filter "' . $methodName . '" not found'
+ 'method for filter "'.$methodName.'" not found'
);
try {
@@ -69,9 +72,9 @@ public function testFilters() {
$this->assertInstanceOf(
'Elastica\Exception\NotImplementedException',
$exception,
- 'breaking change in filter "' . $methodName . '" found: ' . $exception->getMessage()
+ 'breaking change in filter "'.$methodName.'" found: '.$exception->getMessage()
);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php b/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
index bdefab12fe..dfd38a4794 100644
--- a/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
+++ b/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
@@ -52,27 +52,30 @@ class QueryTest extends \PHPUnit_Framework_TestCase
'template' => array(),
);
- public function __construct() {
+ public function __construct()
+ {
$this->queries['filtered'] = array(new Match(), new Exists('field'));
$this->queries['has_child'] = array(new Match());
$this->queries['has_parent'] = array(new Match(), 'type');
$this->queries['top_children'] = array(new Match(), 'type');
}
- public function testType() {
+ public function testType()
+ {
$queryDSL = new DSL\Query();
$this->assertInstanceOf('Elastica\QueryBuilder\DSL', $queryDSL);
$this->assertEquals(DSL::TYPE_QUERY, $queryDSL->getType());
}
- public function testQueries() {
+ public function testQueries()
+ {
$queryDSL = new DSL\Query();
- foreach($this->queries as $methodName => $arguments) {
+ foreach ($this->queries as $methodName => $arguments) {
$this->assertTrue(
method_exists($queryDSL, $methodName),
- 'method for query "' . $methodName . '" not found'
+ 'method for query "'.$methodName.'" not found'
);
try {
@@ -82,20 +85,21 @@ public function testQueries() {
$this->assertInstanceOf(
'Elastica\Exception\NotImplementedException',
$exception,
- 'breaking change in query "' . $methodName . '" found: ' . $exception->getMessage()
+ 'breaking change in query "'.$methodName.'" found: '.$exception->getMessage()
);
}
}
}
- public function testMatch() {
+ public function testMatch()
+ {
$queryDSL = new DSL\Query();
$shortMatch = $queryDSL->match('field', 'match');
$this->assertEquals($shortMatch->getParam('field'), array(
- 'field' => 'match'
+ 'field' => 'match',
));
$this->assertInstanceOf('Elastica\Query\Match', $queryDSL->match());
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php b/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
index ae0c160d81..4471244264 100644
--- a/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
+++ b/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
@@ -16,24 +16,26 @@ class SuggestTest extends \PHPUnit_Framework_TestCase
'context' => array(),
);
- public function __construct() {
-
+ public function __construct()
+ {
}
- public function testType() {
+ public function testType()
+ {
$suggestDSL = new DSL\Suggest();
$this->assertInstanceOf('Elastica\QueryBuilder\DSL', $suggestDSL);
$this->assertEquals(DSL::TYPE_SUGGEST, $suggestDSL->getType());
}
- public function testFilters() {
+ public function testFilters()
+ {
$suggestDSL = new DSL\Suggest();
- foreach($this->suggesters as $methodName => $arguments) {
+ foreach ($this->suggesters as $methodName => $arguments) {
$this->assertTrue(
method_exists($suggestDSL, $methodName),
- 'method for suggest "' . $methodName . '" not found'
+ 'method for suggest "'.$methodName.'" not found'
);
try {
@@ -43,9 +45,9 @@ public function testFilters() {
$this->assertInstanceOf(
'Elastica\Exception\NotImplementedException',
$exception,
- 'breaking change in suggest "' . $methodName . '" found: ' . $exception->getMessage()
+ 'breaking change in suggest "'.$methodName.'" found: '.$exception->getMessage()
);
}
}
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/QueryBuilder/VersionTest.php b/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
index 5015082e56..14fd1b28d9 100644
--- a/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
+++ b/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
@@ -25,7 +25,7 @@ public function testVersions()
new Version\Version140(),
);
- foreach($versions as $version) {
+ foreach ($versions as $version) {
$this->assertVersions($version, $dsl);
}
}
@@ -35,30 +35,29 @@ private function assertVersions(Version $version, array $dsl)
foreach ($version->getQueries() as $query) {
$this->assertTrue(
method_exists($dsl[0], $query),
- 'query "' . $query . '" in ' . get_class($version) . ' must be defined in ' . get_class($dsl[0])
+ 'query "'.$query.'" in '.get_class($version).' must be defined in '.get_class($dsl[0])
);
}
foreach ($version->getFilters() as $filter) {
$this->assertTrue(
method_exists($dsl[1], $filter),
- 'filter "' . $filter . '" in ' . get_class($version) . ' must be defined in ' . get_class($dsl[1])
+ 'filter "'.$filter.'" in '.get_class($version).' must be defined in '.get_class($dsl[1])
);
}
foreach ($version->getAggregations() as $aggregation) {
$this->assertTrue(
method_exists($dsl[2], $aggregation),
- 'aggregation "' . $aggregation . '" in ' . get_class($version) . ' must be defined in ' . get_class($dsl[2])
+ 'aggregation "'.$aggregation.'" in '.get_class($version).' must be defined in '.get_class($dsl[2])
);
}
foreach ($version->getSuggesters() as $suggester) {
$this->assertTrue(
method_exists($dsl[3], $suggester),
- 'suggester "' . $suggester . '" in ' . get_class($version) . ' must be defined in ' . get_class($dsl[3])
+ 'suggester "'.$suggester.'" in '.get_class($version).' must be defined in '.get_class($dsl[3])
);
}
}
-
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/QueryTest.php b/test/lib/Elastica/Test/QueryTest.php
index bc89fcba32..fc0906527b 100644
--- a/test/lib/Elastica/Test/QueryTest.php
+++ b/test/lib/Elastica/Test/QueryTest.php
@@ -4,11 +4,11 @@
use Elastica\Document;
use Elastica\Exception\InvalidException;
+use Elastica\Facet\Terms;
+use Elastica\Query;
use Elastica\Query\Builder;
use Elastica\Query\Term;
use Elastica\Query\Text;
-use Elastica\Query;
-use Elastica\Facet\Terms;
use Elastica\Suggest;
use Elastica\Test\Base as BaseTest;
@@ -86,9 +86,9 @@ public function testArrayQuery()
$query = array(
'query' => array(
'text' => array(
- 'title' => 'test'
- )
- )
+ 'title' => 'test',
+ ),
+ ),
);
$query1 = Query::create($query);
@@ -172,7 +172,7 @@ public function testSetFields()
$this->assertContains('firstname', $data['fields']);
$this->assertContains('lastname', $data['fields']);
- $this->assertEquals(2, count($data['fields']));
+ $this->assertCount(2, $data['fields']);
}
public function testGetQuery()
diff --git a/test/lib/Elastica/Test/ResponseTest.php b/test/lib/Elastica/Test/ResponseTest.php
index af8043be9a..c2cb71d4b9 100644
--- a/test/lib/Elastica/Test/ResponseTest.php
+++ b/test/lib/Elastica/Test/ResponseTest.php
@@ -1,14 +1,15 @@
array('type' => 'string', 'store' => 'no'),
- 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss')
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
));
$type->setMapping($mapping);
@@ -73,7 +74,7 @@ public function testIsOkMultiple()
$docs = array(
new Document(1, array('name' => 'ruflin')),
- new Document(2, array('name' => 'ruflin'))
+ new Document(2, array('name' => 'ruflin')),
);
$response = $type->addDocuments($docs);
@@ -88,7 +89,7 @@ public function testIsOkBulkWithErrorsField()
'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)),
- )
+ ),
)));
$this->assertTrue($response->isOk());
@@ -102,7 +103,7 @@ public function testIsNotOkBulkWithErrorsField()
'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)),
- )
+ ),
)));
$this->assertFalse($response->isOk());
@@ -115,7 +116,7 @@ public function testIsOkBulkItemsWithOkField()
'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)),
- )
+ ),
)));
$this->assertTrue($response->isOk());
@@ -128,7 +129,7 @@ public function testIsNotOkBulkItemsWithOkField()
'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)),
- )
+ ),
)));
$this->assertFalse($response->isOk());
@@ -141,7 +142,7 @@ public function testIsOkBulkItemsWithStatusField()
'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)),
- )
+ ),
)));
$this->assertTrue($response->isOk());
@@ -154,7 +155,7 @@ public function testIsNotOkBulkItemsWithStatusField()
'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)),
- )
+ ),
)));
$this->assertFalse($response->isOk());
@@ -171,5 +172,4 @@ public function testGetDataEmpty()
$this->assertEquals(0, count($response));
}
-
}
diff --git a/test/lib/Elastica/Test/ResultSetTest.php b/test/lib/Elastica/Test/ResultSetTest.php
index 2a62111de8..67e939c777 100644
--- a/test/lib/Elastica/Test/ResultSetTest.php
+++ b/test/lib/Elastica/Test/ResultSetTest.php
@@ -2,10 +2,7 @@
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
-use Elastica\Query;
-use Elastica\Query\Match;
use Elastica\Result;
use Elastica\Test\Base as BaseTest;
diff --git a/test/lib/Elastica/Test/ResultTest.php b/test/lib/Elastica/Test/ResultTest.php
index 54d3ce5599..8b54630841 100644
--- a/test/lib/Elastica/Test/ResultTest.php
+++ b/test/lib/Elastica/Test/ResultTest.php
@@ -5,8 +5,8 @@
use Elastica\Client;
use Elastica\Document;
use Elastica\Result;
-use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class ResultTest extends BaseTest
{
@@ -103,17 +103,17 @@ public function testGetTotalTimeReturnsExpectedResults()
'Total Time should be an integer'
);
}
-
+
public function testHasFields()
{
$data = array('value set');
$result = new Result(array());
$this->assertFalse($result->hasFields());
-
+
$result = new Result(array('_source' => $data));
$this->assertFalse($result->hasFields());
-
+
$result = new Result(array('fields' => $data));
$this->assertTrue($result->hasFields());
$this->assertEquals($data, $result->getFields());
diff --git a/test/lib/Elastica/Test/ScanAndScrollTest.php b/test/lib/Elastica/Test/ScanAndScrollTest.php
index a64670bbdb..3fda0ae9c4 100644
--- a/test/lib/Elastica/Test/ScanAndScrollTest.php
+++ b/test/lib/Elastica/Test/ScanAndScrollTest.php
@@ -9,22 +9,26 @@
use Elastica\Search;
use Elastica\Test\Base as BaseTest;
-class ScanAndScrollTest extends BaseTest {
+class ScanAndScrollTest extends BaseTest
+{
- public function testConstruct() {
+ public function testConstruct()
+ {
$scanAndScroll = $this->_prepareScanAndScroll();
$this->assertInstanceOf('Elastica\ScanAndScroll', $scanAndScroll);
}
- public function testDefaultProperties() {
+ public function testDefaultProperties()
+ {
$scanAndScroll = $this->_prepareScanAndScroll();
$this->assertEquals('1m', $scanAndScroll->expiryTime);
$this->assertEquals(1000, $scanAndScroll->sizePerShard);
}
- public function testQuerySizeOverride() {
+ public function testQuerySizeOverride()
+ {
$query = new Query();
$query->setSize(100);
@@ -43,7 +47,8 @@ public function testQuerySizeOverride() {
$this->assertEquals(10, $query->getParam('size'));
}
- public function testSizePerShard() {
+ public function testSizePerShard()
+ {
$search = $this->_prepareSearch('test_2', 2, 20);
$scanAndScroll = new ScanAndScroll($search);
@@ -53,7 +58,8 @@ public function testSizePerShard() {
$this->assertEquals(10, $scanAndScroll->current()->count());
}
- public function testScrollId() {
+ public function testScrollId()
+ {
$search = $this->_prepareSearch('test_3', 1, 2);
$scanAndScroll = new ScanAndScroll($search);
@@ -66,7 +72,8 @@ public function testScrollId() {
);
}
- public function testForeach() {
+ public function testForeach()
+ {
$search = $this->_prepareSearch('test_4', 2, 11);
$scanAndScroll = new ScanAndScroll($search);
@@ -78,11 +85,11 @@ public function testForeach() {
// Note: there is a 3. scroll with 0 hits
$count = 0;
- foreach($scanAndScroll as $resultSet) {
+ foreach ($scanAndScroll as $resultSet) {
/** @var ResultSet $resultSet */
$count++;
- switch(true) {
+ switch (true) {
case $count == 1: $this->assertEquals(10, $resultSet->count()); break;
case $count == 2: $this->assertEquals(1, $resultSet->count()); break;
}
@@ -91,11 +98,13 @@ public function testForeach() {
$this->assertEquals(2, $count);
}
- private function _prepareScanAndScroll() {
+ private function _prepareScanAndScroll()
+ {
return new ScanAndScroll(new Search($this->_getClient()));
}
- private function _prepareSearch($indexName, $indexShards, $docs) {
+ private function _prepareSearch($indexName, $indexShards, $docs)
+ {
$index = $this->_createIndex($indexName, true, $indexShards);
$type = $index->getType('scanAndScrollTest');
@@ -112,4 +121,4 @@ private function _prepareSearch($indexName, $indexShards, $docs) {
return $search;
}
-}
\ No newline at end of file
+}
diff --git a/test/lib/Elastica/Test/ScriptFieldsTest.php b/test/lib/Elastica/Test/ScriptFieldsTest.php
index 718fa0c8fe..6dc844773f 100644
--- a/test/lib/Elastica/Test/ScriptFieldsTest.php
+++ b/test/lib/Elastica/Test/ScriptFieldsTest.php
@@ -28,37 +28,37 @@ public function testNewScriptFields()
$script = new Script('1 + 2');
// addScript
- $scriptFields = new ScriptFields;
+ $scriptFields = new ScriptFields();
$scriptFields->addScript('test', $script);
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
// setScripts
- $scriptFields = new ScriptFields;
+ $scriptFields = new ScriptFields();
$scriptFields->setScripts(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
// Constructor
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($scriptFields->getParam('test'), $script->toArray());
}
public function testSetScriptFields()
{
- $query = new Query;
+ $query = new Query();
$script = new Script('1 + 2');
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$query->setScriptFields($scriptFields);
$this->assertEquals($query->getParam('script_fields'), $scriptFields->toArray());
$query->setScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$this->assertEquals($query->getParam('script_fields'), $scriptFields->toArray());
}
@@ -83,7 +83,7 @@ public function testQuery()
$query = new Query();
$script = new Script('1 + 2');
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$query->setScriptFields($scriptFields);
diff --git a/test/lib/Elastica/Test/ScriptTest.php b/test/lib/Elastica/Test/ScriptTest.php
index 0a11d1185c..6661b32966 100644
--- a/test/lib/Elastica/Test/ScriptTest.php
+++ b/test/lib/Elastica/Test/ScriptTest.php
@@ -116,14 +116,14 @@ public function dataProviderCreateInvalid()
{
return array(
array(
- new \stdClass
+ new \stdClass(),
),
array(
array('params' => array('param1' => 'one')),
),
array(
array('script' => '_score * 2.0', 'params' => 'param'),
- )
+ ),
);
}
}
diff --git a/test/lib/Elastica/Test/SearchTest.php b/test/lib/Elastica/Test/SearchTest.php
index 026a98d5a5..efdc82180e 100644
--- a/test/lib/Elastica/Test/SearchTest.php
+++ b/test/lib/Elastica/Test/SearchTest.php
@@ -6,11 +6,10 @@
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Index;
-use Elastica\Query\Builder;
+use Elastica\Query;
+use Elastica\Query\FunctionScore;
use Elastica\Query\MatchAll;
use Elastica\Query\QueryString;
-use Elastica\Query\FunctionScore;
-use Elastica\Query;
use Elastica\Script;
use Elastica\Search;
use Elastica\Test\Base as BaseTest;
@@ -158,23 +157,23 @@ public function testGetPath()
// Only index
$search1->addIndex($index1);
- $this->assertEquals($index1->getName() . '/_search', $search1->getPath());
+ $this->assertEquals($index1->getName().'/_search', $search1->getPath());
// MUltiple index, no types
$search1->addIndex($index2);
- $this->assertEquals($index1->getName() . ',' . $index2->getName() . '/_search', $search1->getPath());
+ $this->assertEquals($index1->getName().','.$index2->getName().'/_search', $search1->getPath());
// Single type, no index
$search2->addType($type1);
- $this->assertEquals('_all/' . $type1->getName() . '/_search', $search2->getPath());
+ $this->assertEquals('_all/'.$type1->getName().'/_search', $search2->getPath());
// Multiple types
$search2->addType($type2);
- $this->assertEquals('_all/' . $type1->getName() . ',' . $type2->getName() . '/_search', $search2->getPath());
+ $this->assertEquals('_all/'.$type1->getName().','.$type2->getName().'/_search', $search2->getPath());
// Combine index and types
$search2->addIndex($index1);
- $this->assertEquals($index1->getName() . '/' . $type1->getName() . ',' . $type2->getName() . '/_search', $search2->getPath());
+ $this->assertEquals($index1->getName().'/'.$type1->getName().','.$type2->getName().'/_search', $search2->getPath());
}
public function testSearchRequest()
@@ -479,34 +478,34 @@ public function testEmptySearch()
$this->assertEquals('bunny', $source['username']);
}
- public function testCount() {
+ public function testCount()
+ {
$index = $this->_createIndex('eeee');
$search = new Search($index->getClient());
- $type = $index->getType('test');
+ $type = $index->getType('test');
$doc = new Document(1, array('id' => 1, 'username' => 'ruflin'));
- $type->addDocument($doc);
- $index->refresh();
-
- $search->addIndex($index);
- $search->addType($type);
+ $type->addDocument($doc);
+ $index->refresh();
- $result1 = $search->count(new \Elastica\Query\MatchAll());
- $this->assertEquals(1, $result1);
+ $search->addIndex($index);
+ $search->addType($type);
+ $result1 = $search->count(new \Elastica\Query\MatchAll());
+ $this->assertEquals(1, $result1);
- $result2 = $search->count(new \Elastica\Query\MatchAll(), true);
- $this->assertInstanceOf('\Elastica\ResultSet', $result2);
- $this->assertEquals(1, $result2->getTotalHits());
- }
+ $result2 = $search->count(new \Elastica\Query\MatchAll(), true);
+ $this->assertInstanceOf('\Elastica\ResultSet', $result2);
+ $this->assertEquals(1, $result2->getTotalHits());
+ }
- public function testScanAndScroll() {
+ public function testScanAndScroll()
+ {
$search = new Search($this->_getClient());
$this->assertInstanceOf('Elastica\ScanAndScroll', $search->scanAndScroll());
}
-
public function testIgnoreUnavailableOption()
{
$client = $this->_getClient();
@@ -527,5 +526,4 @@ public function testIgnoreUnavailableOption()
$results = $search->search($query, array(Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true));
$this->assertInstanceOf('\Elastica\ResultSet', $results);
}
-
}
diff --git a/test/lib/Elastica/Test/SnapshotTest.php b/test/lib/Elastica/Test/SnapshotTest.php
index 3ac5bfe299..c7036a0b48 100644
--- a/test/lib/Elastica/Test/SnapshotTest.php
+++ b/test/lib/Elastica/Test/SnapshotTest.php
@@ -2,7 +2,6 @@
namespace Elastica\Test;
-
use Elastica\Document;
use Elastica\Index;
use Elastica\Snapshot;
@@ -109,4 +108,3 @@ public function testSnapshotAndRestore()
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
}
-
\ No newline at end of file
diff --git a/test/lib/Elastica/Test/StatusTest.php b/test/lib/Elastica/Test/StatusTest.php
index 14d7950a2f..7f23c22688 100644
--- a/test/lib/Elastica/Test/StatusTest.php
+++ b/test/lib/Elastica/Test/StatusTest.php
@@ -1,6 +1,7 @@
getIndex($indexName);
$index->create(array(), true);
$index = $this->_createIndex();
- $index->refresh();
- $index->optimize();
+ $index->refresh();
+ $index->optimize();
$status = new Status($index->getClient());
$names = $status->getIndexNames();
@@ -93,7 +94,7 @@ public function testAliasExists()
$indicesWithAlias = $status->getIndicesWithAlias($aliasName);
$this->assertEquals(array("elastica_$indexName"), array_map(
- function($index) {
+ function ($index) {
return $index->getName();
}, $indicesWithAlias));
}
@@ -104,7 +105,7 @@ public function testServerStatus()
$status = $client->getStatus();
$serverStatus = $status->getServerStatus();
- $this->assertTrue(!empty($serverStatus) );
+ $this->assertTrue(!empty($serverStatus));
$this->assertTrue('array' == gettype($serverStatus));
$this->assertArrayHasKey('status', $serverStatus);
$this->assertTrue($serverStatus['status'] == 200);
diff --git a/test/lib/Elastica/Test/Suggest/PhraseTest.php b/test/lib/Elastica/Test/Suggest/PhraseTest.php
index eda08ba0ad..fda5ae7971 100644
--- a/test/lib/Elastica/Test/Suggest/PhraseTest.php
+++ b/test/lib/Elastica/Test/Suggest/PhraseTest.php
@@ -2,13 +2,12 @@
namespace Elastica\Test\Suggest;
+use Elastica\Document;
+use Elastica\Index;
use Elastica\Suggest;
use Elastica\Suggest\CandidateGenerator\DirectGenerator;
use Elastica\Suggest\Phrase;
use Elastica\Test\Base as BaseTest;
-use Elastica\Query;
-use Elastica\Document;
-use Elastica\Index;
class PhraseTest extends BaseTest
{
@@ -55,10 +54,10 @@ public function testToArray()
'text' => 'elasticsearch is bansai coor',
'phrase' => array(
'field' => 'text',
- 'analyzer' => 'simple'
- )
- )
- )
+ 'analyzer' => 'simple',
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $suggest->toArray());
diff --git a/test/lib/Elastica/Test/Suggest/TermTest.php b/test/lib/Elastica/Test/Suggest/TermTest.php
index 7765f1bbbf..205fa25eb2 100644
--- a/test/lib/Elastica/Test/Suggest/TermTest.php
+++ b/test/lib/Elastica/Test/Suggest/TermTest.php
@@ -2,12 +2,11 @@
namespace Elastica\Test\Suggest;
+use Elastica\Document;
+use Elastica\Index;
use Elastica\Suggest;
use Elastica\Suggest\Term;
use Elastica\Test\Base as BaseTest;
-use Elastica\Query;
-use Elastica\Document;
-use Elastica\Index;
class TermTest extends BaseTest
{
@@ -51,17 +50,17 @@ public function testToArray()
'suggest' => array(
'suggest1' => array(
'term' => array(
- 'field' => '_all'
+ 'field' => '_all',
),
- 'text' => 'Foor'
+ 'text' => 'Foor',
),
'suggest2' => array(
'term' => array(
- 'field' => '_all'
+ 'field' => '_all',
),
- 'text' => 'Girhub'
- )
- )
+ 'text' => 'Girhub',
+ ),
+ ),
);
$this->assertEquals($expected, $suggest->toArray());
diff --git a/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
index 4f1c7114d4..5b36bb6817 100644
--- a/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
+++ b/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
@@ -2,10 +2,10 @@
namespace Elastica\Test\Transport;
-use Elastica\Transport\AbstractTransport;
-use Elastica\Transport\Http;
use Elastica\Connection;
use Elastica\Exception\InvalidException;
+use Elastica\Transport\AbstractTransport;
+use Elastica\Transport\Http;
class AbstractTransportTest extends \PHPUnit_Framework_TestCase
{
diff --git a/test/lib/Elastica/Test/Transport/GuzzleTest.php b/test/lib/Elastica/Test/Transport/GuzzleTest.php
index 2972fb4a69..1d959232b3 100644
--- a/test/lib/Elastica/Test/Transport/GuzzleTest.php
+++ b/test/lib/Elastica/Test/Transport/GuzzleTest.php
@@ -7,7 +7,6 @@
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class GuzzleTest extends BaseTest
{
@@ -39,15 +38,15 @@ public function getConfig()
return array(
array(
array('persistent' => false, 'transport' => 'Guzzle'),
- 'GET'
+ 'GET',
),
array(
array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
- 'GET'
+ 'GET',
),
array(
array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
- 'POST'
+ 'POST',
),
);
}
@@ -164,7 +163,6 @@ public function testBodyReuse()
*/
public function testInvalidConnection()
{
-
$client = new Client(array('transport' => 'Guzzle', 'port' => 4500, 'persistent' => false));
$response = $client->request('_status', 'GET');
}
diff --git a/test/lib/Elastica/Test/Transport/HttpTest.php b/test/lib/Elastica/Test/Transport/HttpTest.php
index 1ee4e77d07..91c06ec7bb 100644
--- a/test/lib/Elastica/Test/Transport/HttpTest.php
+++ b/test/lib/Elastica/Test/Transport/HttpTest.php
@@ -7,7 +7,6 @@
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class HttpTest extends BaseTest
{
@@ -32,15 +31,15 @@ public function getConfig()
return array(
array(
array('transport' => 'Http'),
- 'GET'
+ 'GET',
),
array(
array('transport' => array('type' => 'Http', 'postWithRequestBody' => false)),
- 'GET'
+ 'GET',
),
array(
array('transport' => array('type' => 'Http', 'postWithRequestBody' => true)),
- 'POST'
+ 'POST',
),
);
}
@@ -190,7 +189,7 @@ public function testWithoutProxy()
public function testBodyReuse()
{
$client = new Client();
-
+
$index = $client->getIndex('elastica_body_reuse_test');
$index->create(array(), true);
$this->_waitForAllocation($index);
@@ -229,5 +228,4 @@ public function testPostWith0Body()
$this->assertNotEmpty($tokens);
}
-
}
diff --git a/test/lib/Elastica/Test/Transport/NullTest.php b/test/lib/Elastica/Test/Transport/NullTest.php
index c07f5da158..1ef1646311 100644
--- a/test/lib/Elastica/Test/Transport/NullTest.php
+++ b/test/lib/Elastica/Test/Transport/NullTest.php
@@ -25,35 +25,35 @@ public function testEmptyResult()
$index = $client->getIndex('elasticaNullTransportTest1');
- $resultSet = $index->search(new Query());
- $this->assertNotNull($resultSet);
+ $resultSet = $index->search(new Query());
+ $this->assertNotNull($resultSet);
- $response = $resultSet->getResponse();
- $this->assertNotNull($response);
+ $response = $resultSet->getResponse();
+ $this->assertNotNull($response);
// Validate most of the expected fields in the response data. Consumers of the response
// object have a reasonable expectation of finding "hits", "took", etc
$responseData = $response->getData();
- $this->assertContains("took", $responseData);
- $this->assertEquals(0, $responseData["took"]);
- $this->assertContains("_shards", $responseData);
- $this->assertContains("hits", $responseData);
- $this->assertContains("total", $responseData["hits"]);
- $this->assertEquals(0, $responseData["hits"]["total"]);
- $this->assertContains("params", $responseData);
-
- $took = $response->getEngineTime();
- $this->assertEquals(0, $took);
-
- $errorString = $response->getError();
- $this->assertEmpty($errorString);
-
- $shards = $response->getShardsStatistics();
- $this->assertContains("total", $shards);
- $this->assertEquals(0, $shards["total"]);
- $this->assertContains("successful", $shards);
- $this->assertEquals(0, $shards["successful"]);
- $this->assertContains("failed", $shards);
- $this->assertEquals(0, $shards["failed"]);
+ $this->assertContains("took", $responseData);
+ $this->assertEquals(0, $responseData["took"]);
+ $this->assertContains("_shards", $responseData);
+ $this->assertContains("hits", $responseData);
+ $this->assertContains("total", $responseData["hits"]);
+ $this->assertEquals(0, $responseData["hits"]["total"]);
+ $this->assertContains("params", $responseData);
+
+ $took = $response->getEngineTime();
+ $this->assertEquals(0, $took);
+
+ $errorString = $response->getError();
+ $this->assertEmpty($errorString);
+
+ $shards = $response->getShardsStatistics();
+ $this->assertContains("total", $shards);
+ $this->assertEquals(0, $shards["total"]);
+ $this->assertContains("successful", $shards);
+ $this->assertEquals(0, $shards["successful"]);
+ $this->assertContains("failed", $shards);
+ $this->assertEquals(0, $shards["failed"]);
}
}
diff --git a/test/lib/Elastica/Test/Transport/ThriftTest.php b/test/lib/Elastica/Test/Transport/ThriftTest.php
index f1698ff6bd..7672c1c31f 100644
--- a/test/lib/Elastica/Test/Transport/ThriftTest.php
+++ b/test/lib/Elastica/Test/Transport/ThriftTest.php
@@ -6,7 +6,6 @@
use Elastica\Connection;
use Elastica\Document;
use Elastica\Index;
-use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class ThriftTest extends BaseTest
@@ -104,8 +103,8 @@ public function configProvider()
array(
'host' => 'localhost',
'port' => 9500,
- 'transport' => 'Thrift'
- )
+ 'transport' => 'Thrift',
+ ),
),
array(
array(
@@ -116,9 +115,9 @@ public function configProvider()
'framedTransport' => false,
'sendTimeout' => 10000,
'recvTimeout' => 20000,
- )
- )
- )
+ ),
+ ),
+ ),
);
}
diff --git a/test/lib/Elastica/Test/Type/MappingTest.php b/test/lib/Elastica/Test/Type/MappingTest.php
index 796bfb8dcd..ce5281c9ff 100644
--- a/test/lib/Elastica/Test/Type/MappingTest.php
+++ b/test/lib/Elastica/Test/Type/MappingTest.php
@@ -34,7 +34,7 @@ public function testMappingStoreFields()
$doc = new Document(1,
array(
'firstname' => $firstname,
- 'lastname' => 'Ruflin'
+ 'lastname' => 'Ruflin',
)
);
@@ -115,7 +115,7 @@ public function testNestedMapping()
'firstname' => array('type' => 'string', 'store' => 'yes'),
'lastname' => array('type' => 'string', 'store' => 'yes'),
'age' => array('type' => 'integer', 'store' => 'yes'),
- )
+ ),
),
),
),
@@ -128,7 +128,7 @@ public function testNestedMapping()
'user' => array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
- 'age' => 9
+ 'age' => 9,
),
));
@@ -146,7 +146,7 @@ public function testParentMapping()
$parenttype = new Type($index, 'parenttype');
$parentmapping = new Mapping($parenttype,
array(
- 'name' => array('type' => 'string', 'store' => 'yes')
+ 'name' => array('type' => 'string', 'store' => 'yes'),
)
);
@@ -178,9 +178,9 @@ public function testMappingExample()
'note' => array(
'store' => 'yes', '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)
- )
- )
+ 'contenido' => array('type' => 'string', 'store' => 'no', 'include_in_all' => true, 'boost' => 1.0),
+ ),
+ ),
)
);
@@ -190,13 +190,13 @@ public function testMappingExample()
'note' => array(
array(
'titulo' => 'nota1',
- 'contenido' => 'contenido1'
+ 'contenido' => 'contenido1',
),
array(
'titulo' => 'nota2',
- 'contenido' => 'contenido2'
- )
- )
+ 'contenido' => 'contenido2',
+ ),
+ ),
)
);
@@ -208,15 +208,15 @@ public function testMappingExample()
/**
* Test setting a dynamic template and validate whether the right mapping is applied after adding a document which
* should match the dynamic template. The example is the template_1 from the Elasticsearch documentation.
- *
+ *
* @link http://www.elasticsearch.org/guide/reference/mapping/root-object-type/
*/
public function testDynamicTemplate()
{
$index = $this->_createIndex();
$type = $index->getType('person');
-
- // set a dynamic template "template_1" which creates a multi field for multi* matches.
+
+ // 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(
@@ -225,17 +225,17 @@ public function testDynamicTemplate()
'type' => 'multi_field',
'fields' => array(
'{name}' => array('type' => '{dynamic_type}', 'index' => 'analyzed'),
- 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed')
- )
- )
- ))
+ 'org' => array('type' => '{dynamic_type}', 'index' => 'not_analyzed'),
+ ),
+ ),
+ )),
));
-
+
$mapping->send();
-
+
// when running the tests, the mapping sometimes isn't available yet. Optimize index to enforce reload mapping.
$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));
@@ -266,7 +266,7 @@ public function testSetMeta()
$type = $index->getType('test');
$mapping = new Mapping($type, array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
));
$mapping->setMeta(array('class' => 'test'));
$type->setMapping($mapping);
@@ -283,12 +283,12 @@ public function testGetters()
$type = $index->getType('test');
$properties = array(
'firstname' => array('type' => 'string', 'store' => 'yes'),
- 'lastname' => array('type' => 'string')
+ 'lastname' => array('type' => 'string'),
);
$mapping = new Mapping($type, $properties);
$all = array(
"enabled" => true,
- "store" => "yes"
+ "store" => "yes",
);
$mapping->setParam('_all', $all);
$get_all = $mapping->getParam('_all');
diff --git a/test/lib/Elastica/Test/TypeTest.php b/test/lib/Elastica/Test/TypeTest.php
index 4c91b25a29..0da79f5e0d 100644
--- a/test/lib/Elastica/Test/TypeTest.php
+++ b/test/lib/Elastica/Test/TypeTest.php
@@ -6,16 +6,16 @@
use Elastica\Document;
use Elastica\Exception\NotFoundException;
use Elastica\Exception\ResponseException;
+use Elastica\Filter\Term;
+use Elastica\Index;
use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Query\SimpleQueryString;
use Elastica\Script;
use Elastica\Search;
-use Elastica\Filter\Term;
+use Elastica\Test\Base as BaseTest;
use Elastica\Type;
-use Elastica\Index;
use Elastica\Type\Mapping;
-use Elastica\Test\Base as BaseTest;
class TypeTest extends BaseTest
{
@@ -72,11 +72,11 @@ public function testCreateSearch()
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
'size' => 5,
- 'explain' => true
+ 'explain' => true,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test_index'), $search->getIndices());
@@ -100,9 +100,9 @@ public function testCreateSearchWithArray()
$query = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
- )
+ 'query' => 'test',
+ ),
+ ),
);
$options = array(
@@ -115,11 +115,11 @@ public function testCreateSearchWithArray()
$expected = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
+ 'query' => 'test',
+ ),
),
'size' => 5,
- 'explain' => true
+ 'explain' => true,
);
$this->assertEquals($expected, $search->getQuery()->toArray());
$this->assertEquals(array('test_index'), $search->getIndices());
@@ -411,7 +411,7 @@ public function testDeleteByQueryWithQueryAndOptions()
$this->assertEquals(1, $response->count());
// Route to the wrong document id; should not delete
- $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing'=>'2'));
+ $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '2'));
$this->assertTrue($response->isOk());
$index->refresh();
@@ -423,7 +423,7 @@ public function testDeleteByQueryWithQueryAndOptions()
$this->assertEquals(1, $response->count());
// Delete first document
- $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing'=>'1'));
+ $response = $type->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '1'));
$this->assertTrue($response->isOk());
$index->refresh();
@@ -691,10 +691,10 @@ public function testUpdateDocumentWithoutSource()
$mapping->setProperties(array(
'name' => array(
'type' => 'string',
- 'store' => 'yes'),
+ 'store' => 'yes', ),
'counter' => array(
'type' => 'integer',
- 'store' => 'no'
+ 'store' => 'no',
),
));
$mapping->disableSource();
@@ -831,7 +831,8 @@ public function testExists()
$this->assertFalse($index->exists());
}
- public function testGetMapping() {
+ public function testGetMapping()
+ {
$indexName = 'test';
$typeName = 'test-type';
@@ -839,7 +840,7 @@ public function testGetMapping() {
$indexName = $index->getName();
$type = new Type($index, $typeName);
$mapping = new Mapping($type, $expect = array(
- 'id' => array('type' => 'integer', 'store' => true)
+ 'id' => array('type' => 'integer', 'store' => true),
));
$type->setMapping($mapping);
@@ -851,7 +852,8 @@ public function testGetMapping() {
);
}
- public function testGetMappingAlias() {
+ public function testGetMappingAlias()
+ {
$indexName = 'test';
$aliasName = 'test-alias';
$typeName = 'test-alias-type';
@@ -860,7 +862,7 @@ public function testGetMappingAlias() {
$index->addAlias($aliasName);
$type = new Type($index, $typeName);
$mapping = new Mapping($type, $expect = array(
- 'id' => array('type' => 'integer', 'store' => true)
+ 'id' => array('type' => 'integer', 'store' => true),
));
$type->setMapping($mapping);
diff --git a/test/lib/Elastica/Test/UtilTest.php b/test/lib/Elastica/Test/UtilTest.php
index 87488e383c..e01f0553af 100644
--- a/test/lib/Elastica/Test/UtilTest.php
+++ b/test/lib/Elastica/Test/UtilTest.php
@@ -2,10 +2,10 @@
namespace Elastica\Test;
-use Elastica\Util;
-use Elastica\Request;
use Elastica\Connection;
+use Elastica\Request;
use Elastica\Test\Base as BaseTest;
+use Elastica\Util;
class UtilTest extends BaseTest
{
@@ -25,18 +25,18 @@ public function getEscapeTermPairs()
array('oh yeah!', 'oh yeah\\!'),
// Seperate test below because phpunit seems to have some problems
//array('\\+-&&||!(){}[]^"~*?:', '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:'),
- array('some signs, can stay.', 'some signs, can stay.')
+ array('some signs, can stay.', 'some signs, can stay.'),
);
}
/**
* @dataProvider getReplaceBooleanWordsPairs
*/
- public function testReplaceBooleanWords($before, $after)
+ public function testReplaceBooleanWords($before, $after)
{
$this->assertEquals($after, Util::replaceBooleanWords($before));
}
-
+
public function getReplaceBooleanWordsPairs()
{
return array(
@@ -45,10 +45,10 @@ public function getReplaceBooleanWordsPairs()
array('Black AND White', 'Black && White'),
array('TIMBERLAND Men`s', 'TIMBERLAND Men`s'),
array('hello NOT kitty', 'hello !kitty'),
- array('SEND NOTIFICATION', 'SEND NOTIFICATION')
+ array('SEND NOTIFICATION', 'SEND NOTIFICATION'),
);
- }
-
+ }
+
public function testEscapeTermSpecialCharacters()
{
$before = '\\+-&&||!(){}[]^"~*?:/';
@@ -92,7 +92,6 @@ public function testConvertRequestToCurlCommand()
$expected = 'curl -XPOST \'http://localhost:9200/test?no=params\' -d \'{"key":"value"}\'';
$this->assertEquals($expected, $curlCommand);
-
}
public function testConvertDateTimeObjectWithTimezone()
diff --git a/test/phpunit-travis.xml b/test/phpunit-travis.xml
index c4591a9cf9..27b1ac845e 100644
--- a/test/phpunit-travis.xml
+++ b/test/phpunit-travis.xml
@@ -1,17 +1,17 @@
@@ -25,14 +25,14 @@
-