summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-20 09:00:55 +0100
commita2190ac74dd4d7080b12bab90e552d7aa81209ef (patch)
tree8b31f38de9882d18df54cf8d9e0de74167a094eb /vendor/ruflin/elastica/test
parent15e69f7b20b6596b9148030acce5b59993b95a45 (diff)
parent257401d8b2cf661adf36c84b0e3fd1cf85e33c22 (diff)
Merge branch 'mw-1.26'
Diffstat (limited to 'vendor/ruflin/elastica/test')
-rw-r--r--vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php46
-rw-r--r--vendor/ruflin/elastica/test/benchmark/ClientTest.php31
-rw-r--r--vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml10
-rw-r--r--vendor/ruflin/elastica/test/bin/install_php_memcache.sh8
-rw-r--r--vendor/ruflin/elastica/test/bin/run_elasticsearch.sh56
-rw-r--r--vendor/ruflin/elastica/test/bin/run_proxy.sh15
-rw-r--r--vendor/ruflin/elastica/test/bin/show_logs.sh3
-rw-r--r--vendor/ruflin/elastica/test/bootstrap.php2
-rw-r--r--vendor/ruflin/elastica/test/data/test.jpgbin0 -> 4459 bytes
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php35
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php130
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php100
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php45
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php95
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php120
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php43
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php41
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php44
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php51
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php73
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php125
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php88
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php87
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php50
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php72
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php385
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php133
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php29
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php181
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php402
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php95
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php24
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php25
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php42
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php112
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php128
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php113
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php84
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php48
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php37
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php8
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php)12
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php15
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php25
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php65
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php20
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php134
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php7
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php14
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php39
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php200
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php10
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php56
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php107
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php)7
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php12
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php64
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php59
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php109
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php115
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php140
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php78
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php30
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php139
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php152
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php69
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php47
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php83
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php13
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php113
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php9
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php78
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php10
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php285
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php61
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php94
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php43
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php148
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php (renamed from vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php)75
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php84
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php93
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php52
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php36
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php38
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php270
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php112
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php87
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php64
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php68
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php17
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php46
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php159
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php240
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php72
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php151
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php6
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php57
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php99
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php28
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php31
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php103
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php108
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php4
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php5
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php23
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php39
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php58
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php85
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php32
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php67
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php88
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php290
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php16
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php141
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php34
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php22
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php131
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php44
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php46
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php105
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php311
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php74
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php55
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php33
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php140
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php67
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php71
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php135
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php11
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php85
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php103
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php181
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php59
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php96
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php37
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php (renamed from vendor/ruflin/elastica/test/benchmark/TransportTest.php)97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php97
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php259
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php78
-rw-r--r--vendor/ruflin/elastica/test/nginx/nginx.conf24
-rw-r--r--vendor/ruflin/elastica/test/phpunit.xhprof.xml (renamed from vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml)4
-rw-r--r--vendor/ruflin/elastica/test/phpunit.xml.dist37
197 files changed, 9499 insertions, 3228 deletions
diff --git a/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php b/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php
deleted file mode 100644
index 23e6521f..00000000
--- a/vendor/ruflin/elastica/test/benchmark/BulkMemoryUsageTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-
-use Elastica\Client;
-use Elastica\Document;
-
-class BulkMemoryUsageTest extends \PHPUnit_Framework_TestCase
-{
-
- /**
- * Some memory usage stats
- *
- * Really simple and quite stupid ...
- */
- public function testServersArray()
- {
- $client = new Client();
- $index = $client->getIndex('test');
- $index->create(array(), true);
- $type = $index->getType('test');
-
- $data = array(
- 'text1' => 'Very long text for a string',
- 'text2' => 'But this is not very long',
- 'text3' => 'random or not random?',
- );
-
- $startMemory = memory_get_usage();
-
- for ($n = 1; $n < 10; $n++) {
- $docs = array();
-
- for ($i = 1; $i <= 3000; $i++) {
- $docs[] = new Document(uniqid(), $data);
- }
-
- $type->addDocuments($docs);
- $docs = array();
- }
-
- unset($docs);
-
- $endMemory = memory_get_usage();
-
- $this->assertLessThan(1.2, $endMemory/$startMemory);
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/ClientTest.php b/vendor/ruflin/elastica/test/benchmark/ClientTest.php
deleted file mode 100644
index e7a040f7..00000000
--- a/vendor/ruflin/elastica/test/benchmark/ClientTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-use Elastica\Client;
-use Elastica\Document;
-
-class ClientTest extends \PHPUnit_Framework_TestCase
-{
-
- public function testServersArray()
- {
- $client = new Client();
- $index = $client->getIndex('test');
- $index->create(array(), true);
- $type = $index->getType('test');
-
- $start = microtime(true);
-
- for ($i = 1; $i <= 10000; $i++) {
- $doc = new Document($i, array('test' => 1));
- $type->addDocument($doc);
- }
-
- // Refresh index
- $index->refresh();
-
- $end = microtime(true);
-
- //echo $end - $start;
-
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml b/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml
deleted file mode 100644
index a530de35..00000000
--- a/vendor/ruflin/elastica/test/benchmark/phpunit.benchmark.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<phpunit backupGlobals="false"
- backupStaticAttributes="false"
- bootstrap="../bootstrap.php"
- colors="true">
- <testsuites>
- <testsuite name="Transport">
- <file>TransportTest.php</file>
- </testsuite>
- </testsuites>
-</phpunit> \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/bin/install_php_memcache.sh b/vendor/ruflin/elastica/test/bin/install_php_memcache.sh
deleted file mode 100644
index dd046a56..00000000
--- a/vendor/ruflin/elastica/test/bin/install_php_memcache.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-# Build and install PHP Memcache extension
-wget http://pecl.php.net/get/memcache-${MEMCACHE_VER}.tgz
-tar -xzf memcache-${MEMCACHE_VER}.tgz
-sh -c "cd memcache-${MEMCACHE_VER} && phpize && ./configure --enable-memcache && make && sudo make install"
-echo "extension=memcache.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
-
diff --git a/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh b/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh
deleted file mode 100644
index ddbbef35..00000000
--- a/vendor/ruflin/elastica/test/bin/run_elasticsearch.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-check_port_http_code() {
- http_code=`echo $(curl -s -o /dev/null -w "%{http_code}" "http://localhost:$1")`
- return `test $http_code = "$2"`
-}
-
-wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ES_VER}.tar.gz
-tar -xzf elasticsearch-${ES_VER}.tar.gz
-
-elasticsearch-${ES_VER}/bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/${ES_MAPPER_ATTACHMENTS_VER}
-#elasticsearch-${ES_VER}/bin/plugin -install elasticsearch/elasticsearch-transport-thrift/${ES_TRANSPORT_THRIFT_VER}
-elasticsearch-${ES_VER}/bin/plugin -install geocluster-facet --url https://github.com/zenobase/geocluster-facet/releases/download/${ES_GEOCLUSTER_FACET_VER}/geocluster-facet-${ES_GEOCLUSTER_FACET_VER}.jar
-
-export JAVA_OPTS="-server"
-
-# start 3 elasticsearch instances
-for i in 0 1 2
-do
- echo "Setup node #$i"
-
- let "http_port = 9200 + $i"
- let "thrift_port = 9500 + $i"
-
- config_yml=elasticsearch-${ES_VER}/config/elasticsearch-$http_port.yml
-
- echo "Creating config $config_yml"
-
- cp elasticsearch-${ES_VER}/config/elasticsearch.yml $config_yml
-
- echo "index.number_of_shards: 2" >> $config_yml
- echo "index.number_of_replicas: 0" >> $config_yml
- echo "discovery.zen.ping.multicast.enabled: false" >> $config_yml
- echo "http.port: $http_port" >> $config_yml
- echo "thrift.port: $thrift_port" >> $config_yml
-
- # enable udp
- echo "bulk.udp.enabled: true" >> $config_yml
- echo "bulk.udp.bulk_actions: 5" >> $config_yml
-
- # enable dynamic scripting
- echo "script.disable_dynamic: false" >> $config_yml
-
- echo "Starting server on http port: $http_port"
-
- elasticsearch-${ES_VER}/bin/elasticsearch -d -Des.config=$config_yml &
-
- while ! check_port_http_code $http_port 200; do
- echo -n "."
- sleep 2s
- done
- echo ""
- echo "Server #$i is up"
-done
-
-echo "three elasticsearch nodes are up"
diff --git a/vendor/ruflin/elastica/test/bin/run_proxy.sh b/vendor/ruflin/elastica/test/bin/run_proxy.sh
deleted file mode 100644
index c62db8cd..00000000
--- a/vendor/ruflin/elastica/test/bin/run_proxy.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-
-sudo killall nginx 2>/dev/null
-
-echo "installing nginx"
-
-sudo apt-get install nginx
-
-echo "stopping stock nginx"
-
-/etc/init.d/nginx stop
-
-echo "running nginx"
-
-sudo nginx -p test/nginx/ -c nginx.conf
diff --git a/vendor/ruflin/elastica/test/bin/show_logs.sh b/vendor/ruflin/elastica/test/bin/show_logs.sh
deleted file mode 100644
index 0130d2a5..00000000
--- a/vendor/ruflin/elastica/test/bin/show_logs.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-cat elasticsearch-${ES_VER}/logs/* \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/bootstrap.php b/vendor/ruflin/elastica/test/bootstrap.php
index 5903f805..8a29cf0f 100644
--- a/vendor/ruflin/elastica/test/bootstrap.php
+++ b/vendor/ruflin/elastica/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/vendor/ruflin/elastica/test/data/test.jpg b/vendor/ruflin/elastica/test/data/test.jpg
new file mode 100644
index 00000000..d69e5672
--- /dev/null
+++ b/vendor/ruflin/elastica/test/data/test.jpg
Binary files differ
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
index 5c6fe13d..650a4655 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/AvgTest.php
@@ -1,38 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Document;
-use Elastica\Index;
use Elastica\Query;
class AvgTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('avg');
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testAvgAggregation()
{
- $agg = new Avg("avg");
+ $agg = new Avg('avg');
$agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregations();
+ $results = $this->_getIndexForTest()->search($query)->getAggregations();
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results['avg']['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
index 5569ca78..48003d7e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/BaseAggregationTest.php
@@ -1,28 +1,8 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
-use Elastica\Index;
use Elastica\Test\Base;
abstract class BaseAggregationTest extends Base
{
- /**
- * @var Index
- */
- protected $_index;
-
- protected function tearDown()
- {
- parent::tearDown();
- if ($this->_index instanceof Index) {
- $this->_index->delete();
- }
- }
-
- protected function _createIndex($name = 'test', $delete = true, $shards = 1)
- {
- return parent::_createIndex('test_aggregation_' . $name, $delete, $shards);
- }
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
index d2f4d2be..7bc383f0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/CardinalityTest.php
@@ -1,38 +1,132 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Cardinality;
use Elastica\Document;
use Elastica\Query;
class CardinalityTest extends BaseAggregationTest
{
- protected function setUp()
- {
- parent::setUp();
- $this->_index = $this->_createIndex("cardinality");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "blue")),
- new Document("3", array("color" => "red")),
- new Document("4", array("color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'blue')),
+ new Document(3, array('color' => 'red')),
+ new Document(4, array('color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testCardinalityAggregation()
{
- $agg = new Cardinality("cardinality");
- $agg->setField("color");
+ $agg = new Cardinality('cardinality');
+ $agg->setField('color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("cardinality");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('cardinality');
$this->assertEquals(3, $results['value']);
}
+
+ /**
+ * @dataProvider invalidPrecisionThresholdProvider
+ * @expectedException \InvalidArgumentException
+ *
+ * @param $threshold
+ */
+ public function testInvalidPrecisionThreshold($threshold)
+ {
+ $agg = new Cardinality('threshold');
+ $agg->setPrecisionThreshold($threshold);
+ }
+
+ /**
+ * @dataProvider validPrecisionThresholdProvider
+ *
+ * @param $threshold
+ */
+ public function testPrecisionThreshold($threshold)
+ {
+ $agg = new Cardinality('threshold');
+ $agg->setPrecisionThreshold($threshold);
+
+ $this->assertNotNull($agg->getParam('precision_threshold'));
+ $this->assertInternalType('int', $agg->getParam('precision_threshold'));
+ }
+
+ public function invalidPrecisionThresholdProvider()
+ {
+ return array(
+ 'string' => array('100'),
+ 'float' => array(7.8),
+ 'boolean' => array(true),
+ 'array' => array(array()),
+ 'object' => array(new \StdClass()),
+ );
+ }
+
+ public function validPrecisionThresholdProvider()
+ {
+ return array(
+ 'negative-int' => array(-140),
+ 'zero' => array(0),
+ 'positive-int' => array(150),
+ 'more-than-max' => array(40001),
+ );
+ }
+
+ /**
+ * @dataProvider validRehashProvider
+ *
+ * @param bool $rehash
+ */
+ public function testRehash($rehash)
+ {
+ $agg = new Cardinality('rehash');
+ $agg->setRehash($rehash);
+
+ $this->assertNotNull($agg->getParam('rehash'));
+ $this->assertInternalType('boolean', $agg->getParam('rehash'));
+ }
+
+ /**
+ * @dataProvider invalidRehashProvider
+ * @expectedException \InvalidArgumentException
+ *
+ * @param mixed $rehash
+ */
+ public function testInvalidRehash($rehash)
+ {
+ $agg = new Cardinality('rehash');
+ $agg->setRehash($rehash);
+ }
+
+ public function invalidRehashProvider()
+ {
+ return array(
+ 'string' => array('100'),
+ 'int' => array(100),
+ 'float' => array(7.8),
+ 'array' => array(array()),
+ 'object' => array(new \StdClass()),
+ );
+ }
+
+ public function validRehashProvider()
+ {
+ return array(
+ 'true' => array(true),
+ 'false' => array(false),
+ );
+ }
}
-
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
index d5bd878c..ca115ccc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateHistogramTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateHistogram;
use Elastica\Document;
use Elastica\Query;
@@ -10,34 +8,96 @@ use Elastica\Type\Mapping;
class DateHistogramTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("date_histogram");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "created" => array("type" => "date")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'created' => array('type' => 'date'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('created' => '2014-01-29T00:20:00')),
+ new Document(2, array('created' => '2014-01-29T02:20:00')),
+ new Document(3, array('created' => '2014-01-29T03:20:00')),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("created" => 1390962135000)),
- new Document("2", array("created" => 1390965735000)),
- new Document("3", array("created" => 1390954935000)),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testDateHistogramAggregation()
{
- $agg = new DateHistogram("hist", "created", "1h");
+ $agg = new DateHistogram('hist', 'created', '1h');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hist");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
$this->assertEquals(3, sizeof($results['buckets']));
}
+
+ /**
+ * @group unit
+ */
+ public function testSetOffset()
+ {
+ $agg = new DateHistogram('hist', 'created', '1h');
+
+ $agg->setOffset('3m');
+
+ $expected = array(
+ 'date_histogram' => array(
+ 'field' => 'created',
+ 'interval' => '1h',
+ 'offset' => '3m',
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+
+ $this->assertInstanceOf('Elastica\Aggregation\DateHistogram', $agg->setOffset('3m'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetOffsetWorks()
+ {
+ $agg = new DateHistogram('hist', 'created', '1m');
+ $agg->setOffset('+40s');
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
+
+ $this->assertEquals('2014-01-29T00:19:40.000Z', $results['buckets'][0]['key_as_string']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetTimezone()
+ {
+ $agg = new DateHistogram('hist', 'created', '1h');
+
+ $agg->setTimezone('-02:30');
+
+ $expected = array(
+ 'date_histogram' => array(
+ 'field' => 'created',
+ 'interval' => '1h',
+ 'time_zone' => '-02:30',
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+
+ $this->assertInstanceOf('Elastica\Aggregation\DateHistogram', $agg->setTimezone('-02:30'));
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
index 781f2112..b8078a4c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/DateRangeTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\DateRange;
use Elastica\Document;
use Elastica\Query;
@@ -10,42 +8,45 @@ use Elastica\Type\Mapping;
class DateRangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("date_range");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "created" => array("type" => "date")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'created' => array('type' => 'date'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('created' => 1390962135000)),
+ new Document(2, array('created' => 1390965735000)),
+ new Document(3, array('created' => 1390954935000)),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("created" => 1390962135000)),
- new Document("2", array("created" => 1390965735000)),
- new Document("3", array("created" => 1390954935000)),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testDateRangeAggregation()
{
- $agg = new DateRange("date");
- $agg->setField("created");
+ $agg = new DateRange('date');
+ $agg->setField('created');
$agg->addRange(1390958535000)->addRange(null, 1390958535000);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("date");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('date');
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/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
index e125c9c9..8c336245 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ExtendedStatsTest.php
@@ -1,36 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ExtendedStats;
use Elastica\Document;
use Elastica\Query;
class ExtendedStatsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("extended_stats");
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testExtendedStatsAggregation()
{
- $agg = new ExtendedStats("stats");
- $agg->setField("price");
+ $agg = new ExtendedStats('stats');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("stats");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('stats');
$this->assertEquals(4, $results['count']);
$this->assertEquals(1, $results['min']);
@@ -40,4 +43,3 @@ class ExtendedStatsTest extends BaseAggregationTest
$this->assertTrue(array_key_exists('sum_of_squares', $results));
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
index dd4d4c2d..9198bb95 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FilterTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\Filter;
use Elastica\Document;
@@ -12,67 +10,104 @@ use Elastica\Query;
class FilterTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("filter");
- $docs = array(
- new Document("1", array("price" => 5, "color" => "blue")),
- new Document("2", array("price" => 8, "color" => "blue")),
- new Document("3", array("price" => 1, "color" => "red")),
- new Document("4", array("price" => 3, "color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "filter" => array("range" => array("stock" => array("gt" => 0))),
- "aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ 'filter' => array('range' => array('stock' => array('gt' => 0))),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
);
- $agg = new Filter("in_stock_products");
- $agg->setFilter(new Range("stock", array("gt" => 0)));
- $avg = new Avg("avg_price");
- $avg->setField("price");
+ $agg = new Filter('in_stock_products');
+ $agg->setFilter(new Range('stock', array('gt' => 0)));
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$this->assertEquals($expected, $agg->toArray());
}
+ /**
+ * @group functional
+ */
public function testFilterAggregation()
{
- $agg = new Filter("filter");
- $agg->setFilter(new Term(array("color" => "blue")));
- $avg = new Avg("price");
- $avg->setField("price");
+ $agg = new Filter('filter');
+ $agg->setFilter(new Term(array('color' => 'blue')));
+ $avg = new Avg('price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("filter");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('filter');
$results = $results['price']['value'];
$this->assertEquals((5 + 8) / 2.0, $results);
}
+ /**
+ * @group functional
+ */
public function testFilterNoSubAggregation()
{
- $agg = new Avg("price");
- $agg->setField("price");
+ $agg = new Avg('price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("price");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('price');
$results = $results['value'];
$this->assertEquals((5 + 8 + 1 + 3) / 4.0, $results);
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $agg = new Filter('foo', new Term(array('color' => 'blue')));
+
+ $expected = array(
+ 'filter' => array(
+ 'term' => array(
+ 'color' => 'blue',
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConstructWithoutFilter()
+ {
+ $agg = new Filter('foo');
+ $this->assertEquals('foo', $agg->getName());
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php
new file mode 100644
index 00000000..36ebcd45
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/FiltersTest.php
@@ -0,0 +1,120 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Avg;
+use Elastica\Aggregation\Filter;
+use Elastica\Aggregation\Filters;
+use Elastica\Document;
+use Elastica\Filter\Term;
+use Elastica\Query;
+
+class FiltersTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex('filter');
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayUsingNamedFilters()
+ {
+ $expected = array(
+ 'filters' => array(
+ 'filters' => array(
+ 'blue' => array(
+ 'term' => array('color' => 'blue'),
+ ),
+ 'red' => array(
+ 'term' => array('color' => 'red'),
+ ),
+ ),
+ ),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
+ );
+
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')), 'blue');
+ $agg->addFilter(new Term(array('color' => 'red')), 'red');
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayUsingAnonymousFilters()
+ {
+ $expected = array(
+ 'filters' => array(
+ 'filters' => array(
+ array(
+ 'term' => array('color' => 'blue'),
+ ),
+ array(
+ 'term' => array('color' => 'red'),
+ ),
+ ),
+ ),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
+ );
+
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')));
+ $agg->addFilter(new Term(array('color' => 'red')));
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFilterAggregation()
+ {
+ $agg = new Filters('by_color');
+ $agg->addFilter(new Term(array('color' => 'blue')), 'blue');
+ $agg->addFilter(new Term(array('color' => 'red')), 'red');
+
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
+ $agg->addAggregation($avg);
+
+ $query = new Query();
+ $query->addAggregation($agg);
+
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('by_color');
+
+ $resultsForBlue = $results['buckets']['blue'];
+ $resultsForRed = $results['buckets']['red'];
+
+ $this->assertEquals(2, $resultsForBlue['doc_count']);
+ $this->assertEquals(1, $resultsForRed['doc_count']);
+
+ $this->assertEquals((5 + 8) / 2, $resultsForBlue['avg_price']['value']);
+ $this->assertEquals(1, $resultsForRed['avg_price']['value']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
index 7fd677b1..f8a02d1d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeoDistanceTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeoDistance;
use Elastica\Document;
use Elastica\Query;
@@ -10,36 +8,39 @@ use Elastica\Type\Mapping;
class GeoDistanceTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("geo_distance");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'location' => array('type' => 'geo_point'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))),
+ new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))),
+ new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))),
- new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))),
- new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testGeoDistanceAggregation()
{
- $agg = new GeoDistance("geo", "location", array("lat" => 32.804654, "lon" => -117.242594));
+ $agg = new GeoDistance('geo', 'location', array('lat' => 32.804654, 'lon' => -117.242594));
$agg->addRange(null, 100);
- $agg->setUnit("mi");
+ $agg->setUnit('mi');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("geo");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('geo');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
index 38a047f7..6e0d43fd 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GeohashGridTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\GeohashGrid;
use Elastica\Document;
use Elastica\Query;
@@ -10,36 +8,39 @@ use Elastica\Type\Mapping;
class GeohashGridTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("geohash_grid");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "location" => array("type" => "geo_point")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'location' => array('type' => 'geo_point'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('location' => array('lat' => 32.849437, 'lon' => -117.271732))),
+ new Document(2, array('location' => array('lat' => 32.798320, 'lon' => -117.246648))),
+ new Document(3, array('location' => array('lat' => 37.782439, 'lon' => -122.392560))),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("location" => array("lat" => 32.849437, "lon" => -117.271732))),
- new Document("2", array("location" => array("lat" => 32.798320, "lon" => -117.246648))),
- new Document("3", array("location" => array("lat" => 37.782439, "lon" => -122.392560))),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testGeohashGridAggregation()
{
- $agg = new GeohashGrid("hash", "location");
+ $agg = new GeohashGrid('hash', 'location');
$agg->setPrecision(3);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hash");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hash');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
$this->assertEquals(1, $results['buckets'][1]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
index 80366f50..6ab086d0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/GlobalAggregationTest.php
@@ -1,27 +1,27 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Avg;
use Elastica\Aggregation\GlobalAggregation;
class GlobalAggregationTest extends BaseAggregationTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "global" => new \stdClass(),
- "aggs" => array(
- "avg_price" => array("avg" => array("field" => "price"))
- )
+ 'global' => new \stdClass(),
+ 'aggs' => array(
+ 'avg_price' => array('avg' => array('field' => 'price')),
+ ),
);
- $agg = new GlobalAggregation("all_products");
- $avg = new Avg("avg_price");
- $avg->setField("price");
+ $agg = new GlobalAggregation('all_products');
+ $avg = new Avg('avg_price');
+ $avg->setField('price');
$agg->addAggregation($avg);
$this->assertEquals($expected, $agg->toArray());
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
index 35032f43..ffdf73a4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/HistogramTest.php
@@ -1,40 +1,43 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
-use Elastica\Document;
use Elastica\Aggregation\Histogram;
+use Elastica\Document;
use Elastica\Query;
class HistogramTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("histogram");
- $docs = array(
- new Document("1", array("price" => 5, "color" => "blue")),
- new Document("2", array("price" => 8, "color" => "blue")),
- new Document("3", array("price" => 1, "color" => "red")),
- new Document("4", array("price" => 30, "color" => "green")),
- new Document("5", array("price" => 40, "color" => "red")),
- new Document("6", array("price" => 35, "color" => "green")),
- new Document("7", array("price" => 42, "color" => "red")),
- new Document("8", array("price" => 41, "color" => "blue")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1, 'color' => 'red')),
+ new Document(4, array('price' => 30, 'color' => 'green')),
+ new Document(5, array('price' => 40, 'color' => 'red')),
+ new Document(6, array('price' => 35, 'color' => 'green')),
+ new Document(7, array('price' => 42, 'color' => 'red')),
+ new Document(8, array('price' => 41, 'color' => 'blue')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testHistogramAggregation()
{
- $agg = new Histogram("hist", "price", 10);
+ $agg = new Histogram('hist', 'price', 10);
$agg->setMinimumDocumentCount(0); // should return empty buckets
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("hist");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('hist');
$buckets = $results['buckets'];
$this->assertEquals(5, sizeof($buckets));
@@ -42,4 +45,3 @@ class HistogramTest extends BaseAggregationTest
$this->assertEquals(2, $buckets[3]['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
index fce6f857..2f3099f6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/IpRangeTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\IpRange;
use Elastica\Document;
use Elastica\Query;
@@ -10,38 +8,42 @@ use Elastica\Type\Mapping;
class IpRangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("ip_range");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "address" => array("type" => "ip")
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'address' => array('type' => 'ip'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('address' => '192.168.1.100')),
+ new Document(2, array('address' => '192.168.1.150')),
+ new Document(3, array('address' => '192.168.1.200')),
));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array("address" => "192.168.1.100")),
- new Document("2", array("address" => "192.168.1.150")),
- new Document("3", array("address" => "192.168.1.200")),
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
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 = 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");
-
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('ip');
+
foreach ($results['buckets'] as $bucket) {
if (array_key_exists('key', $bucket) && $bucket['key'] == $cidrRange) {
// the CIDR mask
@@ -53,4 +55,3 @@ class IpRangeTest extends BaseAggregationTest
}
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
index 0f5475b3..f057b81d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MaxTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Max;
use Elastica\Document;
use Elastica\Query;
@@ -10,63 +8,72 @@ use Elastica\Script;
class MaxTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('max');
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$expected = array(
- "max" => array(
- "field" => "price",
- "script" => "_value * conversion_rate",
- "params" => array(
- "conversion_rate" => 1.2
- )
+ 'max' => array(
+ 'field' => 'price',
+ 'script' => '_value * conversion_rate',
+ 'params' => array(
+ 'conversion_rate' => 1.2,
+ ),
+ ),
+ 'aggs' => array(
+ 'subagg' => array('max' => array('field' => 'foo')),
),
- "aggs" => array(
- "subagg" => array("max" => array("field" => "foo"))
- )
);
- $agg = new Max("min_price_in_euros");
- $agg->setField("price");
- $agg->setScript(new Script("_value * conversion_rate", array('conversion_rate' => 1.2)));
- $max = new Max("subagg");
- $max->setField("foo");
+ $agg = new Max('min_price_in_euros');
+ $agg->setField('price');
+ $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2)));
+ $max = new Max('subagg');
+ $max->setField('foo');
$agg->addAggregation($max);
$this->assertEquals($expected, $agg->toArray());
}
+ /**
+ * @group functional
+ */
public function testMaxAggregation()
{
- $agg = new Max("min_price");
- $agg->setField("price");
+ $index = $this->_getIndexForTest();
+
+ $agg = new Max('min_price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $index->search($query)->getAggregation('min_price');
$this->assertEquals(8, $results['value']);
// test using a script
- $agg->setScript(new Script("_value * conversion_rate", array("conversion_rate" => 1.2)));
+ $agg->setScript(new Script('_value * conversion_rate', array('conversion_rate' => 1.2)));
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $index->search($query)->getAggregation('min_price');
$this->assertEquals(8 * 1.2, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
index 44b52fb4..ce0ad5e7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MinTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Document;
use Elastica\Query;
class MinTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('min');
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testMinAggregation()
{
- $agg = new Min("min_price");
- $agg->setField("price");
+ $agg = new Min('min_price');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("min_price");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('min_price');
$this->assertEquals(1, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
index 2a852ed0..85461879 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/MissingTest.php
@@ -1,37 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Missing;
use Elastica\Document;
use Elastica\Query;
class MissingTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('missing');
- $docs = array(
- new Document('1', array('price' => 5, "color" => "blue")),
- new Document('2', array('price' => 8, "color" => "blue")),
- new Document('3', array('price' => 1)),
- new Document('4', array('price' => 3, "color" => "green")),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5, 'color' => 'blue')),
+ new Document(2, array('price' => 8, 'color' => 'blue')),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3, 'color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testMissingAggregation()
{
- $agg = new Missing("missing", "color");
+ $agg = new Missing('missing', 'color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("missing");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('missing');
$this->assertEquals(1, $results['doc_count']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
index ed6de99e..58c5d13a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/NestedTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Min;
use Elastica\Aggregation\Nested;
use Elastica\Document;
@@ -11,52 +9,55 @@ use Elastica\Type\Mapping;
class NestedTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("nested");
- $mapping = new Mapping();
- $mapping->setProperties(array(
- "resellers" => array(
- "type" => "nested",
- "properties" => array(
- "name" => array("type" => "string"),
- "price" => array("type" => "double")
- )
- )
- ));
- $type = $this->_index->getType("test");
- $type->setMapping($mapping);
- $docs = array(
- new Document("1", array(
- "resellers" => array(
- "name" => "spacely sprockets",
- "price" => 5.55
- )
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'resellers' => array(
+ 'type' => 'nested',
+ 'properties' => array(
+ 'name' => array('type' => 'string'),
+ 'price' => array('type' => 'double'),
+ ),
+ ),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'resellers' => array(
+ 'name' => 'spacely sprockets',
+ 'price' => 5.55,
+ ),
)),
- new Document("1", array(
- "resellers" => array(
- "name" => "cogswell cogs",
- "price" => 4.98
- )
- ))
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+ new Document(2, array(
+ 'resellers' => array(
+ 'name' => 'cogswell cogs',
+ 'price' => 4.98,
+ ),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testNestedAggregation()
{
- $agg = new Nested("resellers", "resellers");
- $min = new Min("min_price");
- $min->setField("price");
+ $agg = new Nested('resellers', 'resellers');
+ $min = new Min('min_price');
+ $min->setField('price');
$agg->addAggregation($min);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("resellers");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('resellers');
$this->assertEquals(4.98, $results['min_price']['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php
new file mode 100644
index 00000000..ee4dd2c5
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/PercentilesTest.php
@@ -0,0 +1,125 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Percentiles;
+use Elastica\Document;
+use Elastica\Query;
+
+class PercentilesTest extends BaseAggregationTest
+{
+ /**
+ * @group functional
+ */
+ public function testConstruct()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $this->assertEquals('price_percentile', $aggr->getName());
+
+ $aggr = new Percentiles('price_percentile', 'price');
+ $this->assertEquals('price', $aggr->getParam('field'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetField()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setField('price');
+
+ $this->assertEquals('price', $aggr->getParam('field'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setField('price'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetCompression()
+ {
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setCompression(200);
+ $this->assertEquals(200, $aggr->getParam('compression'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setCompression(200));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetPercents()
+ {
+ $percents = array(1, 2, 3);
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setPercents($percents);
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setPercents($percents));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAddPercent()
+ {
+ $percents = array(1, 2, 3);
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setPercents($percents);
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $aggr->addPercent(4);
+ $percents[] = 4;
+ $this->assertEquals($percents, $aggr->getParam('percents'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->addPercent(4));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetScript()
+ {
+ $script = 'doc["load_time"].value / 20';
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setScript($script);
+ $this->assertEquals($script, $aggr->getParam('script'));
+ $this->assertInstanceOf('Elastica\Aggregation\Percentiles', $aggr->setScript($script));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testActualWork()
+ {
+ // prepare
+ $index = $this->_createIndex();
+ $type = $index->getType('offer');
+ $type->addDocuments(array(
+ new Document(1, array('price' => 100)),
+ new Document(2, array('price' => 200)),
+ new Document(3, array('price' => 300)),
+ new Document(4, array('price' => 400)),
+ new Document(5, array('price' => 500)),
+ new Document(6, array('price' => 600)),
+ new Document(7, array('price' => 700)),
+ new Document(8, array('price' => 800)),
+ new Document(9, array('price' => 900)),
+ new Document(10, array('price' => 1000)),
+ ));
+ $index->refresh();
+
+ // execute
+ $aggr = new Percentiles('price_percentile');
+ $aggr->setField('price');
+
+ $query = new Query();
+ $query->addAggregation($aggr);
+
+ $resultSet = $type->search($query);
+ $aggrResult = $resultSet->getAggregation('price_percentile');
+
+ // hope it's ok to hardcode results...
+ $this->assertEquals(109.0, $aggrResult['values']['1.0']);
+ $this->assertEquals(145.0, $aggrResult['values']['5.0']);
+ $this->assertEquals(325.0, $aggrResult['values']['25.0']);
+ $this->assertEquals(550.0, $aggrResult['values']['50.0']);
+ $this->assertEquals(775.0, $aggrResult['values']['75.0']);
+ $this->assertEquals(955.0, $aggrResult['values']['95.0']);
+ $this->assertEquals(991.0, $aggrResult['values']['99.0']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
index fb5ca2fe..f96e4096 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/RangeTest.php
@@ -1,41 +1,78 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Range;
use Elastica\Document;
use Elastica\Query;
class RangeTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('range');
- $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)),
- new Document('5', array('price' => 1.5)),
- new Document('6', array('price' => 2)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ new Document(5, array('price' => 1.5)),
+ new Document(6, array('price' => 2)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testRangeAggregation()
{
- $agg = new Range("range");
- $agg->setField("price");
+ $agg = new Range('range');
+ $agg->setField('price');
$agg->addRange(1.5, 5);
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("range");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('range');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
}
+
+ /**
+ * @group unit
+ */
+ public function testRangeAggregationWithKey()
+ {
+ $agg = new Range('range');
+ $agg->setField('price');
+ $agg->addRange(null, 50, 'cheap');
+ $agg->addRange(50, 100, 'average');
+ $agg->addRange(100, null, 'expensive');
+
+ $expected = array(
+ 'range' => array(
+ 'field' => 'price',
+ 'ranges' => array(
+ array(
+ 'to' => 50,
+ 'key' => 'cheap',
+ ),
+ array(
+ 'from' => 50,
+ 'to' => 100,
+ 'key' => 'average',
+ ),
+ array(
+ 'from' => 100,
+ 'key' => 'expensive',
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $agg->toArray());
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
index 215dac63..0e2ed2e6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ReverseNestedTest.php
@@ -1,86 +1,96 @@
<?php
-
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;
class ReverseNestedTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("nested");
+ $index = $this->_createIndex();
$mapping = new Mapping();
$mapping->setProperties(array(
- "comments" => array(
- "type" => "nested",
- "properties" => array(
- "name" => array("type" => "string"),
- "body" => array("type" => "string")
- )
- )
+ 'comments' => array(
+ 'type' => 'nested',
+ 'properties' => array(
+ 'name' => array('type' => 'string'),
+ 'body' => array('type' => 'string'),
+ ),
+ ),
));
- $type = $this->_index->getType("test");
+ $type = $index->getType('test');
$type->setMapping($mapping);
- $docs = array(
- new Document("1", array(
- "comments" => array(
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'comments' => array(
array(
- "name" => "bob",
- "body" => "this is bobs comment",
+ 'name' => 'bob',
+ 'body' => 'this is bobs comment',
),
array(
- "name" => "john",
- "body" => "this is johns comment",
+ 'name' => 'john',
+ 'body' => 'this is johns comment',
),
),
- "tags" => array("foo", "bar"),
+ 'tags' => array('foo', 'bar'),
)),
- new Document("2", array(
- "comments" => array(
+ new Document(2, array(
+ 'comments' => array(
array(
- "name" => "bob",
- "body" => "this is another comment from bob",
+ 'name' => 'bob',
+ 'body' => 'this is another comment from bob',
),
array(
- "name" => "susan",
- "body" => "this is susans comment",
+ 'name' => 'susan',
+ 'body' => 'this is susans comment',
),
),
- "tags" => array("foo", "baz"),
- ))
- );
- $type->addDocuments($docs);
- $this->_index->refresh();
+ 'tags' => array('foo', 'baz'),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testPathNotSetIfNull()
{
$agg = new ReverseNested('nested');
$this->assertFalse($agg->hasParam('path'));
}
+ /**
+ * @group unit
+ */
public function testPathSetIfNotNull()
{
$agg = new ReverseNested('nested', 'some_field');
$this->assertEquals('some_field', $agg->getParam('path'));
}
+ /**
+ * @group functional
+ */
public function testReverseNestedAggregation()
{
- $agg = new Nested("comments", "comments");
- $names = new Terms("name");
- $names->setField("comments.name");
+ $agg = new Nested('comments', 'comments');
+ $names = new Terms('name');
+ $names->setField('comments.name');
- $tags = new Terms("tags");
- $tags->setField("tags");
+ $tags = new Terms('tags');
+ $tags->setField('tags');
- $reverseNested = new ReverseNested("main");
+ $reverseNested = new ReverseNested('main');
$reverseNested->addAggregation($tags);
$names->addAggregation($reverseNested);
@@ -89,7 +99,7 @@ class ReverseNestedTest extends BaseAggregationTest
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("comments");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('comments');
$this->assertArrayHasKey('name', $results);
$nameResults = $results['name'];
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php
new file mode 100644
index 00000000..bf32b251
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptTest.php
@@ -0,0 +1,87 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Sum;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Script;
+
+class ScriptTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document('1', array('price' => 5)),
+ new Document('2', array('price' => 8)),
+ new Document('3', array('price' => 1)),
+ new Document('4', array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ 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->_getIndexForTest()->search($query)->getAggregation('sum');
+
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregationScriptAsString()
+ {
+ $agg = new Sum('sum');
+ $agg->setScript("doc['price'].value");
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
+
+ $this->assertEquals(5 + 8 + 1 + 3, $results['value']);
+ }
+
+ /**
+ * @group unit
+ */
+ 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);
+
+ $array = $agg->toArray();
+
+ $expected = array(
+ $aggregation => array(
+ 'script' => $string,
+ 'params' => $params,
+ 'lang' => $lang,
+ ),
+ );
+ $this->assertEquals($expected, $array);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php
new file mode 100644
index 00000000..31f5798b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ScriptedMetricTest.php
@@ -0,0 +1,50 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\ScriptedMetric;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Type\Mapping;
+
+class ScriptedMetricTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $type->setMapping(new Mapping(null, array(
+ 'start' => array('type' => 'long'),
+ 'end' => array('type' => 'long'),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array('start' => 100, 'end' => 200)),
+ new Document(2, array('start' => 200, 'end' => 250)),
+ new Document(3, array('start' => 300, 'end' => 450)),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ public function testScriptedMetricAggregation()
+ {
+ $agg = new ScriptedMetric(
+ 'scripted',
+ "_agg['durations'] = [:]",
+ "key = doc['start'].value+ \":\"+ doc['end'].value; _agg.durations[key] = doc['end'].value - doc['start'].value;",
+ 'values = []; for (item in _agg.durations) { values.add(item.value) }; return values'
+ );
+
+ $query = new Query();
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('scripted');
+
+ $this->assertEquals(array(100, 50, 150), $results['value'][0]);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php
new file mode 100644
index 00000000..8960768b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SignificantTermsTest.php
@@ -0,0 +1,72 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\SignificantTerms;
+use Elastica\Document;
+use Elastica\Filter\Terms as TermsFilter;
+use Elastica\Query;
+use Elastica\Query\Terms;
+
+class SignificantTermsTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $colors = array('blue', 'blue', 'red', 'red', 'green', 'yellow', 'white', 'cyan', 'magenta');
+ $temperatures = array(1500, 1500, 1500, 1500, 2500, 3500, 4500, 5500, 6500, 7500, 7500, 8500, 9500);
+ $docs = array();
+ for ($i = 0;$i < 250;$i++) {
+ $docs[] = new Document($i, array('color' => $colors[$i % count($colors)], 'temperature' => $temperatures[$i % count($temperatures)]));
+ }
+ $index->getType('test')->addDocuments($docs);
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSignificantTermsAggregation()
+ {
+ $agg = new SignificantTerms('significantTerms');
+ $agg->setField('temperature');
+ $agg->setSize(1);
+
+ $termsQuery = new Terms();
+ $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white'));
+
+ $query = new Query($termsQuery);
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('significantTerms');
+
+ $this->assertEquals(1, count($results['buckets']));
+ $this->assertEquals(63, $results['buckets'][0]['doc_count']);
+ $this->assertEquals(79, $results['buckets'][0]['bg_count']);
+ $this->assertEquals('1500', $results['buckets'][0]['key_as_string']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSignificantTermsAggregationWithBackgroundFilter()
+ {
+ $agg = new SignificantTerms('significantTerms');
+ $agg->setField('temperature');
+ $agg->setSize(1);
+ $termsFilter = new TermsFilter();
+ $termsFilter->setTerms('color', array('blue', 'red', 'green', 'yellow'));
+ $agg->setBackgroundFilter($termsFilter);
+
+ $termsQuery = new Terms();
+ $termsQuery->setTerms('color', array('blue', 'red', 'green', 'yellow', 'white'));
+
+ $query = new Query($termsQuery);
+ $query->addAggregation($agg);
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('significantTerms');
+
+ $this->assertEquals(15, $results['buckets'][0]['doc_count']);
+ $this->assertEquals(12, $results['buckets'][0]['bg_count']);
+ $this->assertEquals('4500', $results['buckets'][0]['key_as_string']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
index 2d315abf..45c9d08c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/StatsTest.php
@@ -1,36 +1,39 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Stats;
use Elastica\Document;
use Elastica\Query;
class StatsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('stats');
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testStatsAggregation()
{
- $agg = new Stats("stats");
- $agg->setField("price");
+ $agg = new Stats('stats');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("stats");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('stats');
$this->assertEquals(4, $results['count']);
$this->assertEquals(1, $results['min']);
@@ -39,4 +42,3 @@ class StatsTest extends BaseAggregationTest
$this->assertEquals((5 + 8 + 1 + 3), $results['sum']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
index 3b3c56a2..b60e6e14 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/SumTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Sum;
use Elastica\Document;
use Elastica\Query;
class SumTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('sum');
- $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();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testSumAggregation()
{
- $agg = new Sum("sum");
- $agg->setField("price");
+ $agg = new Sum('sum');
+ $agg->setField('price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("sum");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('sum');
$this->assertEquals(5 + 8 + 1 + 3, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
index d9f37a20..58eb02c2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TermsTest.php
@@ -1,39 +1,41 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\Terms;
use Elastica\Document;
use Elastica\Query;
class TermsTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex("terms");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "blue")),
- new Document("3", array("color" => "red")),
- new Document("4", array("color" => "green")),
- );
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'blue')),
+ new Document(3, array('color' => 'red')),
+ new Document(4, array('color' => 'green')),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testTermsAggregation()
{
- $agg = new Terms("terms");
- $agg->setField("color");
+ $agg = new Terms('terms');
+ $agg->setField('color');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("terms");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('terms');
$this->assertEquals(2, $results['buckets'][0]['doc_count']);
- $this->assertEquals("blue", $results['buckets'][0]['key']);
+ $this->assertEquals('blue', $results['buckets'][0]['key']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php
new file mode 100644
index 00000000..afe23e27
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/TopHitsTest.php
@@ -0,0 +1,385 @@
+<?php
+namespace Elastica\Test\Aggregation;
+
+use Elastica\Aggregation\Terms;
+use Elastica\Aggregation\TopHits;
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\Query\MatchAll;
+use Elastica\Query\SimpleQueryString;
+use Elastica\Script;
+use Elastica\ScriptFields;
+
+class TopHitsTest extends BaseAggregationTest
+{
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+
+ $index->getType('questions')->addDocuments(array(
+ new Document(1, array(
+ 'tags' => array('linux'),
+ 'last_activity_date' => '2015-01-05',
+ 'title' => 'Question about linux #1',
+ )),
+ new Document(2, array(
+ 'tags' => array('linux'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about linux #2',
+ )),
+ new Document(3, array(
+ 'tags' => array('windows'),
+ 'last_activity_date' => '2015-01-05',
+ 'title' => 'Question about windows #1',
+ )),
+ new Document(4, array(
+ 'tags' => array('windows'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about windows #2',
+ )),
+ new Document(5, array(
+ 'tags' => array('osx', 'apple'),
+ 'last_activity_date' => '2014-12-23',
+ 'title' => 'Question about osx',
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSize()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSize(12);
+ $this->assertEquals(12, $agg->getParam('size'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFrom()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setFrom(12);
+ $this->assertEquals(12, $agg->getParam('from'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSort()
+ {
+ $sort = array('last_activity_date' => array('order' => 'desc'));
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSort($sort);
+ $this->assertEquals($sort, $agg->getParam('sort'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSource()
+ {
+ $fields = array('title', 'tags');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setSource($fields);
+ $this->assertEquals($fields, $agg->getParam('_source'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetVersion()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setVersion(true);
+ $this->assertTrue($agg->getParam('version'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+
+ $agg->setVersion(false);
+ $this->assertFalse($agg->getParam('version'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExplain()
+ {
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setExplain(true);
+ $this->assertTrue($agg->getParam('explain'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+
+ $agg->setExplain(false);
+ $this->assertFalse($agg->getParam('explain'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetHighlight()
+ {
+ $highlight = array(
+ 'fields' => array(
+ 'title',
+ ),
+ );
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setHighlight($highlight);
+ $this->assertEquals($highlight, $agg->getParam('highlight'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFieldDataFields()
+ {
+ $fields = array('title', 'tags');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setFieldDataFields($fields);
+ $this->assertEquals($fields, $agg->getParam('fielddata_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScriptFields()
+ {
+ $script = new Script('1 + 2');
+ $scriptFields = new ScriptFields(array('three' => $script));
+
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->setScriptFields($scriptFields);
+ $this->assertEquals($scriptFields->toArray(), $agg->getParam('script_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddScriptField()
+ {
+ $script = new Script('2+3');
+ $agg = new TopHits('agg_name');
+ $returnValue = $agg->addScriptField('five', $script);
+ $this->assertEquals(array('five' => $script->toArray()), $agg->getParam('script_fields'));
+ $this->assertInstanceOf('Elastica\Aggregation\TopHits', $returnValue);
+ }
+
+ protected function getOuterAggregationResult($innerAggr)
+ {
+ $outerAggr = new Terms('top_tags');
+ $outerAggr->setField('tags');
+ $outerAggr->setMinimumDocumentCount(2);
+ $outerAggr->addAggregation($innerAggr);
+
+ $query = new Query(new MatchAll());
+ $query->addAggregation($outerAggr);
+
+ return $this->_getIndexForTest()->search($query)->getAggregation('top_tags');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateUpdatedRecently()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'desc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(1, 3), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateUpdatedFarAgo()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'asc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(2, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateTwoDocumentPerTag()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(2);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(1, 2, 3, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateTwoDocumentPerTagWithOffset()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(2);
+ $aggr->setFrom(1);
+ $aggr->setSort(array('last_activity_date' => array('order' => 'desc')));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $resultDocs[] = $doc['_id'];
+ }
+ }
+ $this->assertEquals(array(2, 4), $resultDocs);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithLimitedSource()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSource(array('title'));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('title', $doc['_source']);
+ $this->assertArrayNotHasKey('tags', $doc['_source']);
+ $this->assertArrayNotHasKey('last_activity_date', $doc['_source']);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithVersion()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setVersion(true);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('_version', $doc);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithExplain()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setExplain(true);
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('_explanation', $doc);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithScriptFields()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setSize(1);
+ $aggr->setScriptFields(array('three' => new Script('1 + 2')));
+ $aggr->addScriptField('five', new Script('3 + 2'));
+
+ $resultDocs = array();
+ $outerAggrResult = $this->getOuterAggregationResult($aggr);
+ foreach ($outerAggrResult['buckets'] as $bucket) {
+ foreach ($bucket['top_tag_hits']['hits']['hits'] as $doc) {
+ $this->assertEquals(3, $doc['fields']['three'][0]);
+ $this->assertEquals(5, $doc['fields']['five'][0]);
+ }
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithHighlight()
+ {
+ $queryString = new SimpleQueryString('linux', array('title'));
+
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setHighlight(array('fields' => array('title' => new \stdClass())));
+
+ $query = new Query($queryString);
+ $query->addAggregation($aggr);
+
+ $resultSet = $this->_getIndexForTest()->search($query);
+ $aggrResult = $resultSet->getAggregation('top_tag_hits');
+
+ foreach ($aggrResult['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('highlight', $doc);
+ $this->assertRegExp('#<em>linux</em>#', $doc['highlight']['title'][0]);
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testAggregateWithFieldData()
+ {
+ $aggr = new TopHits('top_tag_hits');
+ $aggr->setFieldDataFields(array('title'));
+
+ $query = new Query(new MatchAll());
+ $query->addAggregation($aggr);
+
+ $resultSet = $this->_getIndexForTest()->search($query);
+ $aggrResult = $resultSet->getAggregation('top_tag_hits');
+
+ foreach ($aggrResult['hits']['hits'] as $doc) {
+ $this->assertArrayHasKey('fields', $doc);
+ $this->assertArrayHasKey('title', $doc['fields']);
+ $this->assertArrayNotHasKey('tags', $doc['fields']);
+ $this->assertArrayNotHasKey('last_activity_date', $doc['fields']);
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
index 5eba9ea4..21b63cbe 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Aggregation/ValueCountTest.php
@@ -1,38 +1,40 @@
<?php
-
namespace Elastica\Test\Aggregation;
-
use Elastica\Aggregation\ValueCount;
use Elastica\Document;
use Elastica\Query;
class ValueCountTest extends BaseAggregationTest
{
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('value_count');
- $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)),
- new Document('5', array('price' => 3)),
- );
- $this->_index->getType('test')->addDocuments($docs);
- $this->_index->refresh();
+ $index = $this->_createIndex();
+
+ $index->getType('test')->addDocuments(array(
+ new Document(1, array('price' => 5)),
+ new Document(2, array('price' => 8)),
+ new Document(3, array('price' => 1)),
+ new Document(4, array('price' => 3)),
+ new Document(5, array('price' => 3)),
+ ));
+
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group functional
+ */
public function testValueCountAggregation()
{
- $agg = new ValueCount("count", "price");
+ $agg = new ValueCount('count', 'price');
$query = new Query();
$query->addAggregation($agg);
- $results = $this->_index->search($query)->getAggregation("count");
+ $results = $this->_getIndexForTest()->search($query)->getAggregation('count');
$this->assertEquals(5, $results['value']);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
index 55cd8873..c826c747 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Base.php
@@ -1,31 +1,142 @@
<?php
-
namespace Elastica\Test;
use Elastica\Client;
+use Elastica\Connection;
+use Elastica\Index;
class Base extends \PHPUnit_Framework_TestCase
{
- protected function _getClient()
+ /**
+ * @param array $params Additional configuration params. Host and Port are already set
+ * @param callback $callback
+ *
+ * @return Client
+ */
+ protected function _getClient(array $params = array(), $callback = null)
+ {
+ $config = array(
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
+ );
+
+ $config = array_merge($config, $params);
+
+ return new Client($config, $callback);
+ }
+
+ /**
+ * @return string Host to es for elastica tests
+ */
+ protected function _getHost()
+ {
+ return getenv('ES_HOST') ?: Connection::DEFAULT_HOST;
+ }
+
+ /**
+ * @return int Port to es for elastica tests
+ */
+ protected function _getPort()
+ {
+ return getenv('ES_PORT') ?: Connection::DEFAULT_PORT;
+ }
+
+ /**
+ * @return string Proxy url string
+ */
+ protected function _getProxyUrl()
+ {
+ $proxyHost = getenv('PROXY_HOST') ?: Connection::DEFAULT_HOST;
+
+ return 'http://'.$proxyHost.':12345';
+ }
+
+ /**
+ * @return string Proxy url string to proxy which returns 403
+ */
+ protected function _getProxyUrl403()
{
- return new Client(array(
- 'host' => getenv('ES_HOST') ?: 'localhost',
- 'port' => getenv('ES_PORT') ?: 9200,
- ));
+ $proxyHost = getenv('PROXY_HOST') ?: Connection::DEFAULT_HOST;
+
+ return 'http://'.$proxyHost.':12346';
}
/**
- * @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)
+ protected function _createIndex($name = null, $delete = true, $shards = 1)
{
+ if (is_null($name)) {
+ $name = preg_replace('/[^a-z]/i', '', strtolower(get_called_class())).uniqid();
+ }
+
$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;
}
+
+ protected function _waitForAllocation(Index $index)
+ {
+ do {
+ $settings = $index->getStatus()->get();
+ $allocated = true;
+ foreach ($settings['shards'] as $shard) {
+ if ($shard[0]['routing']['state'] != 'STARTED') {
+ $allocated = false;
+ }
+ }
+ } while (!$allocated);
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $hasGroup = $this->_isUnitGroup() || $this->_isFunctionalGroup() || $this->_isShutdownGroup() || $this->_isBenchmarkGroup();
+ $this->assertTrue($hasGroup, 'Every test must have one of "unit", "functional", "shutdown" or "benchmark" group');
+ }
+
+ protected function tearDown()
+ {
+ if ($this->_isFunctionalGroup()) {
+ $this->_getClient()->getIndex('_all')->delete();
+ $this->_getClient()->getIndex('_all')->clearCache();
+ }
+
+ parent::tearDown();
+ }
+
+ protected function _isUnitGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('unit', $groups);
+ }
+
+ protected function _isFunctionalGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('functional', $groups);
+ }
+
+ protected function _isShutdownGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('shutdown', $groups);
+ }
+
+ protected function _isBenchmarkGroup()
+ {
+ $groups = \PHPUnit_Util_Test::getGroups(get_class($this), $this->getName(false));
+
+ return in_array('benchmark', $groups);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
index 178883a8..e4588e70 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ActionTest.php
@@ -1,64 +1,61 @@
<?php
-
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
{
+ /**
+ * @group unit
+ */
public function testAction()
{
$action = new Action();
$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();
+ $client = $this->_getClient();
$index = new Index($client, 'index2');
$type = new Type($index, 'type2');
$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/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
index d1495fce..949dcf7a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Bulk/ResponseSetTest.php
@@ -1,17 +1,16 @@
<?php
-
namespace Elastica\Test\Bulk;
-use Elastica\Bulk\Action;
use Elastica\Bulk;
+use Elastica\Bulk\Action;
use Elastica\Exception\Bulk\ResponseException;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Bulk\ResponseSet;
use Elastica\Response;
+use Elastica\Test\Base as BaseTest;
class ResponseSetTest extends BaseTest
{
/**
+ * @group unit
* @dataProvider isOkDataProvider
*/
public function testIsOk($responseData, $actions, $expected)
@@ -20,6 +19,9 @@ class ResponseSetTest extends BaseTest
$this->assertEquals($expected, $responseSet->isOk());
}
+ /**
+ * @group unit
+ */
public function testGetError()
{
list($responseData, $actions) = $this->_getFixture();
@@ -55,6 +57,9 @@ class ResponseSetTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testGetBulkResponses()
{
list($responseData, $actions) = $this->_getFixture();
@@ -76,6 +81,9 @@ class ResponseSetTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testIterator()
{
list($responseData, $actions) = $this->_getFixture();
@@ -119,12 +127,14 @@ class ResponseSetTest extends BaseTest
$return[] = array($responseData, $actions, true);
$responseData['items'][2]['index']['ok'] = false;
$return[] = array($responseData, $actions, false);
+
return $return;
}
/**
* @param array $responseData
* @param array $actions
+ *
* @return \Elastica\Bulk\ResponseSet
*/
protected function _createResponseSet(array $responseData, array $actions)
@@ -138,6 +148,7 @@ class ResponseSetTest extends BaseTest
$bulk = new Bulk($client);
$bulk->addActions($actions);
+
return $bulk->send();
}
@@ -156,7 +167,7 @@ class ResponseSetTest extends BaseTest
'_id' => '1',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -165,7 +176,7 @@ class ResponseSetTest extends BaseTest
'_id' => '2',
'_version' => 1,
'ok' => true,
- )
+ ),
),
array(
'index' => array(
@@ -174,15 +185,16 @@ class ResponseSetTest extends BaseTest
'_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/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
index 3396fe86..c3ff15bc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/BulkTest.php
@@ -1,24 +1,24 @@
<?php
-
namespace Elastica\Test;
use Elastica\Bulk;
use Elastica\Bulk\Action;
-use Elastica\Client;
+use Elastica\Bulk\Action\AbstractDocument;
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
{
-
+ /**
+ * @group functional
+ */
public function testSend()
{
$index = $this->_createIndex();
+ $indexName = $index->getName();
$type = $index->getType('bulk_test');
$type2 = $index->getType('bulk_test2');
$client = $index->getClient();
@@ -28,14 +28,13 @@ class BulkTest extends BaseTest
$newDocument3 = $type->createDocument(3, array('name' => 'The Human Torch'));
$newDocument4 = $type->createDocument(null, array('name' => 'The Thing'));
- $newDocument1->setPercolate('*');
$newDocument3->setOpType(Document::OP_TYPE_CREATE);
$documents = array(
$newDocument1,
$newDocument2,
$newDocument3,
- $newDocument4
+ $newDocument4,
);
$bulk = new Bulk($client);
@@ -63,29 +62,29 @@ class BulkTest extends BaseTest
$data = $bulk->toArray();
$expected = array(
- array('index' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 1, '_percolate' => '*')),
+ array('index' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 1)),
array('name' => 'Mister Fantastic'),
array('index' => array('_id' => 2)),
array('name' => 'Invisible Woman'),
- array('create' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 3)),
+ array('create' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)),
array('name' => 'The Human Torch'),
- array('index' => array('_index' => 'elastica_test', '_type' => 'bulk_test')),
+ array('index' => array('_index' => $indexName, '_type' => 'bulk_test')),
array('name' => 'The Thing'),
);
$this->assertEquals($expected, $data);
- $expected = '{"index":{"_index":"elastica_test","_type":"bulk_test","_id":1,"_percolate":"*"}}
+ $expected = '{"index":{"_index":"'.$indexName.'","_type":"bulk_test","_id":1}}
{"name":"Mister Fantastic"}
{"index":{"_id":2}}
{"name":"Invisible Woman"}
-{"create":{"_index":"elastica_test","_type":"bulk_test","_id":3}}
+{"create":{"_index":"'.$indexName.'","_type":"bulk_test","_id":3}}
{"name":"The Human Torch"}
-{"index":{"_index":"elastica_test","_type":"bulk_test"}}
+{"index":{"_index":"'.$indexName.'","_type":"bulk_test"}}
{"name":"The Thing"}
';
$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,14 +106,13 @@ class BulkTest extends BaseTest
$this->assertEquals(3, $type->count());
$this->assertEquals(1, $type2->count());
-
$bulk = new Bulk($client);
$bulk->addDocument($newDocument3, Action::OP_TYPE_DELETE);
$data = $bulk->toArray();
$expected = array(
- array('delete' => array('_index' => 'elastica_test', '_type' => 'bulk_test', '_id' => 3)),
+ array('delete' => array('_index' => $indexName, '_type' => 'bulk_test', '_id' => 3)),
);
$this->assertEquals($expected, $data);
@@ -132,6 +130,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testUnicodeBulkSend()
{
$index = $this->_createIndex();
@@ -146,7 +147,7 @@ class BulkTest extends BaseTest
$documents = array(
$newDocument1,
$newDocument2,
- $newDocument3
+ $newDocument3,
);
$bulk = new Bulk($client);
@@ -160,9 +161,12 @@ class BulkTest extends BaseTest
$this->assertSame($newDocument3, $actions[2]->getDocument());
}
+ /**
+ * @group functional
+ */
public function testSetIndexType()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('index');
$type = $index->getType('type');
@@ -198,9 +202,12 @@ class BulkTest extends BaseTest
$this->assertEquals('type', $bulk->getType());
}
+ /**
+ * @group unit
+ */
public function testAddActions()
{
- $client = new Client();
+ $client = $this->_getClient();
$bulk = new Bulk($client);
$action1 = new Action(Action::OP_TYPE_DELETE);
@@ -216,7 +223,7 @@ class BulkTest extends BaseTest
$actions = array(
$action1,
- $action2
+ $action2,
);
$bulk->addActions($actions);
@@ -227,6 +234,9 @@ class BulkTest extends BaseTest
$this->assertSame($action2, $getActions[1]);
}
+ /**
+ * @group unit
+ */
public function testAddRawData()
{
$bulk = new Bulk($this->_getClient());
@@ -277,6 +287,7 @@ class BulkTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider invalidRawDataProvider
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -298,7 +309,7 @@ class BulkTest extends BaseTest
array('user' => array('name' => 'hans')),
array('user' => array('name' => 'mans')),
),
- 'Two sources for one action'
+ 'Two sources for one action',
),
array(
array(
@@ -306,29 +317,32 @@ class BulkTest extends BaseTest
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',
+ ),
);
}
+ /**
+ * @group unit
+ */
public function testCreateAbstractDocumentWithInvalidData()
{
//Wrong class type
@@ -350,6 +364,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testErrorRequest()
{
$index = $this->_createIndex();
@@ -379,6 +396,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testRawDocumentDataRequest()
{
$index = $this->_createIndex();
@@ -413,13 +433,14 @@ class BulkTest extends BaseTest
$response = $type->search();
$this->assertEquals(3, $response->count());
- foreach (array("Mister", "Invisible", "Torch") as $name) {
+ foreach (array('Mister', 'Invisible', 'Torch') as $name) {
$result = $type->search($name);
$this->assertEquals(1, count($result->getResults()));
}
}
/**
+ * @group functional
* @dataProvider udpDataProvider
*/
public function testUdp($clientConfig, $host, $port, $shouldFail = false)
@@ -427,7 +448,7 @@ class BulkTest extends BaseTest
if (!function_exists('socket_create')) {
$this->markTestSkipped('Function socket_create() does not exist.');
}
- $client = new Client($clientConfig);
+ $client = $this->_getClient($clientConfig);
$index = $client->getIndex('elastica_test');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
$type = $index->getType('udp_test');
@@ -467,6 +488,9 @@ class BulkTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testUpdate()
{
$index = $this->_createIndex();
@@ -599,6 +623,9 @@ class BulkTest extends BaseTest
$index->delete();
}
+ /**
+ * @group unit
+ */
public function testGetPath()
{
$client = $this->_getClient();
@@ -609,13 +636,16 @@ class BulkTest extends BaseTest
$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());
}
+ /**
+ * @group functional
+ */
public function testRetry()
{
$index = $this->_createIndex();
@@ -634,7 +664,7 @@ class BulkTest extends BaseTest
$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);
@@ -646,65 +676,116 @@ class BulkTest extends BaseTest
$this->assertEquals(5, $metadata[ '_retry_on_conflict' ]);
}
+ /**
+ * @group unit
+ */
+ public function testSetShardTimeout()
+ {
+ $bulk = new Bulk($this->_getClient());
+ $this->assertInstanceOf('Elastica\Bulk', $bulk->setShardTimeout(10));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetRequestParam()
+ {
+ $bulk = new Bulk($this->_getClient());
+ $this->assertInstanceOf('Elastica\Bulk', $bulk->setRequestParam('key', 'value'));
+ }
+
+ /**
+ * @group benchmark
+ */
+ public function testMemoryUsage()
+ {
+ $type = $this->_createIndex()->getType('test');
+
+ $data = array(
+ 'text1' => 'Very long text for a string',
+ 'text2' => 'But this is not very long',
+ 'text3' => 'random or not random?',
+ );
+
+ $startMemory = memory_get_usage();
+
+ for ($n = 1; $n < 10; $n++) {
+ $docs = array();
+
+ for ($i = 1; $i <= 3000; $i++) {
+ $docs[] = new Document(uniqid(), $data);
+ }
+
+ $type->addDocuments($docs);
+ $docs = array();
+ }
+
+ unset($docs);
+
+ $endMemory = memory_get_usage();
+
+ $this->assertLessThan(1.3, $endMemory / $startMemory);
+ }
+
public function udpDataProvider()
{
return array(
array(
array(),
null,
- null
+ null,
),
array(
array(),
- 'localhost',
- null
+ $this->_getHost(),
+ null,
),
array(
array(),
null,
- 9700
+ 9700,
),
array(
array(),
- 'localhost',
- 9700
+ $this->_getHost(),
+ 9700,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9700,
- )
+ ),
),
null,
- null
+ null,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9800,
- )
+ ),
),
- 'localhost',
- 9700
+ $this->_getHost(),
+ 9700,
),
array(
array(
'udp' => array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9800,
- )
+ ),
),
null,
null,
- true
+ true,
),
array(
array(),
- 'localhost',
+ $this->_getHost(),
9800,
- true
+ true,
),
);
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
index 94ee2ead..a5f2b46f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClientTest.php
@@ -1,31 +1,34 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Connection;
use Elastica\Document;
-use Elastica\Exception\ClientException;
use Elastica\Exception\Connection\HttpException;
-use Elastica\Script;
+use Elastica\Exception\InvalidException;
use Elastica\Index;
use Elastica\Request;
+use Elastica\Script;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
class ClientTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
$this->assertCount(1, $client->getConnections());
}
+ /**
+ * @group functional
+ */
public function testConnectionsArray()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client(array('connections' => array(array('host' => 'localhost', 'port' => 9200))));
+ $client = $this->_getClient(array('connections' => array(array('host' => $this->_getHost(), 'port' => 9200))));
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -53,12 +56,15 @@ class ClientTest extends BaseTest
$resultSet = $type->search('rolf');
}
+ /**
+ * @group functional
+ */
public function testTwoServersSame()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client(array('connections' => array(
- array('host' => 'localhost', 'port' => 9200),
- array('host' => 'localhost', 'port' => 9200),
+ $client = $this->_getClient(array('connections' => array(
+ array('host' => $this->_getHost(), 'port' => 9200),
+ array('host' => $this->_getHost(), 'port' => 9200),
)));
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -67,17 +73,17 @@ class ClientTest extends BaseTest
// Adds 1 document to the index
$doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
+ array('username' => 'hans', 'test' => array('2', '3', '5'))
);
$type->addDocument($doc1);
// Adds a list of documents with _bulk upload to the index
$docs = array();
$docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
+ array('username' => 'john', 'test' => array('1', '3', '6'))
);
$docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
+ array('username' => 'rolf', 'test' => array('2', '3', '7'))
);
$type->addDocuments($docs);
@@ -87,30 +93,45 @@ class ClientTest extends BaseTest
$resultSet = $type->search('rolf');
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForConnectionsOption()
{
- $client = new Client(array('connections' => array(array('url' => 'https://localhost:9200'))));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('connections' => array(array('url' => $url))));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForServersOption()
{
- $client = new Client(array('servers' => array(array('url' => 'https://localhost:9200'))));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('servers' => array(array('url' => $url))));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testConnectionParamsArePreparedForDefaultOptions()
{
- $client = new Client(array('url' => 'https://localhost:9200'));
+ $url = 'https://'.$this->_getHost().':9200';
+ $client = $this->_getClient(array('url' => $url));
$connection = $client->getConnection();
- $this->assertEquals('https://localhost:9200', $connection->getConfig('url'));
+ $this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group functional
+ */
public function testBulk()
{
$client = $this->_getClient();
@@ -125,6 +146,9 @@ class ClientTest extends BaseTest
$client->bulk($params);
}
+ /**
+ * @group functional
+ */
public function testOptimizeAll()
{
$client = $this->_getClient();
@@ -134,6 +158,7 @@ class ClientTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddDocumentsEmpty()
@@ -143,7 +168,9 @@ class ClientTest extends BaseTest
}
/**
- * Test bulk operations on Index
+ * Test bulk operations on Index.
+ *
+ * @group functional
*/
public function testBulkIndex()
{
@@ -159,7 +186,7 @@ class ClientTest extends BaseTest
$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'));
@@ -174,7 +201,9 @@ class ClientTest extends BaseTest
}
/**
- * Test bulk operations on Type
+ * Test bulk operations on Type.
+ *
+ * @group functional
*/
public function testBulkType()
{
@@ -190,7 +219,7 @@ class ClientTest extends BaseTest
$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'));
@@ -204,6 +233,9 @@ class ClientTest extends BaseTest
$type->getDocument(2);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocuments()
{
$indexName = 'test';
@@ -243,27 +275,29 @@ class ClientTest extends BaseTest
}
/**
- * 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
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxStringTypeString()
{
$data = array('username' => 'hans');
$userSearch = 'username:hans';
- $index = $this->_createIndex('test', true, 2);
+ $index = $this->_createIndex(null, true, 2);
// Create the index, deleting it first if it already exists
$index->create(array(), true);
@@ -289,8 +323,8 @@ class ClientTest extends BaseTest
// 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 +352,24 @@ class ClientTest extends BaseTest
}
/**
- * 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
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxStringTypeObject()
{
$data = array('username' => 'hans');
@@ -363,8 +399,8 @@ class ClientTest extends BaseTest
// 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 +416,24 @@ class ClientTest extends BaseTest
}
/**
- * 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
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxObjectTypeString()
{
$data = array('username' => 'hans');
@@ -425,8 +463,8 @@ class ClientTest extends BaseTest
// 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 +480,24 @@ class ClientTest extends BaseTest
}
/**
- * 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
+ *
+ * @group functional
+ */
public function testDeleteIdsIdxObjectTypeObject()
{
$data = array('username' => 'hans');
@@ -486,8 +526,8 @@ class ClientTest extends BaseTest
// 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
@@ -502,13 +542,16 @@ class ClientTest extends BaseTest
$this->assertEquals(0, $totalHits);
}
+ /**
+ * @group functional
+ */
public function testOneInvalidConnection()
{
$client = $this->_getClient();
// First connection work, second should not work
- $connection1 = new Connection(array('port' => '9100', 'timeout' => 2));
- $connection2 = new Connection(array('port' => '9200', 'timeout' => 2));
+ $connection1 = new Connection(array('port' => '9100', 'timeout' => 2, 'host' => $this->_getHost()));
+ $connection2 = new Connection(array('port' => '9200', 'timeout' => 2, 'host' => $this->_getHost()));
$client->setConnections(array($connection1, $connection2));
@@ -523,6 +566,9 @@ class ClientTest extends BaseTest
$this->assertTrue($connections[0]->isEnabled() == false || $connections[1]->isEnabled() == false);
}
+ /**
+ * @group functional
+ */
public function testTwoInvalidConnection()
{
$client = $this->_getClient();
@@ -537,7 +583,6 @@ class ClientTest extends BaseTest
$client->request('_status', Request::GET);
$this->fail('Should throw exception as no connection valid');
} catch (HttpException $e) {
- $this->assertTrue(true);
}
$connections = $client->getConnections();
@@ -550,7 +595,9 @@ class ClientTest extends BaseTest
}
/**
- * Tests if the callback works in case a connection is down
+ * Tests if the callback works in case a connection is down.
+ *
+ * @group functional
*/
public function testCallback()
{
@@ -558,7 +605,7 @@ class ClientTest extends BaseTest
$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);
@@ -566,7 +613,7 @@ class ClientTest extends BaseTest
$count++;
};
- $client = new Client(array(), $callback);
+ $client = $this->_getClient(array(), $callback);
// First connection work, second should not work
$connection1 = new Connection(array('port' => '9101', 'timeout' => 2));
@@ -587,17 +634,23 @@ class ClientTest extends BaseTest
$this->assertEquals(2, $count);
}
+ /**
+ * @group functional
+ */
public function testUrlConstructor()
{
- $url = 'http://localhost:9200/';
+ $url = 'http://'.$this->_getHost().':9200/';
// Url should overwrite invalid host
- $client = new Client(array('url' => $url, 'port' => '9101', 'timeout' => 2));
+ $client = $this->_getClient(array('url' => $url, 'port' => '9101', 'timeout' => 2));
$response = $client->request('_status');
$this->assertInstanceOf('Elastica\Response', $response);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByDocument()
{
$index = $this->_createIndex();
@@ -622,6 +675,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value3added', $data['field3']);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByScript()
{
$index = $this->_createIndex();
@@ -647,6 +703,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field3', $data);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByScriptWithUpsert()
{
$index = $this->_createIndex();
@@ -689,6 +748,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field3', $data);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByRawData()
{
$index = $this->_createIndex();
@@ -701,7 +763,7 @@ class ClientTest extends BaseTest
$rawData = array(
'doc' => array(
'field2' => 'value2',
- )
+ ),
);
$response = $client->updateDocument(1, $rawData, $index->getName(), $type->getName(), array('retry_on_conflict' => 1));
@@ -717,6 +779,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentByDocumentWithUpsert()
{
$index = $this->_createIndex();
@@ -748,6 +813,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2updated', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testDocAsUpsert()
{
$index = $this->_createIndex();
@@ -775,6 +843,9 @@ class ClientTest extends BaseTest
$this->assertEquals('value2', $data['field2']);
}
+ /**
+ * @group functional
+ */
public function testUpdateWithInvalidType()
{
$index = $this->_createIndex();
@@ -792,6 +863,9 @@ class ClientTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testDeleteDocuments()
{
$index = $this->_createIndex();
@@ -834,9 +908,12 @@ class ClientTest extends BaseTest
$this->assertEquals(1, $type->count());
}
+ /**
+ * @group functional
+ */
public function testLastRequestResponse()
{
- $client = new Client();
+ $client = $this->_getClient();
$response = $client->request('_status');
$this->assertInstanceOf('Elastica\Response', $response);
@@ -851,6 +928,9 @@ class ClientTest extends BaseTest
$this->assertSame($response, $lastResponse);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentPopulateFields()
{
$index = $this->_createIndex();
@@ -907,6 +987,9 @@ class ClientTest extends BaseTest
$this->assertArrayNotHasKey('field4', $data);
}
+ /**
+ * @group functional
+ */
public function testAddDocumentsWithoutIds()
{
$docs = array();
@@ -933,6 +1016,9 @@ class ClientTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testConfigValue()
{
$config = array(
@@ -940,11 +1026,11 @@ class ClientTest extends BaseTest
'level2' => array(
'level3' => 'value3',
),
- 'level21' => 'value21'
+ 'level21' => 'value21',
),
- 'level11' => 'value11'
+ 'level11' => 'value11',
);
- $client = new Client($config);
+ $client = $this->_getClient($config);
$this->assertNull($client->getConfigValue('level12'));
$this->assertFalse($client->getConfigValue('level12', false));
@@ -958,51 +1044,117 @@ class ClientTest extends BaseTest
$this->assertEquals('value3', $client->getConfigValue(array('level1', 'level2', 'level3')));
$this->assertInternalType('array', $client->getConfigValue(array('level1', 'level2')));
}
-
-
+
+ /**
+ * @group functional
+ */
public function testArrayQuery()
{
- $client = new Client();
-
+ $client = $this->_getClient();
+
$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']);
}
-
+
+ /**
+ * @group functional
+ */
public function testJSONQuery()
{
- $client = new Client();
-
+ $client = $this->_getClient();
+
$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']);
}
+
+ /**
+ * @group unit
+ */
+ public function testAddHeader()
+ {
+ $client = $this->_getClient();
+
+ // add one header
+ $client->addHeader('foo', 'bar');
+ $this->assertEquals(array('foo' => 'bar'), $client->getConfigValue('headers'));
+
+ // check class
+ $this->assertInstanceOf('Elastica\Client', $client->addHeader('foo', 'bar'));
+
+ // check invalid parameters
+ try {
+ $client->addHeader(new \stdClass(), 'foo');
+ $this->fail('Header name is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+
+ try {
+ $client->addHeader('foo', new \stdClass());
+ $this->fail('Header value is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+ }
+
+ /**
+ * @group unit
+ */
+ public function testRemoveHeader()
+ {
+ $client = $this->_getClient();
+
+ // set headers
+ $headers = array(
+ 'first' => 'first value',
+ 'second' => 'second value',
+ );
+ foreach ($headers as $key => $value) {
+ $client->addHeader($key, $value);
+ }
+ $this->assertEquals($headers, $client->getConfigValue('headers'));
+
+ // remove one
+ $client->removeHeader('first');
+ unset($headers['first']);
+ $this->assertEquals($headers, $client->getConfigValue('headers'));
+
+ // check class
+ $this->assertInstanceOf('Elastica\Client', $client->removeHeader('second'));
+
+ // check invalid parameter
+ try {
+ $client->removeHeader(new \stdClass());
+ $this->fail('Header name is not a string but exception not thrown');
+ } catch (InvalidException $ex) {
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
index 085ac13a..00a121fc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster\Health;
use Elastica\Cluster\Health\Index as HealthIndex;
@@ -14,91 +13,123 @@ class IndexTest extends BaseTest
public function setUp()
{
+ parent::setUp();
+
$data = array(
- "status" => "yellow",
- "number_of_shards" => 1,
- "number_of_replicas" => 2,
- "active_primary_shards" => 3,
- "active_shards" => 4,
- "relocating_shards" => 5,
- "initializing_shards" => 6,
- "unassigned_shards" => 7,
- "shards" => array(
- "0" => array(
- "status" => "yellow",
- "primary_active" => false,
- "active_shards" => 0,
- "relocating_shards" => 1,
- "initializing_shards" => 0,
- "unassigned_shards" => 1
+ 'status' => 'yellow',
+ 'number_of_shards' => 1,
+ 'number_of_replicas' => 2,
+ 'active_primary_shards' => 3,
+ 'active_shards' => 4,
+ 'relocating_shards' => 5,
+ 'initializing_shards' => 6,
+ 'unassigned_shards' => 7,
+ 'shards' => array(
+ '0' => array(
+ 'status' => 'yellow',
+ 'primary_active' => false,
+ 'active_shards' => 0,
+ 'relocating_shards' => 1,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 1,
),
- "1" => array(
- "status" => "yellow",
- "primary_active" => true,
- "active_shards" => 1,
- "relocating_shards" => 0,
- "initializing_shards" => 0,
- "unassigned_shards" => 1
+ '1' => array(
+ 'status' => 'yellow',
+ 'primary_active' => true,
+ 'active_shards' => 1,
+ 'relocating_shards' => 0,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 1,
),
- "2" => array(
- "status" => "green",
- "primary_active" => true,
- "active_shards" => 1,
- "relocating_shards" => 0,
- "initializing_shards" => 0,
- "unassigned_shards" => 0,
+ '2' => array(
+ 'status' => 'green',
+ 'primary_active' => true,
+ 'active_shards' => 1,
+ 'relocating_shards' => 0,
+ 'initializing_shards' => 0,
+ 'unassigned_shards' => 0,
),
- )
+ ),
);
$this->_index = new HealthIndex('test', $data);
}
+ /**
+ * @group unit
+ */
public function testGetName()
{
$this->assertEquals('test', $this->_index->getName());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('yellow', $this->_index->getStatus());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfShards()
{
$this->assertEquals(1, $this->_index->getNumberOfShards());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfReplicas()
{
$this->assertEquals(2, $this->_index->getNumberOfReplicas());
}
+ /**
+ * @group unit
+ */
public function testGetActivePrimaryShards()
{
$this->assertEquals(3, $this->_index->getActivePrimaryShards());
}
+ /**
+ * @group unit
+ */
public function testGetActiveShards()
{
$this->assertEquals(4, $this->_index->getActiveShards());
}
+ /**
+ * @group unit
+ */
public function testGetRelocatingShards()
{
$this->assertEquals(5, $this->_index->getRelocatingShards());
}
+ /**
+ * @group unit
+ */
public function testGetInitializingShards()
{
$this->assertEquals(6, $this->_index->getInitializingShards());
}
+ /**
+ * @group unit
+ */
public function testGetUnassignedShards()
{
$this->assertEquals(7, $this->_index->getUnassignedShards());
}
+ /**
+ * @group unit
+ */
public function testGetShards()
{
$shards = $this->_index->getShards();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
index b63195a0..5a436623 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster\Health;
use Elastica\Cluster\Health\Shard as HealthShard;
@@ -14,6 +13,8 @@ class ShardTest extends BaseTest
public function setUp()
{
+ parent::setUp();
+
$shardData = array(
'status' => 'red',
'primary_active' => true,
@@ -26,36 +27,57 @@ class ShardTest extends BaseTest
$this->_shard = new HealthShard(2, $shardData);
}
+ /**
+ * @group unit
+ */
public function testGetShardNumber()
{
$this->assertEquals(2, $this->_shard->getShardNumber());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('red', $this->_shard->getStatus());
}
+ /**
+ * @group unit
+ */
public function testisPrimaryActive()
{
$this->assertTrue($this->_shard->isPrimaryActive());
}
+ /**
+ * @group unit
+ */
public function testIsActive()
{
$this->assertTrue($this->_shard->isActive());
}
+ /**
+ * @group unit
+ */
public function testIsRelocating()
{
$this->assertFalse($this->_shard->isRelocating());
}
+ /**
+ * @group unit
+ */
public function testIsInitialized()
{
$this->assertFalse($this->_shard->isInitialized());
}
+ /**
+ * @group unit
+ */
public function testIsUnassigned()
{
$this->assertTrue($this->_shard->isUnassigned());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
index 054af3f7..bb3e82ec 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/HealthTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Cluster;
use Elastica\Test\Base as BaseTest;
@@ -11,8 +10,10 @@ class HealthTest extends BaseTest
*/
protected $_health;
- public function setUp()
+ protected function setUp()
{
+ parent::setUp();
+
$data = array(
'cluster_name' => 'test_cluster',
'status' => 'green',
@@ -49,56 +50,89 @@ class HealthTest extends BaseTest
$this->_health = $health;
}
+ /**
+ * @group unit
+ */
public function testGetClusterName()
{
$this->assertEquals('test_cluster', $this->_health->getClusterName());
}
+ /**
+ * @group unit
+ */
public function testGetStatus()
{
$this->assertEquals('green', $this->_health->getStatus());
}
+ /**
+ * @group unit
+ */
public function testGetTimedOut()
{
$this->assertFalse($this->_health->getTimedOut());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfNodes()
{
$this->assertEquals(10, $this->_health->getNumberOfNodes());
}
+ /**
+ * @group unit
+ */
public function testGetNumberOfDataNodes()
{
$this->assertEquals(8, $this->_health->getNumberOfDataNodes());
}
+ /**
+ * @group unit
+ */
public function testGetActivePrimaryShards()
{
$this->assertEquals(3, $this->_health->getActivePrimaryShards());
}
+ /**
+ * @group unit
+ */
public function testGetActiveShards()
{
$this->assertEquals(4, $this->_health->getActiveShards());
}
+ /**
+ * @group unit
+ */
public function testGetRelocatingShards()
{
$this->assertEquals(2, $this->_health->getRelocatingShards());
}
+ /**
+ * @group unit
+ */
public function testGetInitializingShards()
{
$this->assertEquals(7, $this->_health->getInitializingShards());
}
+ /**
+ * @group unit
+ */
public function testGetUnassignedShards()
{
$this->assertEquals(5, $this->_health->getUnassignedShards());
}
+ /**
+ * @group unit
+ */
public function testGetIndices()
{
$indices = $this->_health->getIndices();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
index a093feef..2a52fc8f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/SettingsTest.php
@@ -1,14 +1,16 @@
<?php
-
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
{
+ /**
+ * @group functional
+ */
public function testSetTransient()
{
$index = $this->_createIndex();
@@ -21,13 +23,16 @@ class SettingsTest extends BaseTest
$settings->setTransient('discovery.zen.minimum_master_nodes', 2);
$data = $settings->get();
- $this->assertEquals(2, $data['transient']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(2, $data['transient']['discovery']['zen']['minimum_master_nodes']);
$settings->setTransient('discovery.zen.minimum_master_nodes', 1);
$data = $settings->get();
- $this->assertEquals(1, $data['transient']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(1, $data['transient']['discovery']['zen']['minimum_master_nodes']);
}
+ /**
+ * @group functional
+ */
public function testSetPersistent()
{
$index = $this->_createIndex();
@@ -40,21 +45,23 @@ class SettingsTest extends BaseTest
$settings->setPersistent('discovery.zen.minimum_master_nodes', 2);
$data = $settings->get();
- $this->assertEquals(2, $data['persistent']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(2, $data['persistent']['discovery']['zen']['minimum_master_nodes']);
$settings->setPersistent('discovery.zen.minimum_master_nodes', 1);
$data = $settings->get();
- $this->assertEquals(1, $data['persistent']['discovery.zen.minimum_master_nodes']);
+ $this->assertEquals(1, $data['persistent']['discovery']['zen']['minimum_master_nodes']);
}
+ /**
+ * @group functional
+ */
public function testSetReadOnly()
{
// Create two indices to check that the complete cluster is read only
$settings = new Settings($this->_getClient());
$settings->setReadOnly(false);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
-
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$doc1 = new Document(null, array('hello' => 'world'));
$doc2 = new Document(null, array('hello' => 'world'));
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
index ae5fb980..ebd89f01 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ClusterTest.php
@@ -1,26 +1,28 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Cluster;
use Elastica\Test\Base as BaseTest;
class ClusterTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testGetNodeNames()
{
$client = $this->_getClient();
$cluster = new Cluster($client);
- $names = $cluster->getNodeNames();
-
- $this->assertInternalType('array', $names);
- $this->assertGreaterThan(0, count($names));
+ foreach ($cluster->getNodeNames() as $name) {
+ $this->assertEquals('Elastica', $name);
+ }
}
+ /**
+ * @group functional
+ */
public function testGetNodes()
{
$client = $this->_getClient();
@@ -35,6 +37,9 @@ class ClusterTest extends BaseTest
$this->assertGreaterThan(0, count($nodes));
}
+ /**
+ * @group functional
+ */
public function testGetState()
{
$client = $this->_getClient();
@@ -44,28 +49,14 @@ class ClusterTest extends BaseTest
}
/**
- * @expectedException \Elastica\Exception\ConnectionException
+ * @group functional
*/
- public function testShutdown()
- {
- $this->markTestSkipped('This test shuts down the cluster which means the following tests would not work');
- $client = $this->_getClient();
- $cluster = $client->getCluster();
-
- $cluster->shutdown('2s');
-
- sleep(5);
-
- $client->getStatus();
- }
-
public function testGetIndexNames()
{
$client = $this->_getClient();
$cluster = $client->getCluster();
- $indexName = 'elastica_test999';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$index->delete();
$cluster->refresh();
@@ -73,7 +64,7 @@ class ClusterTest extends BaseTest
$indexNames = $cluster->getIndexNames();
$this->assertNotContains($index->getName(), $indexNames);
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$cluster->refresh();
// Now index should exist
@@ -81,6 +72,9 @@ class ClusterTest extends BaseTest
$this->assertContains($index->getname(), $indexNames);
}
+ /**
+ * @group functional
+ */
public function testGetHealth()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php
new file mode 100644
index 00000000..ee03587a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php
@@ -0,0 +1,112 @@
+<?php
+namespace Elastica\Test\Connection;
+
+use Elastica\Connection;
+use Elastica\Connection\ConnectionPool;
+use Elastica\Connection\Strategy\StrategyFactory;
+use Elastica\Test\Base as BaseTest;
+
+/**
+ * @author chabior
+ */
+class ConnectionPoolTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $pool = $this->createPool();
+
+ $this->assertEquals($this->getConnections(), $pool->getConnections());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetConnections()
+ {
+ $pool = $this->createPool();
+
+ $connections = $this->getConnections(5);
+
+ $pool->setConnections($connections);
+
+ $this->assertEquals($connections, $pool->getConnections());
+
+ $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->setConnections($connections));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddConnection()
+ {
+ $pool = $this->createPool();
+ $pool->setConnections(array());
+
+ $connections = $this->getConnections(5);
+
+ foreach ($connections as $connection) {
+ $pool->addConnection($connection);
+ }
+
+ $this->assertEquals($connections, $pool->getConnections());
+
+ $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->addConnection($connections[0]));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testHasConnection()
+ {
+ $pool = $this->createPool();
+
+ $this->assertTrue($pool->hasConnection());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFailHasConnections()
+ {
+ $pool = $this->createPool();
+
+ $pool->setConnections(array());
+
+ $this->assertFalse($pool->hasConnection());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testGetConnection()
+ {
+ $pool = $this->createPool();
+
+ $this->assertInstanceOf('Elastica\Connection', $pool->getConnection());
+ }
+
+ protected function getConnections($quantity = 1)
+ {
+ $params = array();
+ $connections = array();
+
+ for ($i = 0; $i < $quantity; $i++) {
+ $connections[] = new Connection($params);
+ }
+
+ return $connections;
+ }
+
+ protected function createPool()
+ {
+ $connections = $this->getConnections();
+ $strategy = StrategyFactory::create('Simple');
+
+ $pool = new ConnectionPool($connections, $strategy);
+
+ return $pool;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
new file mode 100644
index 00000000..de8290ae
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTest.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\CallbackStrategy;
+use Elastica\Test\Base;
+
+/**
+ * Description of CallbackStrategyTest.
+ *
+ * @author chabior
+ */
+class CallbackStrategyTest extends Base
+{
+ /**
+ * @group unit
+ */
+ public function testInvoke()
+ {
+ $count = 0;
+
+ $callback = function ($connections) use (&$count) {
+ $count++;
+ };
+
+ $strategy = new CallbackStrategy($callback);
+ $strategy->getConnection(array());
+
+ $this->assertEquals(1, $count);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsValid()
+ {
+ // closure is valid
+ $isValid = CallbackStrategy::isValid(function () {});
+ $this->assertTrue($isValid);
+
+ // object implementing __invoke
+ $isValid = CallbackStrategy::isValid(new CallbackStrategyTestHelper());
+ $this->assertTrue($isValid);
+
+ // static method as string
+ $isValid = CallbackStrategy::isValid('Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper::getFirstConnectionStatic');
+ $this->assertTrue($isValid);
+
+ // static method as array
+ $isValid = CallbackStrategy::isValid(array('Elastica\Test\Connection\Strategy\CallbackStrategyTestHelper', 'getFirstConnectionStatic'));
+ $this->assertTrue($isValid);
+
+ // object method
+ $isValid = CallbackStrategy::isValid(array(new CallbackStrategyTestHelper(), 'getFirstConnectionStatic'));
+ $this->assertTrue($isValid);
+
+ // function name
+ $isValid = CallbackStrategy::isValid('array_pop');
+ $this->assertTrue($isValid);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFailIsValid()
+ {
+ $isValid = CallbackStrategy::isValid(new \stdClass());
+ $this->assertFalse($isValid);
+
+ $isValid = CallbackStrategy::isValid('array_pop_pop_pop_pop_pop_pop');
+ $this->assertFalse($isValid);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $count = 0;
+
+ $config = array('connectionStrategy' => function ($connections) use (&$count) {
+ ++$count;
+
+ return current($connections);
+ });
+
+ $client = $this->_getClient($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/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php
new file mode 100644
index 00000000..b15efe91
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/CallbackStrategyTestHelper.php
@@ -0,0 +1,20 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+class CallbackStrategyTestHelper
+{
+ public function __invoke($connections)
+ {
+ return $connections[0];
+ }
+
+ public function getFirstConnection($connections)
+ {
+ return $connections[0];
+ }
+
+ public static function getFirstConnectionStatic($connections)
+ {
+ return $connections[0];
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
new file mode 100644
index 00000000..8d2aa5df
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/EmptyStrategy.php
@@ -0,0 +1,17 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\StrategyInterface;
+
+/**
+ * Description of EmptyStrategy.
+ *
+ * @author chabior
+ */
+class EmptyStrategy implements StrategyInterface
+{
+ public function getConnection($connections)
+ {
+ return;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
new file mode 100644
index 00000000..0dedbc22
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/RoundRobinTest.php
@@ -0,0 +1,128 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection;
+use Elastica\Connection\Strategy\RoundRobin;
+use Elastica\Exception\ConnectionException;
+use Elastica\Response;
+use Elastica\Test\Base;
+
+/**
+ * Description of RoundRobinTest.
+ *
+ * @author chabior
+ */
+class RoundRobinTest extends Base
+{
+ /**
+ * @var int Number of seconds to wait before timeout is called. Is set low for tests to have fast tests.
+ */
+ protected $_timeout = 1;
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $config = array('connectionStrategy' => 'RoundRobin');
+ $client = $this->_getClient($config);
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testOldStrategySetted()
+ {
+ $config = array('roundRobin' => true);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group functional
+ * @expectedException \Elastica\Exception\ConnectionException
+ */
+ public function testFailConnection()
+ {
+ $config = array('connectionStrategy' => 'RoundRobin', 'host' => '255.255.255.0', 'timeout' => $this->_timeout);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+
+ $client->request('/_aliases');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithOneFailConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $callback = function ($connection, $exception, $client) use (&$count) {
+ ++$count;
+ };
+
+ $client = $this->_getClient(array('connectionStrategy' => 'RoundRobin'), $callback);
+ $client->setConnections($connections);
+
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+
+ $this->assertLessThan(count($connections), $count);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithNoValidConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $client = $this->_getClient(array('roundRobin' => true), function () use (&$count) {
+ ++$count;
+ });
+
+ $client->setConnections($connections);
+
+ try {
+ $client->request('/_aliases');
+ $this->fail('Should throw exception as no connection valid');
+ } catch (ConnectionException $e) {
+ $this->assertEquals(count($connections), $count);
+ $this->_checkStrategy($client);
+ }
+ }
+
+ protected function _checkStrategy($client)
+ {
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\RoundRobin', $strategy);
+ }
+
+ protected function _checkResponse($response)
+ {
+ $this->assertTrue($response->isOk());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
new file mode 100644
index 00000000..3b6ac89d
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php
@@ -0,0 +1,113 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection;
+use Elastica\Exception\ConnectionException;
+use Elastica\Test\Base;
+
+/**
+ * Description of SimplyTest.
+ *
+ * @author chabior
+ */
+class SimpleTest extends Base
+{
+ /**
+ * @var int Number of seconds to wait before timeout is called. Is set low for tests to have fast tests.
+ */
+ protected $_timeout = 1;
+
+ /**
+ * @group functional
+ */
+ public function testConnection()
+ {
+ $client = $this->_getClient();
+ $response = $client->request('/_aliases');
+ /* @var $response \Elastica\Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+ }
+
+ /**
+ * @group functional
+ * @expectedException \Elastica\Exception\ConnectionException
+ */
+ public function testFailConnection()
+ {
+ $config = array('host' => '255.255.255.0', 'timeout' => $this->_timeout);
+ $client = $this->_getClient($config);
+
+ $this->_checkStrategy($client);
+
+ $client->request('/_aliases');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithOneFailConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $callback = function ($connection, $exception, $client) use (&$count) {
+ ++$count;
+ };
+
+ $client = $this->_getClient(array(), $callback);
+ $client->setConnections($connections);
+
+ $response = $client->request('/_aliases');
+ /* @var $response Response */
+
+ $this->_checkResponse($response);
+
+ $this->_checkStrategy($client);
+
+ $this->assertLessThan(count($connections), $count);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testWithNoValidConnection()
+ {
+ $connections = array(
+ new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)),
+ new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)),
+ );
+
+ $count = 0;
+ $client = $this->_getClient(array(), function () use (&$count) {
+ ++$count;
+ });
+
+ $client->setConnections($connections);
+
+ try {
+ $client->request('/_aliases');
+ $this->fail('Should throw exception as no connection valid');
+ } catch (ConnectionException $e) {
+ $this->assertEquals(count($connections), $count);
+ }
+ }
+
+ protected function _checkStrategy($client)
+ {
+ $strategy = $client->getConnectionStrategy();
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+
+ protected function _checkResponse($response)
+ {
+ $this->assertTrue($response->isOk());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
new file mode 100644
index 00000000..978f8fd5
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/StrategyFactoryTest.php
@@ -0,0 +1,84 @@
+<?php
+namespace Elastica\Test\Connection\Strategy;
+
+use Elastica\Connection\Strategy\StrategyFactory;
+use Elastica\Test\Base;
+
+/**
+ * Description of StrategyFactoryTest.
+ *
+ * @author chabior
+ */
+class StrategyFactoryTest extends Base
+{
+ /**
+ * @group unit
+ */
+ public function testCreateCallbackStrategy()
+ {
+ $callback = function ($connections) {
+ };
+
+ $strategy = StrategyFactory::create($callback);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\CallbackStrategy', $strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByName()
+ {
+ $strategyName = 'Simple';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByClass()
+ {
+ $strategy = new EmptyStrategy();
+
+ $this->assertEquals($strategy, StrategyFactory::create($strategy));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testCreateByClassName()
+ {
+ $strategyName = '\\Elastica\Test\Connection\Strategy\\EmptyStrategy';
+
+ $strategy = StrategyFactory::create($strategyName);
+
+ $this->assertInstanceOf($strategyName, $strategy);
+ }
+
+ /**
+ * @group unit
+ * @expectedException \InvalidArgumentException
+ */
+ public function testFailCreate()
+ {
+ $strategy = new \stdClass();
+
+ StrategyFactory::create($strategy);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testNoCollisionWithGlobalNamespace()
+ {
+ // create collision
+ if (!class_exists('Simple')) {
+ class_alias('Elastica\Util', 'Simple');
+ }
+ $strategy = StrategyFactory::create('Simple');
+ $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
index 80cab9f0..7600524b 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ConnectionTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Connection;
@@ -8,7 +7,9 @@ use Elastica\Test\Base as BaseTest;
class ConnectionTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testEmptyConstructor()
{
$connection = new Connection();
@@ -17,10 +18,14 @@ class ConnectionTest extends BaseTest
$this->assertEquals(Connection::DEFAULT_TRANSPORT, $connection->getTransport());
$this->assertInstanceOf('Elastica\Transport\AbstractTransport', $connection->getTransportObject());
$this->assertEquals(Connection::TIMEOUT, $connection->getTimeout());
+ $this->assertEquals(Connection::CONNECT_TIMEOUT, $connection->getConnectTimeout());
$this->assertEquals(array(), $connection->getConfig());
$this->assertTrue($connection->isEnabled());
}
+ /**
+ * @group unit
+ */
public function testEnabledDisable()
{
$connection = new Connection();
@@ -32,6 +37,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\ConnectionException
*/
public function testInvalidConnection()
@@ -45,6 +51,9 @@ class ConnectionTest extends BaseTest
$request->send();
}
+ /**
+ * @group unit
+ */
public function testCreate()
{
$connection = Connection::create();
@@ -60,6 +69,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -68,6 +78,9 @@ class ConnectionTest extends BaseTest
Connection::create('test');
}
+ /**
+ * @group unit
+ */
public function testGetConfig()
{
$url = 'test';
@@ -76,6 +89,9 @@ class ConnectionTest extends BaseTest
$this->assertEquals($url, $connection->getConfig('url'));
}
+ /**
+ * @group unit
+ */
public function testGetConfigWithArrayUsedForTransport()
{
$connection = new Connection(array('transport' => array('type' => 'Http')));
@@ -83,6 +99,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException Elastica\Exception\InvalidException
* @expectedExceptionMessage Invalid transport
*/
@@ -93,6 +110,7 @@ class ConnectionTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testGetConfigInvalidValue()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
index 27fc5184..969c5b22 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/DocumentTest.php
@@ -1,20 +1,21 @@
<?php
-
namespace Elastica\Test;
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
{
+ /**
+ * @group unit
+ */
public function testAddFile()
{
$fileName = '/dev/null';
- if(!file_exists($fileName)){
+ if (!file_exists($fileName)) {
$this->markTestSkipped("File {$fileName} does not exist.");
}
$doc = new Document();
@@ -22,6 +23,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testAddGeoPoint()
{
$doc = new Document();
@@ -29,6 +33,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testSetData()
{
$doc = new Document();
@@ -36,6 +43,9 @@ class DocumentTest extends BaseTest
$this->assertInstanceOf('Elastica\Document', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$id = 17;
@@ -49,6 +59,9 @@ class DocumentTest extends BaseTest
$this->assertEquals($result, $doc->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetType()
{
$document = new Document();
@@ -68,6 +81,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('type', $document->getType());
}
+ /**
+ * @group unit
+ */
public function testSetIndex()
{
$document = new Document();
@@ -85,6 +101,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('type2', $document->getType());
}
+ /**
+ * @group unit
+ */
public function testHasId()
{
$document = new Document();
@@ -97,6 +116,9 @@ class DocumentTest extends BaseTest
$this->assertTrue($document->hasId());
}
+ /**
+ * @group unit
+ */
public function testGetOptions()
{
$document = new Document();
@@ -134,6 +156,9 @@ class DocumentTest extends BaseTest
$this->assertArrayNotHasKey('parent', $options);
}
+ /**
+ * @group unit
+ */
public function testGetSetHasRemove()
{
$document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null));
@@ -185,6 +210,9 @@ class DocumentTest extends BaseTest
$this->assertNotEquals($data, $newData);
}
+ /**
+ * @group unit
+ */
public function testDataPropertiesOverloading()
{
$document = new Document(1, array('field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'field4' => null));
@@ -234,6 +262,9 @@ class DocumentTest extends BaseTest
$this->assertNotEquals($data, $newData);
}
+ /**
+ * @group unit
+ */
public function testSetTtl()
{
$document = new Document();
@@ -254,6 +285,9 @@ class DocumentTest extends BaseTest
$this->assertEquals('1d', $document->getTtl());
}
+ /**
+ * @group unit
+ */
public function testSerializedData()
{
$data = '{"user":"rolf"}';
@@ -283,6 +317,9 @@ class DocumentTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testUpsert()
{
$document = new Document();
@@ -298,6 +335,9 @@ class DocumentTest extends BaseTest
$this->assertSame($upsert, $document->getUpsert());
}
+ /**
+ * @group unit
+ */
public function testDocAsUpsert()
{
$document = new Document();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
index 0331e389..efdc04eb 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ExampleTest.php
@@ -1,30 +1,33 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Test\Base as BaseTest;
/**
- * Tests the example code
+ * Tests the example code.
*/
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);
-
- }
-
+ /**
+ * @group functional
+ */
+ public function testBasicGettingStarted()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('ruflin');
+ $type = $index->getType('users');
+
+ $id = 2;
+ $data = array('firstname' => 'Nicolas', 'lastname' => 'Ruflin');
+ $doc = new Document($id, $data);
+
+ $type->addDocument($doc);
+ }
+
+ /**
+ * @group functional
+ */
public function testExample()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php
new file mode 100644
index 00000000..ea84218a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/AbstractExceptionTest.php
@@ -0,0 +1,31 @@
+<?php
+namespace Elastica\Test\Exception;
+
+use Elastica\Test\Base as BaseTest;
+
+abstract class AbstractExceptionTest extends BaseTest
+{
+ protected function _getExceptionClass()
+ {
+ $reflection = new \ReflectionObject($this);
+
+ // Elastica\Test\Exception\RuntimeExceptionTest => Elastica\Exception\RuntimeExceptionTest
+ $name = preg_replace('/^Elastica\\\\Test/', 'Elastica', $reflection->getName());
+
+ // Elastica\Exception\RuntimeExceptionTest => Elastica\Exception\RuntimeException
+ $name = preg_replace('/Test$/', '', $name);
+
+ return $name;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInheritance()
+ {
+ $className = $this->_getExceptionClass();
+ $reflection = new \ReflectionClass($className);
+ $this->assertTrue($reflection->isSubclassOf('Exception'));
+ $this->assertTrue($reflection->implementsInterface('Elastica\Exception\ExceptionInterface'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php
new file mode 100644
index 00000000..38a2f873
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/Response/ActionExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk\Response;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ActionExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php
new file mode 100644
index 00000000..2164f0e3
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/ResponseExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ResponseExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php
new file mode 100644
index 00000000..2b7660bf
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Bulk/UdpExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Bulk;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class UdpExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php
new file mode 100644
index 00000000..1bd07689
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/BulkExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class BulkExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php
new file mode 100644
index 00000000..3f75e456
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ClientExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ClientExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php
new file mode 100644
index 00000000..48a39de4
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/GuzzleExceptionTest.php
@@ -0,0 +1,14 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class GuzzleExceptionTest extends AbstractExceptionTest
+{
+ public static function setUpBeforeClass()
+ {
+ if (!class_exists('GuzzleHttp\\Client')) {
+ self::markTestSkipped('guzzlehttp/guzzle package should be installed to run guzzle transport tests');
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php
new file mode 100644
index 00000000..39d58013
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/HttpExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class HttpExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php
new file mode 100644
index 00000000..5bf8fd35
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/MemcacheExceptionTest.php
@@ -0,0 +1,8 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class MemcacheExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php
new file mode 100644
index 00000000..5cef43be
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/Connection/ThriftExceptionTest.php
@@ -0,0 +1,14 @@
+<?php
+namespace Elastica\Test\Exception\Connection;
+
+use Elastica\Test\Exception\AbstractExceptionTest;
+
+class ThriftExceptionTest extends AbstractExceptionTest
+{
+ public static function setUpBeforeClass()
+ {
+ if (!class_exists('Elasticsearch\\RestClient')) {
+ self::markTestSkipped('munkie/elasticsearch-thrift-php package should be installed to run thrift exception tests');
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php
new file mode 100644
index 00000000..5196b29e
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ConnectionExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ConnectionExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php
new file mode 100644
index 00000000..d11894f7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ElasticsearchExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class ElasticsearchExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php
new file mode 100644
index 00000000..e6e11899
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/InvalidExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class InvalidExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php
new file mode 100644
index 00000000..4fd01c49
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/JSONParseExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class JSONParseExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php
new file mode 100644
index 00000000..ff80a708
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotFoundExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class NotFoundExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php
index ff704638..117aa012 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/NotImplementedExceptionTest.php
@@ -1,22 +1,18 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Exception\NotImplementedException;
-use Elastica\Test\Base as BaseTest;
-class NotImplementedTest extends BaseTest
+class NotImplementedExceptionTest extends AbstractExceptionTest
{
+ /**
+ * @group unit
+ */
public function testInstance()
{
$code = 4;
$message = 'Hello world';
$exception = new NotImplementedException($message, $code);
-
- $this->assertInstanceOf('Elastica\Exception\NotImplementedException', $exception);
- $this->assertInstanceOf('Elastica\Exception\ExceptionInterface', $exception);
- $this->assertInstanceOf('Exception', $exception);
-
$this->assertEquals($message, $exception->getMessage());
$this->assertEquals($code, $exception->getCode());
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
index 31698e26..afcca1ec 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/PartialShardFailureExceptionTest.php
@@ -1,25 +1,25 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Document;
use Elastica\Exception\PartialShardFailureException;
use Elastica\Query;
use Elastica\ResultSet;
-use Elastica\Test\Base as BaseTest;
-class PartialShardFailureExceptionTest extends BaseTest
+class PartialShardFailureExceptionTest extends AbstractExceptionTest
{
-
+ /**
+ * @group functional
+ */
public function testPartialFailure()
{
$client = $this->_getClient();
$index = $client->getIndex('elastica_partial_failure');
$index->create(array(
'index' => array(
- 'number_of_shards' => 5,
- 'number_of_replicas' => 0
- )
+ 'number_of_shards' => 5,
+ 'number_of_replicas' => 0,
+ ),
), true);
$type = $index->getType('folks');
@@ -51,5 +51,4 @@ class PartialShardFailureExceptionTest extends BaseTest
$this->assertEquals(0, count($resultSet->getResults()));
}
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php
new file mode 100644
index 00000000..375731ba
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/QueryBuilderExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class QueryBuilderExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
index 06b5462b..6fc975e7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/ResponseExceptionTest.php
@@ -1,14 +1,14 @@
<?php
-
namespace Elastica\Test\Exception;
use Elastica\Document;
use Elastica\Exception\ResponseException;
-use Elastica\Test\Base as BaseTest;
-class ResponseExceptionTest extends BaseTest
+class ResponseExceptionTest extends AbstractExceptionTest
{
-
+ /**
+ * @group functional
+ */
public function testCreateExistingIndex()
{
$this->_createIndex('woo', true);
@@ -22,15 +22,18 @@ class ResponseExceptionTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testBadType()
{
- $index = $this->_createIndex('woo');
- $type = $index->getType('test');
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
$type->setMapping(array(
'num' => array(
- 'type' => 'long'
- )
+ 'type' => 'long',
+ ),
));
try {
@@ -44,9 +47,12 @@ class ResponseExceptionTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testWhatever()
{
- $index = $this->_createIndex('woo');
+ $index = $this->_createIndex();
$index->delete();
try {
@@ -56,5 +62,4 @@ class ResponseExceptionTest extends BaseTest
$this->assertEquals(404, $ex->getElasticsearchException()->getCode());
}
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php
new file mode 100644
index 00000000..9dd18951
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Exception/RuntimeExceptionTest.php
@@ -0,0 +1,6 @@
+<?php
+namespace Elastica\Test\Exception;
+
+class RuntimeExceptionTest extends AbstractExceptionTest
+{
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
index 46dcdbf9..96d30aa2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/DateHistogramTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -11,6 +10,9 @@ use Elastica\Type\Mapping;
class DateHistogramTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testClassHierarchy()
{
$facet = new DateHistogram('dateHist1');
@@ -19,7 +21,51 @@ class DateHistogramTest extends BaseTest
unset($facet);
}
- public function testTest()
+ /**
+ * @group functional
+ */
+ public function testQuery()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('helloworld');
+
+ $mapping = new Mapping($type, array(
+ 'name' => array('type' => 'string', 'store' => 'no'),
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
+ ));
+ $type->setMapping($mapping);
+
+ $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00'));
+ $type->addDocument($doc);
+ $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00'));
+ $type->addDocument($doc);
+
+ $facet = new DateHistogram('dateHist1');
+ $facet->setInterval('day');
+ $facet->setField('dtmPosted');
+
+ $query = new Query();
+ $query->addFacet($facet);
+ $query->setQuery(new MatchAll());
+ $index->refresh();
+
+ $response = $type->search($query);
+ $facets = $response->getFacets();
+
+ $this->assertEquals(4, $response->getTotalHits());
+ $this->assertEquals(2, count($facets['dateHist1']['entries']));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFactor()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
@@ -28,22 +74,23 @@ class DateHistogramTest extends BaseTest
$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' => 'long', 'store' => 'no'),
));
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00"));
+ $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => 1308865980));
$type->addDocument($doc);
- $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00"));
+ $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => 1308822780));
$type->addDocument($doc);
- $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00"));
+ $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => 1310115180));
$type->addDocument($doc);
- $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00"));
+ $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => 1310089980));
$type->addDocument($doc);
$facet = new DateHistogram('dateHist1');
- $facet->setInterval("day");
- $facet->setField("dtmPosted");
+ $facet->setInterval('day');
+ $facet->setField('dtmPosted');
+ $facet->setFactor(1000);
$query = new Query();
$query->addFacet($facet);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
index ca6f5ba3..622923fe 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/FilterTest.php
@@ -1,15 +1,17 @@
<?php
-
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;
class FilterTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilter()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
index d06b58f9..f771ac32 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/GeoClusterTest.php
@@ -1,42 +1,50 @@
<?php
-
namespace Elastica\Test\Facet;
+use Elastica\Document;
+use Elastica\Facet\GeoCluster;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
-
-class GeoClusterTest extends BaseTest{
- public function testQuery() {
+use Elastica\Type\Mapping;
+
+class GeoClusterTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ 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');
}
- $index = $this->_createIndex('geocluster_test');
+ $index = $this->_createIndex();
$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);
@@ -46,4 +54,4 @@ class GeoClusterTest extends BaseTest{
$index->delete();
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
index ef5d7ccd..8e0231aa 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/QueryTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class QueryTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilter()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
index 0b528a79..dc374289 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/StatisticalTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -8,8 +7,14 @@ use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+/**
+ * @todo Add test for Statistical with setScript
+ */
class StatisticalTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testStatisticalWithSetField()
{
$client = $this->_getClient();
@@ -41,6 +46,9 @@ class StatisticalTest extends BaseTest
$this->assertEquals(45, $facets['stats']['max']);
}
+ /**
+ * @group functional
+ */
public function testStatisticalWithSetFields()
{
$client = $this->_getClient();
@@ -56,7 +64,7 @@ class StatisticalTest extends BaseTest
$type->addDocument($doc);
$facet = new Statistical('stats');
- $facet->setFields(array('price','price2'));
+ $facet->setFields(array('price', 'price2'));
$query = new Query();
$query->addFacet($facet);
@@ -71,12 +79,4 @@ class StatisticalTest extends BaseTest
$this->assertEquals(10, $facets['stats']['min']);
$this->assertEquals(90, $facets['stats']['max']);
}
-
- /**
- * @todo
- */
- public function testStatisticalWithSetScript()
- {
- $this->markTestIncomplete('Test for setting the script value');
- }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
index bea9b78d..e3377930 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsStatsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,96 +9,105 @@ use Elastica\Test\Base as BaseTest;
class TermsStatsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
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 );
- $facets = $response->getFacets();
+ $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']);
}
+ /**
+ * @group functional
+ */
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 );
- $facets = $response->getFacets();
+ $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);
+ /**
+ * @group unit
+ */
+ 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/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
index e8521c5c..f4c95796 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Facet/TermsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Facet;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -39,6 +41,9 @@ class TermsTest extends BaseTest
$this->assertEquals(3, count($facets['test']['terms']));
}
+ /**
+ * @group functional
+ */
public function testFacetScript()
{
$client = $this->_getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
index 1e47819f..3ba64dd1 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/AbstractTest.php
@@ -1,11 +1,13 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Test\Base as BaseTest;
class AbstractTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetCached()
{
$stubFilter = $this->getStub();
@@ -19,6 +21,9 @@ class AbstractTest extends BaseTest
$this->assertFalse($arrayFilter['_cache']);
}
+ /**
+ * @group unit
+ */
public function testSetCachedDefaultValue()
{
$stubFilter = $this->getStub();
@@ -28,6 +33,9 @@ class AbstractTest extends BaseTest
$this->assertTrue($arrayFilter['_cache']);
}
+ /**
+ * @group unit
+ */
public function testSetCacheKey()
{
$stubFilter = $this->getStub();
@@ -40,6 +48,7 @@ class AbstractTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testSetCacheKeyEmptyKey()
@@ -51,6 +60,9 @@ class AbstractTest extends BaseTest
$stubFilter->setCacheKey($cacheKey);
}
+ /**
+ * @group unit
+ */
public function testSetName()
{
$stubFilter = $this->getStub();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
index 672c6c67..a8f47633 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolAndTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class BoolAndTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$and = new BoolAnd();
@@ -23,13 +25,16 @@ class BoolAndTest extends BaseTest
$expectedArray = array(
'and' => array(
$idsFilter->toArray(),
- $idsFilter->toArray()
- )
+ $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $and->toArray());
}
+ /**
+ * @group functional
+ */
public function testSetCache()
{
$client = $this->_getClient();
@@ -37,12 +42,11 @@ class BoolAndTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'nicolas ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('name' => 'nicolas ruflin')),
+ new Document(3, array('name' => 'ruflin')),
+ ));
$and = new BoolAnd();
@@ -62,4 +66,21 @@ class BoolAndTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $ids1 = new Ids('foo', array(1, 2));
+ $ids2 = new Ids('bar', array(3, 4));
+
+ $and1 = new BoolAnd(array($ids1, $ids2));
+
+ $and2 = new BoolAnd();
+ $and2->addFilter($ids1);
+ $and2->addFilter($ids2);
+
+ $this->assertEquals($and1->toArray(), $and2->toArray());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php
new file mode 100644
index 00000000..ec7728af
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolFilterTest.php
@@ -0,0 +1,200 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Document;
+use Elastica\Filter\BoolFilter;
+use Elastica\Filter\Ids;
+use Elastica\Filter\Term;
+use Elastica\Filter\Terms;
+use Elastica\Query;
+use Elastica\Test\Base as BaseTest;
+
+class BoolFilterTest extends BaseTest
+{
+ /**
+ * @return array
+ */
+ public function getTestToArrayData()
+ {
+ $out = array();
+
+ // case #0
+ $mainBool = new BoolFilter();
+
+ $idsFilter1 = new Ids();
+ $idsFilter1->setIds(1);
+ $idsFilter2 = new Ids();
+ $idsFilter2->setIds(2);
+ $idsFilter3 = new Ids();
+ $idsFilter3->setIds(3);
+
+ $childBool = new BoolFilter();
+ $childBool->addShould(array($idsFilter1, $idsFilter2));
+ $mainBool->addShould(array($childBool, $idsFilter3));
+
+ $expectedArray = array(
+ 'bool' => array(
+ 'should' => array(
+ array(
+ array(
+ 'bool' => array(
+ 'should' => array(
+ array(
+ $idsFilter1->toArray(),
+ $idsFilter2->toArray(),
+ ),
+ ),
+ ),
+ ),
+ $idsFilter3->toArray(),
+ ),
+ ),
+ ),
+ );
+ $out[] = array($mainBool, $expectedArray);
+
+ // case #1 _cache parameter should be supported
+ $bool = new BoolFilter();
+ $terms = new Terms('field1', array('value1', 'value2'));
+ $termsNot = new Terms('field2', array('value1', 'value2'));
+ $bool->addMust($terms);
+ $bool->addMustNot($termsNot);
+ $bool->setCached(true);
+ $bool->setCacheKey('my-cache-key');
+ $expected = array(
+ 'bool' => array(
+ 'must' => array(
+ $terms->toArray(),
+ ),
+ 'must_not' => array(
+ $termsNot->toArray(),
+ ),
+ '_cache' => true,
+ '_cache_key' => 'my-cache-key',
+ ),
+ );
+ $out[] = array($bool, $expected);
+
+ return $out;
+ }
+
+ /**
+ * @group unit
+ * @dataProvider getTestToArrayData()
+ *
+ * @param Bool $bool
+ * @param array $expectedArray
+ */
+ public function testToArray(BoolFilter $bool, $expectedArray)
+ {
+ $this->assertEquals($expectedArray, $bool->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testBoolFilter()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('book');
+
+ //index some test data
+ $type->addDocuments(array(
+ new Document(1, array('author' => 'Michael Shermer', 'title' => 'The Believing Brain', 'publisher' => 'Robinson')),
+ new Document(2, array('author' => 'Jared Diamond', 'title' => 'Guns, Germs and Steel', 'publisher' => 'Vintage')),
+ new Document(3, array('author' => 'Jared Diamond', 'title' => 'Collapse', 'publisher' => 'Penguin')),
+ new Document(4, array('author' => 'Richard Dawkins', 'title' => 'The Selfish Gene', 'publisher' => 'OUP Oxford')),
+ new Document(5, array('author' => 'Anthony Burges', 'title' => 'A Clockwork Orange', 'publisher' => 'Penguin')),
+ ));
+
+ $index->refresh();
+
+ //use the terms lookup feature to query for some data
+ //build query
+ //must
+ // should
+ // author = jared
+ // author = richard
+ // must_not
+ // publisher = penguin
+
+ //construct the query
+ $query = new Query();
+ $mainBoolFilter = new BoolFilter();
+ $shouldFilter = new BoolFilter();
+ $authorFilter1 = new Term();
+ $authorFilter1->setTerm('author', 'jared');
+ $authorFilter2 = new Term();
+ $authorFilter2->setTerm('author', 'richard');
+ $shouldFilter->addShould(array($authorFilter1, $authorFilter2));
+
+ $mustNotFilter = new BoolFilter();
+ $publisherFilter = new Term();
+ $publisherFilter->setTerm('publisher', 'penguin');
+ $mustNotFilter->addMustNot($publisherFilter);
+
+ $mainBoolFilter->addMust(array($shouldFilter, $mustNotFilter));
+ $query->setPostFilter($mainBoolFilter);
+ //execute the query
+ $results = $index->search($query);
+
+ //check the number of results
+ $this->assertEquals($results->count(), 2, 'Bool filter with child Bool filters: number of results check');
+
+ //count compare the id's
+ $ids = array();
+ /** @var \Elastica\Result $result **/
+ foreach ($results as $result) {
+ $ids[] = $result->getId();
+ }
+ $this->assertEquals($ids, array('2', '4'), 'Bool filter with child Bool filters: result ID check');
+
+ $index->delete();
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddMustInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addMust('fail!');
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddMustNotInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addMustNot('fail!');
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddShouldInvalidException()
+ {
+ $filter = new BoolFilter();
+ $filter->addShould('fail!');
+ }
+
+ /**
+ * Small unit test to check if also the old object name works.
+ *
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $filter = new \Elastica\Filter\Bool();
+ $filter->addShould('fail!');
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
index adcebf45..75461496 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolNotTest.php
@@ -1,13 +1,15 @@
<?php
-
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
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$idsFilter = new Ids();
@@ -16,8 +18,8 @@ class BoolNotTest extends BaseTest
$expectedArray = array(
'not' => array(
- 'filter' => $idsFilter->toArray()
- )
+ 'filter' => $idsFilter->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
index 25234a8c..6462d1fa 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolOrTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Filter\AbstractFilter;
+use Elastica\Document;
use Elastica\Filter\BoolOr;
use Elastica\Filter\Ids;
use Elastica\Test\Base as BaseTest;
class BoolOrTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddFilter()
{
$filter = $this->getMockForAbstractClass('Elastica\Filter\AbstractFilter');
@@ -17,6 +19,9 @@ class BoolOrTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\BoolOr', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$orFilter = new BoolOr();
@@ -33,10 +38,53 @@ class BoolOrTest extends BaseTest
$expectedArray = array(
'or' => array(
$filter1->toArray(),
- $filter2->toArray()
- )
+ $filter2->toArray(),
+ ),
);
$this->assertEquals($expectedArray, $orFilter->toArray());
}
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $ids1 = new Ids('foo', array(1, 2));
+ $ids2 = new Ids('bar', array(3, 4));
+
+ $and1 = new BoolOr(array($ids1, $ids2));
+
+ $and2 = new BoolOr();
+ $and2->addFilter($ids1);
+ $and2->addFilter($ids2);
+
+ $this->assertEquals($and1->toArray(), $and2->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOrFilter()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $doc1 = new Document('', array('categoryId' => 1));
+ $doc2 = new Document('', array('categoryId' => 2));
+ $doc3 = new Document('', array('categoryId' => 3));
+
+ $type->addDocument($doc1);
+ $type->addDocument($doc2);
+ $type->addDocument($doc3);
+
+ $index->refresh();
+
+ $boolOr = new \Elastica\Filter\BoolOr();
+ $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '1')));
+ $boolOr->addFilter(new \Elastica\Filter\Term(array('categoryId' => '2')));
+
+ $resultSet = $type->search($boolOr);
+ $this->assertEquals(2, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php
deleted file mode 100644
index 60eb3a45..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/BoolTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-
-namespace Elastica\Test\Filter;
-
-use \Elastica\Query;
-use Elastica\Filter\Bool;
-use Elastica\Filter\Term;
-use Elastica\Filter\Ids;
-use Elastica\Test\Base as BaseTest;
-
-class BoolTest extends BaseTest
-{
- public function testToArray()
- {
- $mainBool = new Bool();
-
- $idsFilter1 = new Ids();
- $idsFilter1->setIds(1);
- $idsFilter2 = new Ids();
- $idsFilter2->setIds(2);
- $idsFilter3 = new Ids();
- $idsFilter3->setIds(3);
-
- $childBool = new Bool();
- $childBool->addShould(array($idsFilter1, $idsFilter2));
- $mainBool->addShould(array($childBool, $idsFilter3));
-
- $expectedArray = array(
- 'bool' => array(
- 'should' => array(
- array(
- array(
- 'bool' => array(
- 'should' => array(
- array(
- $idsFilter1->toArray(),
- $idsFilter2->toArray()
- )
- )
- )
- ),
- $idsFilter3->toArray()
- )
- )
- )
- );
-
- $this->assertEquals($expectedArray, $mainBool->toArray());
- }
-
- public function testBoolFilter()
- {
- $index = $this->_createIndex('bool_filter_test');
- $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')));
-
- $index->refresh();
-
- //use the terms lookup feature to query for some data
- //build query
- //must
- // should
- // author = jared
- // author = richard
- // must_not
- // publisher = penguin
-
- //construct the query
- $query = new Query();
- $mainBoolFilter = new Bool();
- $shouldFilter = new Bool();
- $authorFilter1 = new Term();
- $authorFilter1->setTerm('author', 'jared');
- $authorFilter2 = new Term();
- $authorFilter2->setTerm('author', 'richard');
- $shouldFilter->addShould(array($authorFilter1, $authorFilter2));
-
- $mustNotFilter = new Bool();
- $publisherFilter = new Term();
- $publisherFilter->setTerm('publisher', 'penguin');
- $mustNotFilter->addMustNot($publisherFilter);
-
- $mainBoolFilter->addMust(array($shouldFilter, $mustNotFilter));
- $query->setFilter($mainBoolFilter);
- //execute the query
- $results = $index->search($query);
-
- //check the number of results
- $this->assertEquals($results->count(), 2, 'Bool filter with child Bool filters: number of results check');
-
- //count compare the id's
- $ids = array();
- /** @var \Elastica\Result $result **/
- foreach($results as $result){
- $ids[] = $result->getId();
- }
- $this->assertEquals($ids, array("2","4"), 'Bool filter with child Bool filters: result ID check');
-
- $index->delete();
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php
index 9e4f5b67..25afa724 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTests.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ExistsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Exists;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class ExistsTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'test';
@@ -16,6 +18,9 @@ class ExistsTest extends BaseTest
$this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetField()
{
$field = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php
new file mode 100644
index 00000000..8fdde965
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php
@@ -0,0 +1,55 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\GeoBoundingBox;
+use Elastica\Test\Base as BaseTest;
+
+class GeoBoundingBoxTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testAddCoordinates()
+ {
+ $key = 'pin.location';
+ $coords = array('40.73, -74.1', '40.01, -71.12');
+ $filter = new GeoBoundingBox($key, array('1,2', '3,4'));
+
+ $filter->addCoordinates($key, $coords);
+ $expectedArray = array('top_left' => $coords[0], 'bottom_right' => $coords[1]);
+ $this->assertEquals($expectedArray, $filter->getParam($key));
+
+ $returnValue = $filter->addCoordinates($key, $coords);
+ $this->assertInstanceOf('Elastica\Filter\GeoBoundingBox', $returnValue);
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testAddCoordinatesInvalidException()
+ {
+ $filter = new GeoBoundingBox('foo', array());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $key = 'pin.location';
+ $coords = array('40.73, -74.1', '40.01, -71.12');
+ $filter = new GeoBoundingBox($key, $coords);
+
+ $expectedArray = array(
+ 'geo_bounding_box' => array(
+ $key => array(
+ 'top_left' => $coords[0],
+ 'bottom_right' => $coords[1],
+ ),
+ ),
+ );
+
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
index 4c4d2bcc..203a45de 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceRangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,12 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoDistanceRangeTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
-
+ $index = $this->_createIndex();
$type = $index->getType('test');
// Set mapping
@@ -53,7 +52,7 @@ class GeoDistanceRangeTest extends BaseTest
);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
@@ -64,13 +63,14 @@ class GeoDistanceRangeTest extends BaseTest
array('gte' => '0km', 'lte' => '40000km')
);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$index->refresh();
$this->assertEquals(2, $type->search($query)->count());
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidRange()
@@ -83,6 +83,7 @@ class GeoDistanceRangeTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider invalidLocationDataProvider
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -96,6 +97,7 @@ class GeoDistanceRangeTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider constructDataProvider
*/
public function testConstruct($key, $location, $ranges, $expected)
@@ -130,7 +132,7 @@ class GeoDistanceRangeTest extends BaseTest
),
array(
false,
- )
+ ),
);
}
@@ -149,8 +151,8 @@ class GeoDistanceRangeTest extends BaseTest
'from' => '10km',
'to' => '20km',
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -168,8 +170,8 @@ class GeoDistanceRangeTest extends BaseTest
'from' => '10km',
'include_lower' => true,
'location' => 'u09tvqx',
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -189,8 +191,8 @@ class GeoDistanceRangeTest extends BaseTest
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
+ ),
+ ),
),
array(
'location',
@@ -210,9 +212,9 @@ class GeoDistanceRangeTest extends BaseTest
'lat' => 48.86,
'lon' => 2.35,
),
- )
- )
- )
+ ),
+ ),
+ ),
);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
index a5049914..b61b4adc 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoDistanceTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,11 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoDistanceTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
@@ -49,25 +49,28 @@ class GeoDistanceTest extends BaseTest
$geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '1km');
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
$query = new Query();
$geoFilter = new GeoDistance('point', array('lat' => 30, 'lon' => 40), '40000km');
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$index->refresh();
$this->assertEquals(2, $type->search($query)->count());
}
+ /**
+ * @group unit
+ */
public function testConstructLatlon()
{
$key = 'location';
$location = array(
'lat' => 48.86,
- 'lon' => 2.35
+ 'lon' => 2.35,
);
$distance = '10km';
@@ -76,8 +79,8 @@ class GeoDistanceTest extends BaseTest
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
@@ -85,6 +88,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testConstructGeohash()
{
$key = 'location';
@@ -96,8 +102,8 @@ class GeoDistanceTest extends BaseTest
$expected = array(
'geo_distance' => array(
$key => $location,
- 'distance' => $distance
- )
+ 'distance' => $distance,
+ ),
);
$data = $filter->toArray();
@@ -105,6 +111,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetDistanceType()
{
$filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km');
@@ -116,6 +125,9 @@ class GeoDistanceTest extends BaseTest
$this->assertEquals($distanceType, $data['geo_distance']['distance_type']);
}
+ /**
+ * @group unit
+ */
public function testSetOptimizeBbox()
{
$filter = new GeoDistance('location', array('lat' => 48.86, 'lon' => 2.35), '10km');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
index 7ebd738c..b56f73b0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoPolygonTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,11 +9,12 @@ use Elastica\Test\Base as BaseTest;
class GeoPolygonTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGeoPoint()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
@@ -49,7 +49,7 @@ class GeoPolygonTest extends BaseTest
$geoFilter = new GeoPolygon('location', $points);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(1, $type->search($query)->count());
// Both points should be inside
@@ -58,7 +58,7 @@ class GeoPolygonTest extends BaseTest
$geoFilter = new GeoPolygon('location', $points);
$query = new Query(new MatchAll());
- $query->setFilter($geoFilter);
+ $query->setPostFilter($geoFilter);
$this->assertEquals(2, $type->search($query)->count());
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
index 21afec1a..96453527 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php
@@ -1,66 +1,67 @@
<?php
-
-
namespace Elastica\Test\Filter;
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
{
+ /**
+ * @group functional
+ */
public function testGeoProvided()
{
- $indexName = 'geo_shape_filter_test';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
+ $indexName = $index->getName();
$type = $index->getType('type');
$otherType = $index->getType('other_type');
// 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);
// add type docs
$type->addDocument(new \Elastica\Document('1', array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(0.0, 50.0),
- array(50.0, 0.0)
- )
- )
+ array(50.0, 0.0),
+ ),
+ ),
)));
// add other type docs
$otherType->addDocument(new \Elastica\Document('2', array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(25.0, 75.0),
- array(75.0, 25.0)
- )
- )
+ array(75.0, 25.0),
+ ),
+ ),
)));
$index->optimize();
$index->refresh();
$gsp = new GeoShapePreIndexed(
- 'location', '1', 'type', 'elastica_'.$indexName, 'location'
+ 'location', '1', 'type', $indexName, 'location'
);
$gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
@@ -70,12 +71,12 @@ class GeoShapePreIndexedTest extends BaseTest
'indexed_shape' => array(
'id' => '1',
'type' => 'type',
- 'index' => 'elastica_'.$indexName,
- 'path' => 'location'
+ 'index' => $indexName,
+ 'path' => 'location',
),
- 'relation' => $gsp->getRelation()
- )
- )
+ 'relation' => $gsp->getRelation(),
+ ),
+ ),
);
$this->assertEquals($expected, $gsp->toArray());
@@ -87,4 +88,15 @@ class GeoShapePreIndexedTest extends BaseTest
$index->delete();
}
-} \ No newline at end of file
+
+ /**
+ * @group unit
+ */
+ public function testSetRelation()
+ {
+ $gsp = new GeoShapePreIndexed('location', '1', 'type', 'indexName', 'location');
+ $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
+ $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation());
+ $this->assertInstanceOf('Elastica\Filter\GeoShapePreIndexed', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
index 146150a3..d631e44e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php
@@ -1,38 +1,41 @@
<?php
-
-
namespace Elastica\Test\Filter;
+use Elastica\Document;
use Elastica\Filter\AbstractGeoShape;
use Elastica\Filter\GeoShapeProvided;
use Elastica\Query\Filtered;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class GeoShapeProvidedTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testConstructEnvelope()
{
- $index = $this->_createIndex('geo_shape_filter_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
// create mapping
- $mapping = new \Elastica\Type\Mapping($type, array(
+ $mapping = new Mapping($type, array(
'location' => array(
- 'type' => 'geo_shape'
- )
+ 'type' => 'geo_shape',
+ ),
));
$type->setMapping($mapping);
// add docs
- $type->addDocument(new \Elastica\Document(1, array(
+ $type->addDocument(new Document(1, array(
'location' => array(
- "type" => "envelope",
- "coordinates" => array(
+ 'type' => 'envelope',
+ 'coordinates' => array(
array(-50.0, 50.0),
- array(50.0, -50.0)
- )
- )
+ array(50.0, -50.0),
+ ),
+ ),
)));
$index->optimize();
@@ -40,7 +43,7 @@ class GeoShapeProvidedTest extends BaseTest
$envelope = array(
array(25.0, 75.0),
- array(75.0, 25.0)
+ array(75.0, 25.0),
);
$gsp = new GeoShapeProvided('location', $envelope);
@@ -49,11 +52,11 @@ class GeoShapeProvidedTest extends BaseTest
'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());
@@ -62,10 +65,11 @@ class GeoShapeProvidedTest extends BaseTest
$results = $type->search($query);
$this->assertEquals(1, $results->count());
-
- $index->delete();
}
+ /**
+ * @group unit
+ */
public function testConstructPolygon()
{
$polygon = array(array(102.0, 2.0), array(103.0, 2.0), array(103.0, 3.0), array(103.0, 3.0), array(102.0, 2.0));
@@ -76,13 +80,24 @@ class GeoShapeProvidedTest extends BaseTest
'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
+
+ /**
+ * @group unit
+ */
+ public function testSetRelation()
+ {
+ $gsp = new GeoShapeProvided('location', array(array(25.0, 75.0), array(75.0, 25.0)));
+ $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT);
+ $this->assertEquals(AbstractGeoShape::RELATION_INTERSECT, $gsp->getRelation());
+ $this->assertInstanceOf('Elastica\Filter\GeoShapeProvided', $gsp->setRelation(AbstractGeoShape::RELATION_INTERSECT));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
index 7cb8aef6..7ef0d04f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeohashCellTest.php
@@ -1,12 +1,17 @@
<?php
-
namespace Elastica\Test\Filter;
-use Elastica\Test\Base as BaseTest;
+use Elastica\Document;
use Elastica\Filter\GeohashCell;
+use Elastica\Query;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class GeohashCellTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new GeohashCell('pin', array('lat' => 37.789018, 'lon' => -122.391506), '50m');
@@ -14,43 +19,46 @@ class GeohashCellTest extends BaseTest
'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());
}
+ /**
+ * @group functional
+ */
public function testFilter()
{
- $index = $this->_createIndex('geohash_filter_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
- $mapping = new \Elastica\Type\Mapping($type, array(
+ $mapping = new Mapping($type, array(
'pin' => array(
'type' => 'geo_point',
'geohash' => true,
- 'geohash_prefix' => true
- )
+ 'geohash_prefix' => true,
+ ),
));
$type->setMapping($mapping);
- $type->addDocument(new \Elastica\Document(1, array('pin' => '9q8yyzm0zpw8')));
- $type->addDocument(new \Elastica\Document(2, array('pin' => '9mudgb0yued0')));
+ $type->addDocument(new Document(1, array('pin' => '9q8yyzm0zpw8')));
+ $type->addDocument(new Document(2, array('pin' => '9mudgb0yued0')));
$index->refresh();
$filter = new GeohashCell('pin', array('lat' => 32.828326, 'lon' => -117.255854));
- $query = new \Elastica\Query();
- $query->setFilter($filter);
+ $query = new Query();
+ $query->setPostFilter($filter);
$results = $type->search($query);
$this->assertEquals(1, $results->count());
//test precision parameter
$filter = new GeohashCell('pin', '9', 1);
- $query = new \Elastica\Query();
- $query->setFilter($filter);
+ $query = new Query();
+ $query->setPostFilter($filter);
$results = $type->search($query);
$this->assertEquals(2, $results->count());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
index 8bba8173..00af1def 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasChildTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class HasChildTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,35 +22,71 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
}
- public function testSetScope()
+ /**
+ * @group functional
+ */
+ public function testSetType()
{
- $q = new MatchAll();
+ $index = $this->prepareSearchData();
- $type = 'test';
+ $filter = new HasChild(new MatchAll(), 'type_name');
+ $this->assertEquals('type_name', $filter->getParam('type'));
- $scope = 'foo';
+ $filter->setType('new_type_name');
+ $this->assertEquals('new_type_name', $filter->getParam('type'));
- $filter = new HasChild($q, $type);
- $filter->setScope($scope);
+ $type = $index->getType('foo');
+ $filter = new HasChild(new MatchAll(), $type);
+ $this->assertEquals('foo', $filter->getParam('type'));
- $expectedArray = array(
- 'has_child' => array(
- 'query' => $q->toArray(),
- 'type' => $type,
- '_scope' => $scope
- )
- );
+ $type = $index->getType('bar');
+ $filter->setType($type);
+ $this->assertEquals('bar', $filter->getParam('type'));
- $this->assertEquals($expectedArray, $filter->toArray());
+ $returnValue = $filter->setType('last');
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetMinimumChildrenCount()
+ {
+ $query = new MatchAll();
+ $filter = new HasChild($query, 'test');
+
+ $filter->setMinimumChildrenCount(2);
+ $this->assertEquals(2, $filter->getParam('min_children'));
+
+ $returnValue = $filter->setMinimumChildrenCount(2);
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
}
+ /**
+ * @group unit
+ */
+ public function testSetMaximumChildrenCount()
+ {
+ $query = new MatchAll();
+ $filter = new HasChild($query, 'test');
+
+ $filter->setMaximumChildrenCount(10);
+ $this->assertEquals(10, $filter->getParam('max_children'));
+
+ $returnValue = $filter->setMaximumChildrenCount(10);
+ $this->assertInstanceOf('Elastica\Filter\HasChild', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
public function testFilterInsideHasChild()
{
$f = new \Elastica\Filter\MatchAll();
@@ -60,14 +98,16 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testFilterInsideHasChildSearch()
{
$index = $this->prepareSearchData();
@@ -77,7 +117,7 @@ class HasChildTest extends BaseTest
$filter = new HasChild($f, 'child');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -88,6 +128,9 @@ class HasChildTest extends BaseTest
$this->assertEquals($expected, $result);
}
+ /**
+ * @group functional
+ */
public function testQueryInsideHasChildSearch()
{
$index = $this->prepareSearchData();
@@ -97,7 +140,7 @@ class HasChildTest extends BaseTest
$filter = new HasChild($f, 'child');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -107,24 +150,27 @@ class HasChildTest extends BaseTest
$this->assertEquals($expected, $result);
}
-
+
+ /**
+ * @group functional
+ */
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->setFilter($filter);
+ $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);
}
@@ -135,7 +181,7 @@ class HasChildTest extends BaseTest
$index->create(array(), true);
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
$childMapping = new \Elastica\Type\Mapping($childType);
$childMapping->setParent('parent');
@@ -144,7 +190,7 @@ class HasChildTest extends BaseTest
$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'));
@@ -161,6 +207,7 @@ class HasChildTest extends BaseTest
$childType->addDocument($child3);
$index->refresh();
+
return $index;
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
index 7998372b..50143dda 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/HasParentTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class HasParentTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,35 +22,41 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
}
- public function testSetScope()
+ /**
+ * @group functional
+ */
+ public function testSetType()
{
- $q = new MatchAll();
+ $index = $this->prepareSearchData();
- $type = 'test';
+ $filter = new HasParent(new MatchAll(), 'type_name');
+ $this->assertEquals('type_name', $filter->getParam('type'));
- $scope = 'foo';
+ $filter->setType('new_type_name');
+ $this->assertEquals('new_type_name', $filter->getParam('type'));
- $filter = new HasParent($q, $type);
- $filter->setScope($scope);
+ $type = $index->getType('foo');
+ $filter = new HasParent(new MatchAll(), $type);
+ $this->assertEquals('foo', $filter->getParam('type'));
- $expectedArray = array(
- 'has_parent' => array(
- 'query' => $q->toArray(),
- 'type' => $type,
- '_scope' => $scope
- )
- );
+ $type = $index->getType('bar');
+ $filter->setType($type);
+ $this->assertEquals('bar', $filter->getParam('type'));
- $this->assertEquals($expectedArray, $filter->toArray());
+ $returnValue = $filter->setType('last');
+ $this->assertInstanceOf('Elastica\Filter\HasParent', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testFilterInsideHasParent()
{
$f = new \Elastica\Filter\MatchAll();
@@ -60,14 +68,16 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'filter' => $f->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testFilterInsideHasParentSearch()
{
$index = $this->prepareSearchData();
@@ -77,7 +87,7 @@ class HasParentTest extends BaseTest
$filter = new HasParent($f, 'parent');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -88,6 +98,9 @@ class HasParentTest extends BaseTest
$this->assertEquals($expected, $result);
}
+ /**
+ * @group functional
+ */
public function testQueryInsideHasParentSearch()
{
$index = $this->prepareSearchData();
@@ -97,7 +110,7 @@ class HasParentTest extends BaseTest
$filter = new HasParent($f, 'parent');
$searchQuery = new \Elastica\Query();
- $searchQuery->setFilter($filter);
+ $searchQuery->setPostFilter($filter);
$searchResults = $index->search($searchQuery);
$this->assertEquals(1, $searchResults->count());
@@ -134,6 +147,7 @@ class HasParentTest extends BaseTest
$childType->addDocument($child2);
$index->refresh();
+
return $index;
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
index 3d6af870..8395f39a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IdsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -10,81 +9,82 @@ use Elastica\Test\Base as BaseTest;
class IdsTest extends BaseTest
{
- protected $_index;
- protected $_type;
-
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
-
- $type1 = $index->getType('helloworld1');
- $type2 = $index->getType('helloworld2');
+ $index = $this->_createIndex();
// Add documents to first type
+ $docs = array();
for ($i = 1; $i < 100; $i++) {
- $doc = new Document($i, array('name' => 'ruflin'));
- $type1->addDocument($doc);
+ $docs[] = new Document($i, array('name' => 'ruflin'));
}
+ $index->getType('helloworld1')->addDocuments($docs);
// Add documents to second type
+ $docs = array();
for ($i = 1; $i < 100; $i++) {
- $doc = new Document($i, array('name' => 'ruflin'));
- $type2->addDocument($doc);
+ $docs[] = new Document($i, array('name' => 'ruflin'));
}
-
// This is a special id that will only be in the second type
- $doc = new Document('101', array('name' => 'ruflin'));
- $type2->addDocument($doc);
+ $docs[] = new Document(101, array('name' => 'ruflin'));
+ $index->getType('helloworld2')->addDocuments($docs);
$index->optimize();
$index->refresh();
- $this->_type = $type1;
- $this->_index = $index;
+ return $index;
}
- public function tearDown()
+ protected function _getTypeForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->delete();
+ return $this->_getIndexForTest()->getType('helloworld1');
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchSingle()
{
$filter = new Ids();
$filter->setIds('1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchArray()
{
$filter = new Ids();
$filter->setIds(array(1, 7, 13));
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingle()
{
$filter = new Ids();
$filter->addId('39');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingleNotInType()
{
$filter = new Ids();
@@ -94,11 +94,14 @@ class IdsTest extends BaseTest
$filter->addId(104);
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testComboIdsSearchArray()
{
$filter = new Ids();
@@ -106,11 +109,14 @@ class IdsTest extends BaseTest
$filter->addId('39');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingle()
{
$filter = new Ids();
@@ -118,11 +124,14 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArray()
{
$filter = new Ids();
@@ -130,11 +139,14 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingleDocInOtherType()
{
$filter = new Ids();
@@ -144,12 +156,15 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
// ...therefore 0 results should be returned
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArrayDocInOtherType()
{
$filter = new Ids();
@@ -159,12 +174,15 @@ class IdsTest extends BaseTest
$filter->setType('helloworld1');
$query = Query::create($filter);
- $resultSet = $this->_type->search($query);
+ $resultSet = $this->_getTypeForTest()->search($query);
// ...therefore only 1 result should be returned
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchArray()
{
$filter = new Ids();
@@ -172,11 +190,14 @@ class IdsTest extends BaseTest
$filter->setType(array('helloworld1', 'helloworld2'));
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchSingle()
{
$filter = new Ids();
@@ -184,18 +205,40 @@ class IdsTest extends BaseTest
$filter->setType(array('helloworld1', 'helloworld2'));
$query = Query::create($filter);
- $resultSet = $this->_index->search($query);
+ $resultSet = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group unit
+ */
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();
$filter = new Ids();
}
+
+ /**
+ * @group unit
+ */
+ public function testAddType()
+ {
+ $type = $this->_getClient()->getIndex('indexname')->getType('typename');
+
+ $filter = new Ids();
+
+ $filter->addType('foo');
+ $this->assertEquals(array('foo'), $filter->getParam('type'));
+
+ $filter->addType($type);
+ $this->assertEquals(array('foo', $type->getName()), $filter->getParam('type'));
+
+ $returnValue = $filter->addType('bar');
+ $this->assertInstanceOf('Elastica\Filter\Ids', $returnValue);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
index b682a5ce..bc78aa6b 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/IndicesTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
@@ -13,81 +12,114 @@ use Elastica\Test\Base as BaseTest;
class IndicesTest extends BaseTest
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index1;
-
- /**
- * @var Index
- */
- protected $_index2;
-
- protected function setUp()
- {
- parent::setUp();
- $this->_index1 = $this->_createIndex('indices_filter_1');
- $this->_index2 = $this->_createIndex('indices_filter_2');
- $this->_index1->addAlias("indices_filter");
- $this->_index2->addAlias("indices_filter");
- $docs = array(
- new Document("1", array("color" => "blue")),
- new Document("2", array("color" => "green")),
- new Document("3", array("color" => "blue")),
- new Document("4", array("color" => "yellow")),
- );
- $this->_index1->getType("test")->addDocuments($docs);
- $this->_index2->getType("test")->addDocuments($docs);
- $this->_index1->refresh();
- $this->_index2->refresh();
- }
-
- protected function tearDown()
- {
- $this->_index1->delete();
- $this->_index2->delete();
- parent::tearDown();
- }
-
public function testToArray()
{
$expected = array(
- "indices" => array(
- "indices" => array("index1", "index2"),
- "filter" => array(
- "term" => array("tag" => "wow")
+ 'indices' => array(
+ 'indices' => array('index1', 'index2'),
+ 'filter' => array(
+ 'term' => array('tag' => 'wow'),
),
- "no_match_filter" => array(
- "term" => array("tag" => "such filter")
- )
- )
+ 'no_match_filter' => array(
+ 'term' => array('tag' => 'such filter'),
+ ),
+ ),
);
- $filter = new Indices(new Term(array("tag" => "wow")), array("index1", "index2"));
- $filter->setNoMatchFilter(new Term(array("tag" => "such filter")));
+ $filter = new Indices(new Term(array('tag' => 'wow')), array('index1', 'index2'));
+ $filter->setNoMatchFilter(new Term(array('tag' => 'such filter')));
$this->assertEquals($expected, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testIndicesFilter()
{
- $filter = new Indices(new BoolNot(new Term(array("color" => "blue"))), array($this->_index1->getName()));
- $filter->setNoMatchFilter(new BoolNot(new Term(array("color" => "yellow"))));
+ $docs = array(
+ new Document(1, array('color' => 'blue')),
+ new Document(2, array('color' => 'green')),
+ new Document(3, array('color' => 'blue')),
+ new Document(4, array('color' => 'yellow')),
+ );
+
+ $index1 = $this->_createIndex();
+ $index1->addAlias('indices_filter');
+ $index1->getType('test')->addDocuments($docs);
+ $index1->refresh();
+
+ $index2 = $this->_createIndex();
+ $index2->addAlias('indices_filter');
+ $index2->getType('test')->addDocuments($docs);
+ $index2->refresh();
+
+ $filter = new Indices(new BoolNot(new Term(array('color' => 'blue'))), array($index1->getName()));
+ $filter->setNoMatchFilter(new BoolNot(new Term(array('color' => 'yellow'))));
$query = new Query();
- $query->setFilter($filter);
+ $query->setPostFilter($filter);
// search over the alias
- $index = $this->_getClient()->getIndex("indices_filter");
+ $index = $this->_getClient()->getIndex('indices_filter');
$results = $index->search($query);
// ensure that the proper docs have been filtered out for each index
$this->assertEquals(5, $results->count());
foreach ($results->getResults() as $result) {
$data = $result->getData();
- $color = $data["color"];
- if ($result->getIndex() == $this->_index1->getName()) {
- $this->assertNotEquals("blue", $color);
+ $color = $data['color'];
+ if ($result->getIndex() === $index1->getName()) {
+ $this->assertNotEquals('blue', $color);
} else {
- $this->assertNotEquals("yellow", $color);
+ $this->assertNotEquals('yellow', $color);
}
}
}
+
+ /**
+ * @group unit
+ */
+ public function testSetIndices()
+ {
+ $client = $this->_getClient();
+ $index1 = $client->getIndex('index1');
+ $index2 = $client->getIndex('index2');
+
+ $indices = array('one', 'two');
+ $filter = new Indices(new Term(array('color' => 'blue')), $indices);
+ $this->assertEquals($indices, $filter->getParam('indices'));
+
+ $indices[] = 'three';
+ $filter->setIndices($indices);
+ $this->assertEquals($indices, $filter->getParam('indices'));
+
+ $filter->setIndices(array($index1, $index2));
+ $expected = array($index1->getName(), $index2->getName());
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $returnValue = $filter->setIndices($indices);
+ $this->assertInstanceOf('Elastica\Filter\Indices', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddIndex()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('someindex');
+
+ $filter = new Indices(new Term(array('color' => 'blue')), array());
+
+ $filter->addIndex($index);
+ $expected = array($index->getName());
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $filter->addIndex('foo');
+ $expected = array($index->getName(), 'foo');
+ $this->assertEquals($expected, $filter->getParam('indices'));
+
+ $returnValue = $filter->addIndex('bar');
+ $this->assertInstanceOf('Elastica\Filter\Indices', $returnValue);
+ }
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php
new file mode 100644
index 00000000..0cdfee39
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/LimitTest.php
@@ -0,0 +1,34 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\Limit;
+use Elastica\Test\Base as BaseTest;
+
+class LimitTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testSetType()
+ {
+ $filter = new Limit(10);
+ $this->assertEquals(10, $filter->getParam('value'));
+
+ $this->assertInstanceOf('Elastica\Filter\Limit', $filter->setLimit(20));
+ $this->assertEquals(20, $filter->getParam('value'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Limit(15);
+
+ $expectedArray = array(
+ 'limit' => array('value' => 15),
+ );
+
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
index 6696f11d..9bfd511f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MatchAllTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\MatchAll;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class MatchAllTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new MatchAll();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php
new file mode 100644
index 00000000..f87df790
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MissingTest.php
@@ -0,0 +1,78 @@
+<?php
+namespace Elastica\Test\Filter;
+
+use Elastica\Filter\Missing;
+use Elastica\Test\Base as BaseTest;
+
+class MissingTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Missing('field_name');
+ $expectedArray = array('missing' => array('field' => 'field_name'));
+ $this->assertEquals($expectedArray, $filter->toArray());
+
+ $filter = new Missing('field_name');
+ $filter->setExistence(true);
+ $expectedArray = array('missing' => array('field' => 'field_name', 'existence' => true));
+ $this->assertEquals($expectedArray, $filter->toArray());
+
+ $filter = new Missing('field_name');
+ $filter->setNullValue(true);
+ $expectedArray = array('missing' => array('field' => 'field_name', 'null_value' => true));
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetField()
+ {
+ $filter = new Missing('field_name');
+
+ $this->assertEquals('field_name', $filter->getParam('field'));
+
+ $filter->setField('new_field_name');
+ $this->assertEquals('new_field_name', $filter->getParam('field'));
+
+ $returnValue = $filter->setField('very_new_field_name');
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExistence()
+ {
+ $filter = new Missing('field_name');
+
+ $filter->setExistence(true);
+ $this->assertTrue($filter->getParam('existence'));
+
+ $filter->setExistence(false);
+ $this->assertFalse($filter->getParam('existence'));
+
+ $returnValue = $filter->setExistence(true);
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetNullValue()
+ {
+ $filter = new Missing('field_name');
+
+ $filter->setNullValue(true);
+ $this->assertTrue($filter->getParam('null_value'));
+
+ $filter->setNullValue(false);
+ $this->assertFalse($filter->getParam('null_value'));
+
+ $returnValue = $filter->setNullValue(true);
+ $this->assertInstanceOf('Elastica\Filter\Missing', $returnValue);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
index f6513338..cc8a56e8 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/MultiTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\AbstractMulti;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class AbstractMultiTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$stub = $this->getStub();
@@ -15,6 +17,9 @@ class AbstractMultiTest extends BaseTest
$this->assertEmpty($stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testAddFilter()
{
$stub = $this->getStub();
@@ -23,12 +28,15 @@ class AbstractMultiTest extends BaseTest
$stub->addFilter($filter);
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testSetFilters()
{
$stub = $this->getStub();
@@ -37,12 +45,15 @@ class AbstractMultiTest extends BaseTest
$stub->setFilters(array($filter));
$expected = array(
- $filter->toArray()
+ $filter->toArray(),
);
$this->assertEquals($expected, $stub->getFilters());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$stub = $this->getStub();
@@ -52,13 +63,16 @@ class AbstractMultiTest extends BaseTest
$expected = array(
$stub->getBaseName() => array(
- $filter->toArray()
- )
+ $filter->toArray(),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
}
+ /**
+ * @group unit
+ */
public function testToArrayWithParam()
{
$stub = $this->getStub();
@@ -72,9 +86,9 @@ class AbstractMultiTest extends BaseTest
$stub->getBaseName() => array(
'_cache' => true,
'filters' => array(
- $filter->toArray()
- )
- )
+ $filter->toArray(),
+ ),
+ ),
);
$this->assertEquals($expected, $stub->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
index 12dbb598..96a49a77 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedFilterWithSetFilterTest.php
@@ -1,121 +1,110 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
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
{
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested_abstract_filter');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('user');
- $mapping = new Mapping();
- $mapping->setProperties(
- array(
- 'firstname' => array('type' => 'string', 'store' => 'yes'),
- // default is store => no expected
- 'lastname' => array('type' => 'string'),
- 'hobbies' => array(
- 'type' => 'nested',
- 'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
- )
- );
- $type->setMapping($mapping);
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(1,
- array(
+ $type->setMapping(new Mapping(null, array(
+ 'firstname' => array('type' => 'string', 'store' => 'yes'),
+ // default is store => no expected
+ 'lastname' => array('type' => 'string'),
+ 'hobbies' => array(
+ 'type' => 'nested',
+ 'include_in_parent' => true,
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
+ )));
+
+ $type->addDocuments(array(
+ new Document(1, array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
'hobbies' => array(
- array('hobby' => 'opensource')
- )
- )
- );
- $docs[] = new Document(2,
- array(
+ array('hobby' => 'opensource'),
+ ),
+ )),
+ new Document(2, array(
'firstname' => 'Nicolas',
'lastname' => 'Ippolito',
'hobbies' => array(
array('hobby' => 'opensource'),
array('hobby' => 'guitar'),
- )
- )
- );
- $response = $type->addDocuments($docs);
+ ),
+ )),
+ ));
- // Refresh index
$index->refresh();
- }
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested_abstract_filter');
- $index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
$expectedArray = array(
'nested' => array(
'path' => 'hobbies',
'filter' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
- $this->assertEquals($expectedArray, $f->toArray());
+ $this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testShouldReturnTheRightNumberOfResult()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested_abstract_filter');
- $s->addIndex($i);
- $r = $s->search($f);
+ $client = $this->_getClient();
+ $search = new Search($client);
+ $index = $this->_getIndexForTest();
+ $search->addIndex($index);
+ $resultSet = $search->search($filter);
- $this->assertEquals(1, $r->getTotalHits());
+ $this->assertEquals(1, $resultSet->getTotalHits());
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('opensource'));
- $f->setPath('hobbies');
- $f->setFilter($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('opensource'));
+ $filter->setPath('hobbies');
+ $filter->setFilter($query);
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested_abstract_filter');
- $s->addIndex($i);
- $r = $s->search($f);
- $this->assertEquals(2, $r->getTotalHits());
+ $client = $this->_getClient();
+ $search = new Search($client);
+ $index = $this->_getIndexForTest();
+ $search->addIndex($index);
+ $resultSet = $search->search($filter);
+ $this->assertEquals(2, $resultSet->getTotalHits());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
index 8d0d2004..8eb42d37 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NestedTest.php
@@ -1,21 +1,18 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Document;
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
{
- public function setUp()
+ protected function _getIndexForTest()
{
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested');
- $index->create(array(), true);
+ $index = $this->_createIndex('elastica_test_filter_nested');
$type = $index->getType('user');
$mapping = new Mapping();
$mapping->setProperties(
@@ -26,96 +23,105 @@ class NestedTest extends BaseTest
'hobbies' => array(
'type' => 'nested',
'include_in_parent' => true,
- 'properties' => array('hobby' => array('type' => 'string'))
- )
+ 'properties' => array('hobby' => array('type' => 'string')),
+ ),
)
);
$type->setMapping($mapping);
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(1,
- array(
- 'firstname' => 'Nicolas',
- 'lastname' => 'Ruflin',
- 'hobbies' => array(
- array('hobby' => 'opensource')
+ $response = $type->addDocuments(array(
+ new Document(1,
+ array(
+ 'firstname' => 'Nicolas',
+ 'lastname' => 'Ruflin',
+ 'hobbies' => array(
+ array('hobby' => 'opensource'),
+ ),
)
- )
- );
- $docs[] = new Document(2,
- array(
- 'firstname' => 'Nicolas',
- 'lastname' => 'Ippolito',
- 'hobbies' => array(
- array('hobby' => 'opensource'),
- array('hobby' => 'guitar'),
+ ),
+ new Document(2,
+ array(
+ 'firstname' => 'Nicolas',
+ 'lastname' => 'Ippolito',
+ 'hobbies' => array(
+ array('hobby' => 'opensource'),
+ array('hobby' => 'guitar'),
+ ),
)
- )
- );
- $response = $type->addDocuments($docs);
+ ),
+ ));
- // Refresh index
$index->refresh();
- }
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('elastica_test_filter_nested');
- $index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setQuery($q);
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
$expectedArray = array(
'nested' => array(
'path' => 'hobbies',
'query' => array('terms' => array(
- 'hobby' => array('guitar')
- ))
- )
+ 'hobby' => array('guitar'),
+ )),
+ ),
);
- $this->assertEquals($expectedArray, $f->toArray());
+ $this->assertEquals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testShouldReturnTheRightNumberOfResult()
{
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('guitar'));
- $f->setPath('hobbies');
- $f->setQuery($q);
-
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested');
- $s->addIndex($i);
- $r = $s->search($f);
-
- $this->assertEquals(1, $r->getTotalHits());
-
- $f = new Nested();
- $this->assertEquals(array('nested' => array()), $f->toArray());
- $q = new Terms();
- $q->setTerms('hobby', array('opensource'));
- $f->setPath('hobbies');
- $f->setQuery($q);
-
- $c = $this->_getClient();
- $s = new Search($c);
- $i = $c->getIndex('elastica_test_filter_nested');
- $s->addIndex($i);
- $r = $s->search($f);
- $this->assertEquals(2, $r->getTotalHits());
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('guitar'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($this->_getIndexForTest());
+ $resultSet = $search->search($filter);
+ $this->assertEquals(1, $resultSet->getTotalHits());
+
+ $filter = new Nested();
+ $this->assertEquals(array('nested' => array()), $filter->toArray());
+ $query = new Terms();
+ $query->setTerms('hobby', array('opensource'));
+ $filter->setPath('hobbies');
+ $filter->setQuery($query);
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($this->_getIndexForTest());
+ $resultSet = $search->search($filter);
+ $this->assertEquals(2, $resultSet->getTotalHits());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetJoin()
+ {
+ $filter = new Nested();
+
+ $this->assertTrue($filter->setJoin(true)->getParam('join'));
+
+ $this->assertFalse($filter->setJoin(false)->getParam('join'));
+
+ $returnValue = $filter->setJoin(true);
+ $this->assertInstanceOf('Elastica\Filter\Nested', $returnValue);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
index 6cc2de06..590b5137 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/NumericRangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\NumericRange;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class NumericRangeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddField()
{
$rangeFilter = new NumericRange();
@@ -14,6 +16,9 @@ class NumericRangeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\NumericRange', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$filter = new NumericRange();
@@ -23,8 +28,8 @@ class NumericRangeTest extends BaseTest
$expectedArray = array(
'numeric_range' => array(
- 'name' => $fromTo
- )
+ 'name' => $fromTo,
+ ),
);
$this->assertEquals($expectedArray, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
index 16362140..aab37615 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/PrefixTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
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
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'name';
@@ -18,30 +20,21 @@ class PrefixTest extends BaseTest
$expectedArray = array(
'prefix' => array(
- $field => $prefix
- )
+ $field => $prefix,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
}
+ /**
+ * @group functional
+ */
public function testDifferentPrefixes()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
- /*$indexParams = array(
- 'analysis' => array(
- 'analyzer' => array(
- 'lw' => array(
- 'type' => 'custom',
- 'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
- ),
- )
- );*/
-
$index->create(array(), true);
$type = $index->getType('test');
@@ -50,17 +43,13 @@ class PrefixTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
@@ -86,6 +75,9 @@ class PrefixTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDifferentPrefixesLowercase()
{
$client = $this->_getClient();
@@ -97,10 +89,10 @@ class PrefixTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -112,16 +104,13 @@ class PrefixTest extends BaseTest
);
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
index 0a331098..23754510 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/QueryTest.php
@@ -1,13 +1,15 @@
<?php
-
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
{
+ /**
+ * @group unit
+ */
public function testSimple()
{
$query = new QueryString('foo bar');
@@ -17,13 +19,16 @@ class QueryTest extends BaseTest
'query' => array(
'query_string' => array(
'query' => 'foo bar',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expected, $filter->toArray());
}
+ /**
+ * @group unit
+ */
public function testExtended()
{
$query = new QueryString('foo bar');
@@ -37,8 +42,8 @@ class QueryTest extends BaseTest
'query' => 'foo bar',
),
),
- '_cache' => true
- )
+ '_cache' => true,
+ ),
);
$this->assertEquals($expected, $filter->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
index bf2cb260..b7cad3ac 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Range;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class RangeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testAddField()
{
$rangeFilter = new Range();
@@ -14,19 +16,46 @@ class RangeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\Range', $returnValue);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
+ $field = 'field_name';
+ $range = array('gte' => 10, 'lte' => 99);
+
$filter = new Range();
+ $filter->addField($field, $range);
+ $expectedArray = array('range' => array($field => $range));
+ $this->assertEquals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetExecution()
+ {
+ $field = 'field_name';
+ $range = array('gte' => 10, 'lte' => 99);
+ $filter = new Range('field_name', $range);
- $fromTo = array('from' => 'ra', 'to' => 'ru');
- $filter->addField('name', $fromTo);
+ $filter->setExecution('fielddata');
+ $this->assertEquals('fielddata', $filter->getParam('execution'));
- $expectedArray = array(
- 'range' => array(
- 'name' => $fromTo
- )
- );
+ $returnValue = $filter->setExecution('index');
+ $this->assertInstanceOf('Elastica\Filter\Range', $returnValue);
+ }
- $this->assertEquals($expectedArray, $filter->toArray());
+ /**
+ * Tests that parent fields are not overwritten by the toArray method.
+ *
+ * @group unit
+ */
+ public function testSetCachedNotOverwritten()
+ {
+ $filter = new Range('field_name', array());
+ $filter->setCached(true);
+ $array = $filter->toArray();
+ $this->assertTrue($array['range']['_cache']);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
index e06064dd..6e3a0395 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/RegexpTest.php
@@ -1,14 +1,16 @@
<?php
-
namespace Elastica\Test\Filter;
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
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'name';
@@ -18,13 +20,41 @@ class RegexpTest extends BaseTest
$expectedArray = array(
'regexp' => array(
- $field => $regexp
- )
+ $field => $regexp,
+ ),
);
$this->assertequals($expectedArray, $filter->toArray());
}
+ /**
+ * @group unit
+ */
+ public function testToArrayWithOptions()
+ {
+ $field = 'name';
+ $regexp = 'ruf';
+ $options = array(
+ 'flags' => 'ALL',
+ );
+
+ $filter = new Regexp($field, $regexp, $options);
+
+ $expectedArray = array(
+ 'regexp' => array(
+ $field => array(
+ 'value' => $regexp,
+ 'flags' => 'ALL',
+ ),
+ ),
+ );
+
+ $this->assertequals($expectedArray, $filter->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testDifferentRegexp()
{
$client = $this->_getClient();
@@ -38,17 +68,13 @@ class RegexpTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
@@ -74,6 +100,9 @@ class RegexpTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDifferentRegexpLowercase()
{
$client = $this->_getClient();
@@ -85,10 +114,10 @@ class RegexpTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -99,17 +128,13 @@ class RegexpTest extends BaseTest
)
);
$type->setMapping($mapping);
-
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
index 65ea628e..fdec0381 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/ScriptTest.php
@@ -1,13 +1,15 @@
<?php
-
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
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$string = '_score * 2.0';
@@ -20,11 +22,14 @@ class ScriptTest extends BaseTest
$expected = array(
'script' => array(
'script' => $string,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
+ /**
+ * @group unit
+ */
public function testSetScript()
{
$string = '_score * 2.0';
@@ -45,7 +50,7 @@ class ScriptTest extends BaseTest
'script' => $string,
'params' => $params,
'lang' => $lang,
- )
+ ),
);
$this->assertEquals($expected, $array);
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
index 9a116851..9c8f5a2a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Term;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TermTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Term();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
index 96994730..bb37ba96 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TermsTest.php
@@ -1,54 +1,129 @@
<?php
-
namespace Elastica\Test\Filter;
+use Elastica\Document;
use Elastica\Filter\Terms;
+use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testLookup()
{
- $index = $this->_createIndex('terms_filter_test');
+ $index = $this->_createIndex();
$type1 = $index->getType('musicians');
$type2 = $index->getType('bands');
//index some test data
- $type1->addDocument(new \Elastica\Document(1, array('name' => 'robert', 'lastName' => 'plant')));
- $type1->addDocument(new \Elastica\Document(2, array('name' => 'jimmy', 'lastName' => 'page')));
- $type1->addDocument(new \Elastica\Document(3, array('name' => 'john paul', 'lastName' => 'jones')));
- $type1->addDocument(new \Elastica\Document(4, array('name' => 'john', 'lastName' => 'bonham')));
- $type1->addDocument(new \Elastica\Document(5, array('name' => 'jimi', 'lastName' => 'hendrix')));
+ $type1->addDocuments(array(
+ new Document(1, array('name' => 'robert', 'lastName' => 'plant')),
+ new Document(2, array('name' => 'jimmy', 'lastName' => 'page')),
+ new Document(3, array('name' => 'john paul', 'lastName' => 'jones')),
+ new Document(4, array('name' => 'john', 'lastName' => 'bonham')),
+ new Document(5, array('name' => 'jimi', 'lastName' => 'hendrix')),
+ ));
- $type2->addDocument(new \Elastica\Document('led zeppelin', array('members' => array('plant', 'page', 'jones', 'bonham'))));
+ $type2->addDocument(new Document('led zeppelin', array('members' => array('plant', 'page', 'jones', 'bonham'))));
$index->refresh();
//use the terms lookup feature to query for some data
$termsFilter = new Terms();
- $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', NULL);
- $query = new \Elastica\Query();
- $query->setFilter($termsFilter);
+ $termsFilter->setLookup('lastName', $type2, 'led zeppelin', 'members', null);
+ $query = new 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->setFilter($termsFilter);
+ $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->setFilter($termsFilter);
+ $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->setFilter($termsFilter);
+ $query->setPostFilter($termsFilter);
$results = $index->search($query);
$this->assertEquals($results->count(), 4, 'Terms lookup with options array');
-
+
$index->delete();
}
+
+ /**
+ * @group unit
+ */
+ public function testSetExecution()
+ {
+ $filter = new Terms('color', array('blue', 'green'));
+
+ $filter->setExecution('bool');
+ $this->assertEquals('bool', $filter->getParam('execution'));
+
+ $returnValue = $filter->setExecution('bool');
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetTerms()
+ {
+ $field = 'color';
+ $terms = array('blue', 'green');
+
+ $filter = new Terms();
+ $filter->setTerms($field, $terms);
+ $expected = array('terms' => array($field => $terms));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $returnValue = $filter->setTerms($field, $terms);
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddTerm()
+ {
+ $filter = new Terms('color', array('blue'));
+
+ $filter->addTerm('green');
+ $expected = array('terms' => array('color' => array('blue', 'green')));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $returnValue = $filter->addTerm('cyan');
+ $this->assertInstanceOf('Elastica\Filter\Terms', $returnValue);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $filter = new Terms('color', array());
+ $expected = array('terms' => array('color' => array()));
+ $this->assertEquals($expected, $filter->toArray());
+
+ $filter = new Terms('color', array('cyan'));
+ $expected = array('terms' => array('color' => array('cyan')));
+ $this->assertEquals($expected, $filter->toArray());
+ }
+
+ /**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testToArrayInvalidException()
+ {
+ $filter = new Terms();
+ $filter->toArray();
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
index fcada826..8da19273 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/TypeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Filter;
use Elastica\Filter\Type;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TypeTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetType()
{
$typeFilter = new Type();
@@ -14,12 +16,15 @@ class TypeTest extends BaseTest
$this->assertInstanceOf('Elastica\Filter\Type', $returnValue);
}
+ /**
+ * @group unit
+ */
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/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
index 4f74d22b..1562c7a0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/SettingsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class SettingsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGet()
{
$indexName = 'elasticatest';
@@ -28,6 +30,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetWithAlias()
{
$indexName = 'elasticatest';
@@ -50,6 +55,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetNumberOfReplicas()
{
$indexName = 'test';
@@ -70,6 +78,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetRefreshInterval()
{
$indexName = 'test';
@@ -91,6 +102,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetRefreshInterval()
{
$indexName = 'test';
@@ -112,6 +126,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergePolicy()
{
$indexName = 'test';
@@ -133,6 +150,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergeFactor()
{
$indexName = 'test';
@@ -157,6 +177,9 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMergePolicyType()
{
$indexName = 'test';
@@ -181,14 +204,16 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetReadOnly()
{
- $index = $this->_createIndex('test');
+ $index = $this->_createIndex();
//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'));
@@ -196,11 +221,11 @@ class SettingsTest extends BaseTest
$type = $index->getType('test');
$type->addDocument($doc1);
- $this->assertEquals('false', $index->getSettings()->get('blocks.read_only')); //ES returns a string for this setting
+ $this->assertFalse($index->getSettings()->getReadOnly());
// Try to add doc to read only index
$index->getSettings()->setReadOnly(true);
- $this->assertEquals('true', $index->getSettings()->get('blocks.read_only'));
+ $this->assertTrue($index->getSettings()->getReadOnly());
try {
$type->addDocument($doc2);
@@ -208,7 +233,7 @@ class SettingsTest extends BaseTest
} catch (ResponseException $e) {
$message = $e->getMessage();
$this->assertContains('ClusterBlockException', $message);
- $this->assertContains('index read-only', $message);
+ $this->assertContains('index write', $message);
}
// Remove read only, add document
@@ -223,10 +248,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
-
+ /**
+ * @group functional
+ */
public function testGetSetBlocksRead()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -244,9 +271,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetSetBlocksWrite()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -264,9 +294,12 @@ class SettingsTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetSetBlocksMetadata()
{
- $index = $this->_createIndex('elastica-test');
+ $index = $this->_createIndex();
$index->refresh();
$settings = $index->getSettings();
@@ -285,16 +318,21 @@ class SettingsTest extends BaseTest
$index->delete();
}
- protected function _waitForAllocation(Index $index)
+ /**
+ * @group functional
+ */
+ public function testNotFoundIndex()
{
- do {
- $settings = $index->getStatus()->get();
- $allocated = true;
- foreach ($settings['shards'] as $shard) {
- if ($shard[0]['routing']['state'] != 'STARTED') {
- $allocated = false;
- }
- }
- } while (!$allocated);
+ $client = $this->_getClient();
+ $index = $client->getIndex('not_found_index');
+ //wait for the shards to be allocated
+
+ try {
+ $settings = $index->getSettings()->get();
+ $this->fail('Should throw exception because of index not found');
+ } catch (ResponseException $e) {
+ $message = $e->getMessage();
+ $this->assertContains('IndexMissingException', $message);
+ }
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
index 5e8e8d57..d0bb7838 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatsTest.php
@@ -1,12 +1,13 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Test\Base as BaseTest;
class StatsTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testGetSettings()
{
$indexName = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
index 8a056a53..24f22ffd 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Index/StatusTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Index;
use Elastica\Index\Status as IndexStatus;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class StatusTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetAliases()
{
$indexName = 'test';
@@ -31,6 +33,9 @@ class StatusTest extends BaseTest
$this->assertTrue(in_array($aliasName, $aliases));
}
+ /**
+ * @group functional
+ */
public function testHasAlias()
{
$indexName = 'test';
@@ -50,6 +55,9 @@ class StatusTest extends BaseTest
$this->assertTrue($status->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testGetSettings()
{
$indexName = 'test';
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
index 8e4ac306..25ac53c2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/IndexTest.php
@@ -1,21 +1,23 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Exception\ResponseException;
use Elastica\Index;
+use Elastica\Query\HasChild;
use Elastica\Query\QueryString;
+use Elastica\Query\SimpleQueryString;
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
{
+ /**
+ * @group functional
+ */
public function testMapping()
{
$index = $this->_createIndex();
@@ -41,13 +43,15 @@ class IndexTest extends BaseTest
$result = $type->search('hanswurst');
}
- public function testGetMappingAlias() {
+ /**
+ * @group functional
+ */
+ public function testGetMappingAlias()
+ {
+ $index = $this->_createIndex();
+ $indexName = $index->getName();
- $indexName = 'test-mapping';
$aliasName = 'test-mapping-alias';
-
- $index = $this->_createIndex($indexName);
- $indexName = $index->getName();
$index->addAlias($aliasName);
$type = new Type($index, 'test');
@@ -71,6 +75,9 @@ class IndexTest extends BaseTest
$this->assertEquals($mapping1, $mapping2);
}
+ /**
+ * @group functional
+ */
public function testParent()
{
$index = $this->_createIndex();
@@ -108,12 +115,15 @@ class IndexTest extends BaseTest
$this->assertEquals(array('title' => 'Foo bar'), $resultSet->current()->getData());
}
+ /**
+ * @group functional
+ */
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 +132,7 @@ class IndexTest extends BaseTest
$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);
@@ -147,12 +157,15 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
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 +174,7 @@ class IndexTest extends BaseTest
$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);
@@ -186,12 +199,15 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
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,33 +216,40 @@ class IndexTest extends BaseTest
$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);
+ $index->optimize();
+ $index->refresh();
+
$doc2 = new Document(2);
$doc2->set('text', 'running in basel');
$type->addDocument($doc2);
$index->optimize();
-
- $resultSet = $type->search('xodoa');
- $this->assertEquals(1, $resultSet->count());
+ $index->refresh();
$resultSet = $type->search('basel');
$this->assertEquals(2, $resultSet->count());
$resultSet = $type->search('ruflin');
$this->assertEquals(0, $resultSet->count());
+
+ $resultSet = $type->search('xodoa');
+ $this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testExcludeFileSource()
{
$this->_checkAttachmentsPlugin();
$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 +267,7 @@ class IndexTest extends BaseTest
$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);
@@ -259,6 +282,7 @@ class IndexTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\ResponseException
*/
public function testAddRemoveAlias()
@@ -297,6 +321,9 @@ class IndexTest extends BaseTest
$client->getIndex($aliasName)->getType($typeName)->search('ruflin');
}
+ /**
+ * @group functional
+ */
public function testCount()
{
$index = $this->_createIndex();
@@ -309,7 +336,6 @@ class IndexTest extends BaseTest
$type->addDocument($doc1);
$type->addDocument($doc2);
-
$index->refresh();
$this->assertEquals(2, $index->count());
@@ -322,6 +348,123 @@ class IndexTest extends BaseTest
$this->assertEquals(1, $index->count($query));
}
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQueryString()
+ {
+ $index = $this->_createIndex();
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery('nicolas');
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQuery()
+ {
+ $index = $this->_createIndex();
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testDeleteByQueryWithQueryAndOptions()
+ {
+ $index = $this->_createIndex(null, true, 2);
+ $type1 = new Type($index, 'test1');
+ $type1->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type1->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type2 = new Type($index, 'test2');
+ $type2->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
+ $type2->addDocument(new Document(2, array('name' => 'ruflin')));
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Route to the wrong document id; should not delete
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '2'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ $response = $index->search('ruflin*');
+ $this->assertEquals(4, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(2, $response->count());
+
+ // Delete first document
+ $response = $index->deleteByQuery(new SimpleQueryString('nicolas'), array('routing' => '1'));
+ $this->assertTrue($response->isOk());
+
+ $index->refresh();
+
+ // Makes sure, document is deleted
+ $response = $index->search('ruflin*');
+ $this->assertEquals(2, $response->count());
+
+ $response = $index->search('nicolas');
+ $this->assertEquals(0, $response->count());
+ }
+
+ /**
+ * @group functional
+ */
public function testDeleteIndexDeleteAlias()
{
$indexName = 'test';
@@ -345,6 +488,9 @@ class IndexTest extends BaseTest
$this->assertFalse($status->aliasExists($aliasName));
}
+ /**
+ * @group functional
+ */
public function testAddAliasTwoIndices()
{
$indexName1 = 'test1';
@@ -356,8 +502,10 @@ class IndexTest extends BaseTest
$index2 = $client->getIndex($indexName2);
$index1->create(array(), true);
+ $this->_waitForAllocation($index1);
$index1->addAlias($aliasName);
$index2->create(array(), true);
+ $this->_waitForAllocation($index2);
$index1->refresh();
$index2->refresh();
@@ -366,7 +514,6 @@ class IndexTest extends BaseTest
$status = new Status($client);
-
$this->assertTrue($status->indexExists($indexName1));
$this->assertTrue($status->indexExists($indexName2));
@@ -379,6 +526,9 @@ class IndexTest extends BaseTest
$this->assertTrue($index2->getStatus()->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testReplaceAlias()
{
$indexName1 = 'test1';
@@ -409,6 +559,9 @@ class IndexTest extends BaseTest
$this->assertTrue($index2->getStatus()->hasAlias($aliasName));
}
+ /**
+ * @group functional
+ */
public function testAddDocumentVersion()
{
$client = $this->_getClient();
@@ -428,24 +581,29 @@ class IndexTest extends BaseTest
$this->assertEquals(2, $data['_version']);
}
+ /**
+ * @group functional
+ */
public function testClearCache()
{
- $client = $this->_getClient();
- $index1 = $client->getIndex('test1');
-
- $response = $index1->clearCache();
+ $index = $this->_createIndex();
+ $response = $index->clearCache();
$this->assertFalse($response->hasError());
}
+ /**
+ * @group functional
+ */
public function testFlush()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test1');
-
+ $index = $this->_createIndex();
$response = $index->flush();
$this->assertFalse($response->hasError());
}
+ /**
+ * @group functional
+ */
public function testExists()
{
$index = $this->_createIndex();
@@ -458,11 +616,13 @@ class IndexTest extends BaseTest
}
/**
- * Test $index->delete() return value for unknown index
+ * Test $index->delete() return value for unknown index.
*
* Tests if deleting an index that does not exist in Elasticsearch,
* correctly returns a boolean true from the hasError() method of
* the \Elastica\Response object
+ *
+ * @group functional
*/
public function testDeleteMissingIndexHasError()
{
@@ -481,7 +641,9 @@ class IndexTest extends BaseTest
}
/**
- * Tests to see if the test type mapping exists when calling $index->getMapping()
+ * Tests to see if the test type mapping exists when calling $index->getMapping().
+ *
+ * @group functional
*/
public function testIndexGetMapping()
{
@@ -504,6 +666,8 @@ class IndexTest extends BaseTest
/**
* Tests to see if the index is empty when there are no types set.
+ *
+ * @group functional
*/
public function testEmptyIndexGetMapping()
{
@@ -514,7 +678,9 @@ class IndexTest extends BaseTest
}
/**
- * Test to see if search Default Limit works
+ * Test to see if search Default Limit works.
+ *
+ * @group functional
*/
public function testLimitDefaultIndex()
{
@@ -551,6 +717,8 @@ class IndexTest extends BaseTest
/**
* @expectedException \Elastica\Exception\InvalidException
+ *
+ * @group functional
*/
public function testCreateArray()
{
@@ -560,22 +728,28 @@ class IndexTest extends BaseTest
//Testing recreate (backward compatibility)
$index = $client->getIndex($indexName);
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
//Testing create index with array options
$opts = array('recreate' => true, 'routing' => 'r1,r2');
$index->create(array(), $opts);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
//Testing invalid options
$opts = array('recreate' => true, 'routing' => 'r1,r2', 'testing_invalid_option' => true);
$index->create(array(), $opts);
+ $this->_waitForAllocation($index);
$status = new Status($client);
$this->assertTrue($status->indexExists($indexName));
}
+ /**
+ * @group functional
+ */
public function testCreateSearch()
{
$client = $this->_getClient();
@@ -589,10 +763,10 @@ class IndexTest extends BaseTest
$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());
@@ -607,6 +781,9 @@ class IndexTest extends BaseTest
$this->assertFalse($search->hasType($type));
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$index = $this->_createIndex();
@@ -636,6 +813,9 @@ class IndexTest extends BaseTest
$this->assertEquals(3, $count);
}
+ /**
+ * @group functional
+ */
public function testOptimize()
{
$index = $this->_createIndex();
@@ -663,9 +843,12 @@ class IndexTest extends BaseTest
$this->assertEquals(0, $stats['_all']['primaries']['docs']['deleted']);
}
+ /**
+ * @group functional
+ */
public function testAnalyze()
{
- $index = $this->_createIndex('analyze');
+ $index = $this->_createIndex();
$index->optimize();
sleep(2);
$returnedTokens = $index->analyze('foo');
@@ -677,13 +860,35 @@ class IndexTest extends BaseTest
'end_offset' => 3,
'type' => '<ALPHANUM>',
'position' => 1,
- )
+ ),
);
$this->assertEquals($tokens, $returnedTokens);
}
/**
+ * @group unit
+ * @expectedException \Elastica\Exception\InvalidException
+ */
+ public function testThrowExceptionIfNotScalar()
+ {
+ $client = $this->_getClient();
+ $client->getIndex(new \stdClass());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertScalarsToString()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex(1);
+
+ $this->assertEquals('1', $index->getName());
+ $this->assertInternalType('string', $index->getName());
+ }
+
+ /**
* Check for the presence of the mapper-attachments plugin and skip the current test if it is not found.
*/
protected function _checkAttachmentsPlugin()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
index 188be933..fdfc5c00 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/LogTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Log;
use Elastica\Test\Base as BaseTest;
use Psr\Log\LogLevel;
@@ -12,45 +10,63 @@ class LogTest extends BaseTest
private $_context = array();
private $_message = 'hello world';
- protected function setUp()
+ public static function setUpBeforeClass()
{
if (!class_exists('Psr\Log\AbstractLogger')) {
- $this->markTestSkipped('The Psr extension is not available.');
+ self::markTestSkipped('The Psr extension is not available.');
}
}
+ /**
+ * @group unit
+ */
public function testLogInterface()
{
$log = new Log();
$this->assertInstanceOf('Psr\Log\LoggerInterface', $log);
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigPath()
{
$logPath = '/tmp/php.log';
- $client = new Client(array('log' => $logPath));
+ $client = $this->_getClient(array('log' => $logPath));
$this->assertEquals($logPath, $client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigEnable()
{
- $client = new Client(array('log' => true));
+ $client = $this->_getClient(array('log' => true));
$this->assertTrue($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testSetLogConfigEnable1()
{
- $client = new Client();
+ $client = $this->_getClient();
$client->setLogger(new Log());
$this->assertFalse($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testEmptyLogConfig()
{
$client = $this->_getClient();
$this->assertEmpty($client->getConfig('log'));
}
+ /**
+ * @group unit
+ */
public function testGetLastMessage()
{
$log = new Log('/tmp/php.log');
@@ -63,14 +79,17 @@ class LogTest extends BaseTest
$this->assertEquals($message, $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessage2()
{
- $client = new Client(array('log' => true));
+ $client = $this->_getClient(array('log' => true));
$log = new Log($client);
// 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);
@@ -81,6 +100,9 @@ class LogTest extends BaseTest
$this->assertEquals($message, $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageInfo()
{
$log = $this->initLog();
@@ -88,6 +110,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageCritical()
{
$log = $this->initLog();
@@ -95,6 +120,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageAlert()
{
$log = $this->initLog();
@@ -102,6 +130,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageDebug()
{
$log = $this->initLog();
@@ -109,6 +140,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageEmergency()
{
$log = $this->initLog();
@@ -116,6 +150,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageError()
{
$log = $this->initLog();
@@ -123,6 +160,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageNotice()
{
$log = $this->initLog();
@@ -130,6 +170,9 @@ class LogTest extends BaseTest
$this->assertEquals($this->getMessage(), $log->getLastMessage());
}
+ /**
+ * @group unit
+ */
public function testGetLastMessageWarning()
{
$log = $this->initLog();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
index a62aaaad..765c8c1d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Multi/SearchTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Multi;
use Elastica\Document;
@@ -41,6 +40,9 @@ class SearchTest extends BaseTest
return $type;
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
@@ -50,6 +52,9 @@ class SearchTest extends BaseTest
$this->assertSame($client, $multiSearch->getClient());
}
+ /**
+ * @group unit
+ */
public function testSetSearches()
{
$client = $this->_getClient();
@@ -79,6 +84,9 @@ class SearchTest extends BaseTest
$this->assertCount(0, $searches);
}
+ /**
+ * @group unit
+ */
public function testSetSearchesByKeys()
{
$client = $this->_getClient();
@@ -108,6 +116,9 @@ class SearchTest extends BaseTest
$this->assertCount(0, $searches);
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$type = $this->_createType();
@@ -200,6 +211,9 @@ class SearchTest extends BaseTest
$this->assertEquals(6, $resultSets[1]->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testSearchWithKeys()
{
$type = $this->_createType();
@@ -217,7 +231,7 @@ class SearchTest extends BaseTest
$query1->setSize(2);
$search1->setQuery($query1);
- $multiSearch->addSearch($search1, "search1");
+ $multiSearch->addSearch($search1, 'search1');
$this->assertCount(1, $multiSearch->getSearches());
@@ -230,13 +244,13 @@ class SearchTest extends BaseTest
$query2->setSize(3);
$search2->setQuery($query2);
- $multiSearch->addSearch($search2, "search2");
+ $multiSearch->addSearch($search2, 'search2');
$this->assertCount(2, $multiSearch->getSearches());
$searches = $multiSearch->getSearches();
- $this->assertSame($search1, $searches["search1"]);
- $this->assertSame($search2, $searches["search2"]);
+ $this->assertSame($search1, $searches['search1']);
+ $this->assertSame($search2, $searches['search2']);
$multiResultSet = $multiSearch->search();
@@ -248,24 +262,24 @@ class SearchTest extends BaseTest
$this->assertInstanceOf('Elastica\ResultSet', $resultSet);
}
- $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet["search1"]);
- $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet["search2"]);
+ $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet['search1']);
+ $this->assertInstanceOf('Elastica\ResultSet', $multiResultSet['search2']);
$resultSets = $multiResultSet->getResultSets();
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertCount(2, $resultSets["search1"]);
- $this->assertSame($query1, $resultSets["search1"]->getQuery());
- $this->assertEquals(3, $resultSets["search1"]->getTotalHits());
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertCount(2, $resultSets['search1']);
+ $this->assertSame($query1, $resultSets['search1']->getQuery());
+ $this->assertEquals(3, $resultSets['search1']->getTotalHits());
- $this->assertArrayHasKey("search2", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search2"]);
- $this->assertCount(3, $resultSets["search2"]);
- $this->assertSame($query2, $resultSets["search2"]->getQuery());
- $this->assertEquals(6, $resultSets["search2"]->getTotalHits());
+ $this->assertArrayHasKey('search2', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search2']);
+ $this->assertCount(3, $resultSets['search2']);
+ $this->assertSame($query2, $resultSets['search2']->getQuery());
+ $this->assertEquals(6, $resultSets['search2']->getTotalHits());
$this->assertFalse($multiResultSet->hasError());
@@ -282,19 +296,22 @@ class SearchTest extends BaseTest
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertCount(0, $resultSets["search1"]);
- $this->assertSame($query1, $resultSets["search1"]->getQuery());
- $this->assertEquals(3, $resultSets["search1"]->getTotalHits());
-
- $this->assertArrayHasKey("search2", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search2"]);
- $this->assertCount(0, $resultSets["search2"]);
- $this->assertSame($query2, $resultSets["search2"]->getQuery());
- $this->assertEquals(6, $resultSets["search2"]->getTotalHits());
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertCount(0, $resultSets['search1']);
+ $this->assertSame($query1, $resultSets['search1']->getQuery());
+ $this->assertEquals(3, $resultSets['search1']->getTotalHits());
+
+ $this->assertArrayHasKey('search2', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search2']);
+ $this->assertCount(0, $resultSets['search2']);
+ $this->assertSame($query2, $resultSets['search2']->getQuery());
+ $this->assertEquals(6, $resultSets['search2']->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testSearchWithError()
{
$type = $this->_createType();
@@ -340,6 +357,9 @@ class SearchTest extends BaseTest
$this->assertTrue($multiResultSet->hasError());
}
+ /**
+ * @group functional
+ */
public function testSearchWithErrorWithKeys()
{
$type = $this->_createType();
@@ -352,7 +372,7 @@ class SearchTest extends BaseTest
$searchGood->setQuery('bunny');
$searchGood->addIndex($index)->addType($type);
- $multiSearch->addSearch($searchGood, "search1");
+ $multiSearch->addSearch($searchGood, 'search1');
$searchBad = new Search($client);
$searchBadQuery = new Range();
@@ -369,11 +389,11 @@ class SearchTest extends BaseTest
$resultSets = $multiResultSet->getResultSets();
$this->assertInternalType('array', $resultSets);
- $this->assertArrayHasKey("search1", $resultSets);
- $this->assertInstanceOf('Elastica\ResultSet', $resultSets["search1"]);
- $this->assertSame($searchGood->getQuery(), $resultSets["search1"]->getQuery());
- $this->assertSame(6, $resultSets["search1"]->getTotalHits());
- $this->assertCount(6, $resultSets["search1"]);
+ $this->assertArrayHasKey('search1', $resultSets);
+ $this->assertInstanceOf('Elastica\ResultSet', $resultSets['search1']);
+ $this->assertSame($searchGood->getQuery(), $resultSets['search1']->getQuery());
+ $this->assertSame(6, $resultSets['search1']->getTotalHits());
+ $this->assertCount(6, $resultSets['search1']);
$this->assertArrayHasKey(0, $resultSets);
$this->assertInstanceOf('Elastica\ResultSet', $resultSets[0]);
@@ -385,6 +405,9 @@ class SearchTest extends BaseTest
$this->assertTrue($multiResultSet->hasError());
}
+ /**
+ * @group functional
+ */
public function testGlobalSearchTypeSearch()
{
$type = $this->_createType();
@@ -466,6 +489,9 @@ class SearchTest extends BaseTest
$this->assertEquals(6, $resultSets[1]->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testGlobalSearchTypeSearchWithKeys()
{
$type = $this->_createType();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
index 10886b2d..812f141e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Node/InfoTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Node;
use Elastica\Node;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class InfoTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGet()
{
$client = $this->_getClient();
@@ -22,11 +24,14 @@ class InfoTest extends BaseTest
// 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'));
}
+ /**
+ * @group functional
+ */
public function testHasPlugin()
{
$client = $this->_getClient();
@@ -35,8 +40,40 @@ class InfoTest extends BaseTest
$info = $node->getInfo();
$pluginName = 'mapper-attachments';
-
+
$this->assertTrue($info->hasPlugin($pluginName));
$this->assertFalse($info->hasPlugin('foo'));
}
+
+ /**
+ * @group functional
+ */
+ public function testGetId()
+ {
+ $client = $this->_getClient();
+ $nodes = $client->getCluster()->getNodes();
+
+ $ids = array();
+
+ foreach ($nodes as $node) {
+ $id = $node->getInfo()->getId();
+
+ // Checks that the ids are unique
+ $this->assertFalse(in_array($id, $ids));
+ $ids[] = $id;
+ }
+ }
+
+ /**
+ * @group functional
+ */
+ public function testGetName()
+ {
+ $client = $this->_getClient();
+ $nodes = $client->getCluster()->getNodes();
+
+ foreach ($nodes as $node) {
+ $this->assertEquals('Elastica', $node->getInfo()->getName());
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
index d70825d1..fbd2d297 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/NodeTest.php
@@ -1,14 +1,14 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
use Elastica\Node;
use Elastica\Test\Base as BaseTest;
class NodeTest extends BaseTest
{
-
+ /**
+ * @group functional
+ */
public function testCreateNode()
{
$client = $this->_getClient();
@@ -19,6 +19,9 @@ class NodeTest extends BaseTest
$this->assertInstanceOf('Elastica\Node', $node);
}
+ /**
+ * @group functional
+ */
public function testGetInfo()
{
$client = $this->_getClient();
@@ -32,6 +35,9 @@ class NodeTest extends BaseTest
$this->assertInstanceOf('Elastica\Node\Info', $info);
}
+ /**
+ * @group functional
+ */
public function testGetStats()
{
$client = $this->_getClient();
@@ -46,39 +52,24 @@ class NodeTest extends BaseTest
}
/**
- * Shuts one of two nodes down (if two available)
+ * @group functional
*/
- public function testShutdown()
+ public function testGetName()
{
- $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
- $client = $this->_getClient();
- $nodes = $client->getCluster()->getNodes();
+ $nodes = $this->_getClient()->getCluster()->getNodes();
+ // At least 1 instance must exist
+ $this->assertGreaterThan(0, $nodes);
- $count = count($nodes);
- if ($count < 2) {
- $this->markTestSkipped('At least two nodes have to be running, because 1 node is shutdown');
+ foreach ($nodes as $node) {
+ $this->assertEquals($node->getName(), 'Elastica');
}
+ }
- // Store node info of node with port 9200 for later
- foreach ($nodes as $key => $node) {
- if ($node->getInfo()->getPort() == 9200) {
- $info = $node->getInfo();
- unset($nodes[$key]);
- }
- }
-
- // Select one of the not port 9200 nodes and shut it down
- $node = array_shift($nodes);
- $node->shutdown('2s');
-
- // Wait until node is shutdown
- sleep(5);
-
- // Use still existing node
- $client = new Client(array('host' => $info->getIp(), 'port' => $info->getPort()));
- $names = $client->getCluster()->getNodeNames();
-
- // One node less ...
- $this->assertEquals($count - 1, count($names));
+ /**
+ * @group functional
+ */
+ public function testGetId()
+ {
+ $node = new Node('Elastica', $this->_getClient());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
index fab77600..eade8118 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ParamTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test;
use Elastica\Param;
-use Elastica\Util;
use Elastica\Test\Base as BaseTest;
+use Elastica\Util;
class ParamTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArrayEmpty()
{
$param = new Param();
@@ -15,6 +17,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($this->_getFilterName($param) => array()), $param->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetParams()
{
$param = new Param();
@@ -25,6 +30,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($this->_getFilterName($param) => $params), $param->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetGetParam()
{
$param = new Param();
@@ -39,6 +47,9 @@ class ParamTest extends BaseTest
$this->assertEquals($value, $param->getParam($key));
}
+ /**
+ * @group unit
+ */
public function testAddParam()
{
$param = new Param();
@@ -52,6 +63,9 @@ class ParamTest extends BaseTest
$this->assertEquals(array($value), $param->getParam($key));
}
+ /**
+ * @group unit
+ */
public function testAddParam2()
{
$param = new Param();
@@ -68,6 +82,7 @@ class ParamTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testGetParamInvalid()
@@ -77,6 +92,9 @@ class ParamTest extends BaseTest
$param->getParam('notest');
}
+ /**
+ * @group unit
+ */
public function testHasParam()
{
$param = new Param();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
index f4cfae0c..2a5a88c3 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/PercolatorTest.php
@@ -1,22 +1,24 @@
<?php
-
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;
class PercolatorTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testConstruct()
{
- $percolatorName = 'percotest';
+ $index = $this->_createIndex();
+ $percolatorName = $index->getName();
- $index = $this->_createIndex($percolatorName);
$percolator = new Percolator($index);
$query = new Term(array('field1' => 'value1'));
@@ -29,7 +31,7 @@ class PercolatorTest extends BaseTest
'_index' => $index->getName(),
'_id' => $percolatorName,
'_version' => 1,
- 'created' => 1
+ 'created' => 1,
);
$this->assertEquals($expectedArray, $data);
@@ -37,12 +39,16 @@ class PercolatorTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testMatchDoc()
{
$index = $this->_createIndex();
+
$percolator = new Percolator($index);
- $percolatorName = 'percotest';
+ $percolatorName = $index->getName();
$query = new Term(array('name' => 'ruflin'));
$response = $percolator->registerQuery($percolatorName, $query);
@@ -77,6 +83,8 @@ class PercolatorTest extends BaseTest
/**
* Test case for using filtered percolator queries based on the Elasticsearch documentation examples.
+ *
+ * @group functional
*/
public function testFilteredMatchDoc()
{
@@ -111,6 +119,8 @@ class PercolatorTest extends BaseTest
/**
* Test case for using filtered percolator queries based on the Elasticsearch documentation examples.
+ *
+ * @group functional
*/
public function testRegisterAndUnregisterPercolator()
{
@@ -140,7 +150,6 @@ class PercolatorTest extends BaseTest
$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');
@@ -162,26 +171,31 @@ class PercolatorTest extends BaseTest
$percolator = new Percolator($index);
$query = new Term(array('name' => 'foobar'));
- $percolator->registerQuery($percolatorName, $query);
+ $percolator->registerQuery($percolatorName, $query, array('field1' => array('tag1', 'tag2')));
+
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'));
- $doc2 = new Document(2, array('name' => 'barbaz'));
- $type->addDocument($doc1);
- $type->addDocument($doc2);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'foobar')),
+ new Document(2, array('name' => 'barbaz')),
+ ));
$index->refresh();
+
return $type;
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithoutAnyParameter()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
$matches = $percolator->matchExistingDoc(1, $type->getName());
@@ -190,28 +204,34 @@ class PercolatorTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithPercolateFormatIds()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
$parameter = array('percolate_format' => 'ids');
- $matches = $percolator->matchExistingDoc(1, $type->getName(), null, $parameter);
+ $matches = $percolator->matchExistingDoc(1, $type->getName(), null, $parameter);
$this->assertCount(1, $matches);
$this->assertEquals('existingDoc', $matches[0]);
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testPercolateExistingDocWithIdThatShouldBeUrlEncoded()
{
$percolator = $this->_getDefaultPercolator();
- $index = $percolator->getIndex();
- $type = $this->_addDefaultDocuments($index);
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
// id with whitespace, should be urlencoded
- $id = "foo bar 1";
+ $id = 'foo bar 1';
$type->addDocument(new Document($id, array('name' => 'foobar')));
$index->refresh();
@@ -221,4 +241,88 @@ class PercolatorTest extends BaseTest
$this->assertCount(1, $matches);
$index->delete();
}
+
+ /**
+ * @group functional
+ */
+ public function testPercolateWithAdditionalRequestBodyOptions()
+ {
+ $index = $this->_createIndex();
+ $percolator = new Percolator($index);
+
+ $query = new Term(array('name' => 'foo'));
+ $response = $percolator->registerQuery('percotest', $query, array('field1' => array('tag1', 'tag2')));
+
+ $this->assertTrue($response->isOk());
+ $this->assertFalse($response->hasError());
+
+ $query = new Term(array('name' => 'foo'));
+ $response = $percolator->registerQuery('percotest1', $query, array('field1' => array('tag2')));
+
+ $this->assertTrue($response->isOk());
+ $this->assertFalse($response->hasError());
+
+ $doc1 = new Document();
+ $doc1->set('name', 'foo');
+
+ $index->refresh();
+
+ $options = array(
+ 'track_scores' => true,
+ 'sort' => array('_score' => 'desc'),
+ 'size' => 1,
+ );
+
+ $matches = $percolator->matchDoc($doc1, new Term(array('field1' => 'tag2')), 'type', $options);
+
+ $this->assertCount(1, $matches);
+ $this->assertEquals('percotest1', $matches[0]['_id']);
+ $this->assertArrayHasKey('_score', $matches[0]);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testPercolateExistingDocWithAdditionalRequestBodyOptions()
+ {
+ $percolatorName = 'existingDoc';
+ $percolator = $this->_getDefaultPercolator($percolatorName);
+
+ $query = new Term(array('name' => 'foobar'));
+ $percolator->registerQuery($percolatorName.'1', $query, array('field1' => array('tag2')));
+
+ $index = $percolator->getIndex();
+ $type = $this->_addDefaultDocuments($index);
+
+ $options = array(
+ 'track_scores' => true,
+ 'sort' => array('_score' => 'desc'),
+ 'size' => 1,
+ );
+
+ $matches = $percolator->matchExistingDoc(1, $type->getName(), new Term(array('field1' => 'tag2')), $options);
+
+ $this->assertCount(1, $matches);
+ $this->assertEquals('existingDoc1', $matches[0]['_id']);
+ $this->assertArrayHasKey('_score', $matches[0]);
+ $index->delete();
+ }
+
+ protected function _createIndex($name = null, $delete = true, $shards = 1)
+ {
+ $index = parent::_createIndex($name, $delete, $shards);
+ $type = $index->getType('.percolator');
+
+ $mapping = new Type\Mapping($type,
+ array(
+ 'name' => array('type' => 'string'),
+ 'field1' => array('type' => 'string'),
+ )
+ );
+ $mapping->disableSource();
+
+ $type->setMapping($mapping);
+
+ return $index;
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php
index d3bd90cd..211d0c23 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoolQueryTest.php
@@ -1,20 +1,22 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Index;
-use Elastica\Query\Bool;
+use Elastica\Query\BoolQuery;
use Elastica\Query\Ids;
use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
use Elastica\Type;
-class BoolTest extends BaseTest
+class BoolQueryTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $query = new Bool();
+ $query = new BoolQuery();
$idsQuery1 = new Ids();
$idsQuery1->setIds(1);
@@ -41,20 +43,22 @@ class BoolTest extends BaseTest
'minimum_number_should_match' => $minMatch,
'must_not' => array($idsQuery2->toArray()),
'boost' => $boost,
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
/**
- * Test to resolve the following issue
+ * Test to resolve the following issue.
+ *
+ * @link https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU
*
- * https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU
+ * @group unit
*/
public function testToArrayStructure()
{
- $boolQuery = new Bool();
+ $boolQuery = new BoolQuery();
$term1 = new Term();
$term1->setParam('interests', 84);
@@ -68,6 +72,9 @@ class BoolTest extends BaseTest
$this->assertEquals($jsonString, json_encode($boolQuery->toArray()));
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -86,7 +93,7 @@ class BoolTest extends BaseTest
// Refresh index
$index->refresh();
- $boolQuery = new Bool();
+ $boolQuery = new BoolQuery();
$termQuery1 = new Term(array('test' => '2'));
$boolQuery->addMust($termQuery1);
$resultSet = $type->search($boolQuery);
@@ -111,4 +118,54 @@ class BoolTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+
+ /**
+ * @group functional
+ */
+ public function testEmptyBoolQuery()
+ {
+ $index = $this->_createIndex();
+ $type = new Type($index, 'test');
+
+ $docNumber = 3;
+ for ($i = 0; $i < $docNumber; $i++) {
+ $doc = new Document($i, array('email' => 'test@test.com'));
+ $type->addDocument($doc);
+ }
+
+ $index->refresh();
+
+ $boolQuery = new BoolQuery();
+
+ $resultSet = $type->search($boolQuery);
+
+ $this->assertEquals($resultSet->count(), $docNumber);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $index = $this->_createIndex();
+ $type = new Type($index, 'test');
+
+ $docNumber = 3;
+ for ($i = 0; $i < $docNumber; $i++) {
+ $doc = new Document($i, array('email' => 'test@test.com'));
+ $type->addDocument($doc);
+ }
+
+ $index->refresh();
+
+ $boolQuery = new \Elastica\Query\Bool();
+
+ $resultSet = $type->search($boolQuery);
+
+ $this->assertEquals($resultSet->count(), $docNumber);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
index f5af8740..8133fd37 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BoostingTest.php
@@ -1,67 +1,54 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Query\Boosting;
+use Elastica\Query\Term;
use Elastica\Test\Base as BaseTest;
class BoostingTest extends BaseTest
{
/**
- * @var \Elastica\Index
- */
- protected $index;
-
- /**
- * @var \Elastica\Type
- */
- protected $type;
-
- /*
* @var array
*/
- protected $sampleData;
-
- protected function setUp()
+ protected $sampleData = array(
+ array('name' => 'Vital Lama', 'price' => 5.2),
+ array('name' => 'Vital Match', 'price' => 2.1),
+ array('name' => 'Mercury Vital', 'price' => 7.5),
+ array('name' => 'Fist Mercury', 'price' => 3.8),
+ array('name' => 'Lama Vital 2nd', 'price' => 3.2),
+ );
+
+ protected function _getTestIndex()
{
- parent::setUp();
- $this->index = $this->_createIndex('test_boostingquery');
- $this->type = $this->index->getType('test');
- $this->type->setMapping(array(
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+ $type->setMapping(array(
'name' => array('type' => 'string', 'index' => 'analyzed'),
- 'price' => array('type' => 'float')
+ 'price' => array('type' => 'float'),
));
-
- $this->sampleData = array(
- array("name" => "Vital Lama", "price" => 5.2),
- array("name" => "Vital Match", "price" => 2.1),
- array("name" => "Mercury Vital", "price" => 7.5),
- array("name" => "Fist Mercury", "price" => 3.8),
- array("name" => "Lama Vital 2nd", "price" => 3.2)
- );
-
- foreach($this->sampleData as $key => $value) {
- $this->type->addDocument(new Document($key, $value));
+ $docs = array();
+ foreach ($this->sampleData as $key => $value) {
+ $docs[] = new Document($key, $value);
}
+ $type->addDocuments($docs);
- $this->index->refresh();
- }
+ $index->refresh();
- protected function tearDown()
- {
- $this->index->delete();
- parent::tearDown();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
- $keyword = "vital";
- $negativeKeyword = "Mercury";
+ $keyword = 'vital';
+ $negativeKeyword = 'Mercury';
$query = new Boosting();
- $positiveQuery = new \Elastica\Query\Term(array('name' => $keyword));
- $negativeQuery = new \Elastica\Query\Term(array('name' => $negativeKeyword));
+ $positiveQuery = new Term(array('name' => $keyword));
+ $negativeQuery = new Term(array('name' => $negativeKeyword));
$query->setPositiveQuery($positiveQuery);
$query->setNegativeQuery($negativeQuery);
$query->setNegativeBoost(0.3);
@@ -70,25 +57,28 @@ class BoostingTest extends BaseTest
'boosting' => array(
'positive' => $positiveQuery->toArray(),
'negative' => $negativeQuery->toArray(),
- 'negative_boost' => 0.3
- )
+ 'negative_boost' => 0.3,
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testNegativeBoost()
{
- $keyword = "vital";
- $negativeKeyword = "mercury";
+ $keyword = 'vital';
+ $negativeKeyword = 'mercury';
$query = new Boosting();
- $positiveQuery = new \Elastica\Query\Term(array('name' => $keyword));
- $negativeQuery = new \Elastica\Query\Term(array('name' => $negativeKeyword));
+ $positiveQuery = new Term(array('name' => $keyword));
+ $negativeQuery = new Term(array('name' => $negativeKeyword));
$query->setPositiveQuery($positiveQuery);
$query->setNegativeQuery($negativeQuery);
$query->setNegativeBoost(0.2);
- $response = $this->type->search($query);
+ $response = $this->_getTestIndex()->search($query);
$results = $response->getResults();
$this->assertEquals($response->getTotalHits(), 4);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
index 5875c4ba..a96e8b3a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/BuilderTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Builder;
@@ -8,21 +7,7 @@ use Elastica\Test\Base as BaseTest;
class BuilderTest extends BaseTest
{
/**
- * @var \Elastica\Query\Builder
- */
- private $builder;
-
- public function setUp()
- {
- $this->builder = new Builder();
- }
-
- public function tearDown()
- {
- $this->builder = null;
- }
-
- /**
+ * @group unit
* @covers \Elastica\Query\Builder::factory
* @covers \Elastica\Query\Builder::__construct
*/
@@ -66,11 +51,12 @@ class BuilderTest extends BaseTest
array('size', 7, '{"size":"7"}'),
array('tieBreakerMultiplier', 7, '{"tie_breaker_multiplier":"7"}'),
array('matchAll', 1.1, '{"match_all":{"boost":"1.1"}}'),
- array('fields', array("age", "sex", "location"), '{"fields":["age","sex","location"]}'),
+ array('fields', array('age', 'sex', 'location'), '{"fields":["age","sex","location"]}'),
);
}
/**
+ * @group unit
* @dataProvider getQueryData
* @covers \Elastica\Query\Builder::__toString
* @covers \Elastica\Query\Builder::allowLeadingWildcard
@@ -99,8 +85,9 @@ class BuilderTest extends BaseTest
*/
public function testAllowLeadingWildcard($method, $argument, $result)
{
- $this->assertSame($this->builder, $this->builder->$method($argument));
- $this->assertSame($result, (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->$method($argument));
+ $this->assertSame($result, (string) $builder);
}
public function getQueryTypes()
@@ -127,11 +114,10 @@ class BuilderTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider getQueryTypes
- *
* @covers \Elastica\Query\Builder::fieldClose
* @covers \Elastica\Query\Builder::close
- *
* @covers \Elastica\Query\Builder::bool
* @covers \Elastica\Query\Builder::boolClose
* @covers \Elastica\Query\Builder::constantScore
@@ -169,12 +155,14 @@ class BuilderTest extends BaseTest
*/
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);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->$method()); // open
+ $this->assertSame($builder, $builder->{$method.'Close'}()); // close
+ $this->assertSame('{"'.$queryType.'":{}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::fieldOpen
* @covers \Elastica\Query\Builder::fieldClose
* @covers \Elastica\Query\Builder::open
@@ -182,44 +170,51 @@ class BuilderTest extends BaseTest
*/
public function testFieldOpenAndClose()
{
- $this->assertSame($this->builder, $this->builder->fieldOpen('someField'));
- $this->assertSame($this->builder, $this->builder->fieldClose());
- $this->assertSame('{"someField":{}}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->fieldOpen('someField'));
+ $this->assertSame($builder, $builder->fieldClose());
+ $this->assertSame('{"someField":{}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::sortField
*/
public function testSortField()
{
- $this->assertSame($this->builder, $this->builder->sortField('name', true));
- $this->assertSame('{"sort":{"name":{"reverse":"true"}}}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->sortField('name', true));
+ $this->assertSame('{"sort":{"name":{"reverse":"true"}}}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::sortFields
*/
public function testSortFields()
{
- $this->assertSame($this->builder, $this->builder->sortFields(array('field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc')));
- $this->assertSame('{"sort":[{"field1":"asc"},{"field2":"desc"},{"field3":"asc"}]}', (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->sortFields(array('field1' => 'asc', 'field2' => 'desc', 'field3' => 'asc')));
+ $this->assertSame('{"sort":[{"field1":"asc"},{"field2":"desc"},{"field3":"asc"}]}', (string) $builder);
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::queries
*/
public function testQueries()
{
$queries = array();
- $b1 = clone $this->builder;
- $b2 = clone $this->builder;
+ $builder = new Builder();
+ $b1 = clone $builder;
+ $b2 = clone $builder;
$queries[] = $b1->term()->field('age', 34)->termClose();
$queries[] = $b2->term()->field('name', 'christer')->termClose();
- $this->assertSame($this->builder, $this->builder->queries($queries));
- $this->assertSame('{"queries":[{"term":{"age":"34"}},{"term":{"name":"christer"}}]}', (string) $this->builder);
+ $this->assertSame($builder, $builder->queries($queries));
+ $this->assertSame('{"queries":[{"term":{"age":"34"}},{"term":{"name":"christer"}}]}', (string) $builder);
}
public function getFieldData()
@@ -234,37 +229,45 @@ class BuilderTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider getFieldData
* @covers \Elastica\Query\Builder::field
*/
public function testField($name, $value, $result)
{
- $this->assertSame($this->builder, $this->builder->field($name, $value));
- $this->assertSame($result, (string) $this->builder);
+ $builder = new Builder();
+ $this->assertSame($builder, $builder->field($name, $value));
+ $this->assertSame($result, (string) $builder);
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
+ * @expectedExceptionMessage The produced query is not a valid json string : "{{}"
* @covers \Elastica\Query\Builder::toArray
*/
public function testToArrayWithInvalidData()
{
- $this->builder->open('foo');
- $this->builder->toArray();
+ $builder = new Builder();
+ $builder->open('foo');
+ $builder->toArray();
}
/**
+ * @group unit
* @covers \Elastica\Query\Builder::toArray
*/
public function testToArray()
{
- $this->builder->query()->term()->field('category.id', array(1, 2, 3))->termClose()->queryClose();
- $this->assertEquals(array(
+ $builder = new Builder();
+ $builder->query()->term()->field('category.id', array(1, 2, 3))->termClose()->queryClose();
+ $expected = array(
'query' => array(
'term' => array(
- 'category.id' => array(1, 2, 3)
- )
- )
- ), $this->builder->toArray());
+ 'category.id' => array(1, 2, 3),
+ ),
+ ),
+ );
+ $this->assertEquals($expected, $builder->toArray());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
index a84d6397..016213a8 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/CommonTest.php
@@ -1,12 +1,15 @@
<?php
-
namespace Elastica\Test\Query;
+use Elastica\Document;
use Elastica\Query\Common;
use Elastica\Test\Base as BaseTest;
class CommonTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Common('body', 'test query', .001);
@@ -17,29 +20,32 @@ class CommonTest extends BaseTest
'body' => array(
'query' => 'test query',
'cutoff_frequency' => .001,
- 'low_freq_operator' => 'and'
- )
- )
+ 'low_freq_operator' => 'and',
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $index = $this->_createIndex('common_test');
+ $index = $this->_createIndex();
$type = $index->getType('test');
+ $docs = array(
+ new Document(1, array('body' => 'foo baz')),
+ new Document(2, array('body' => 'foo bar baz')),
+ new Document(3, array('body' => 'foo bar baz bat')),
+ );
//add documents to create common terms
- $docs = array();
- for ($i = 0; $i < 20; $i++) {
- $docs[] = new \Elastica\Document($i, array('body' => 'foo bar'));
+ for ($i = 4; $i < 24; $i++) {
+ $docs[] = new Document($i, array('body' => 'foo bar'));
}
$type->addDocuments($docs);
-
- $type->addDocument(new \Elastica\Document(20, array('body' => 'foo baz')));
- $type->addDocument(new \Elastica\Document(21, array('body' => 'foo bar baz')));
- $type->addDocument(new \Elastica\Document(22, array('body' => 'foo bar baz bat')));
$index->refresh();
$query = new Common('body', 'foo bar baz bat', .5);
@@ -53,7 +59,5 @@ class CommonTest extends BaseTest
//only the document containing both low frequency terms should match
$this->assertEquals(1, $results->count());
-
- $index->delete();
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
index 27143eb6..a3a213b9 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ConstantScoreTest.php
@@ -1,15 +1,13 @@
<?php
-
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
{
@@ -55,6 +53,7 @@ class ConstantScoreTest extends BaseTest
);
}
/**
+ * @group unit
* @dataProvider dataProviderSampleQueries
*/
public function testSimple($filter, $expected)
@@ -67,6 +66,9 @@ class ConstantScoreTest extends BaseTest
$this->assertEquals($expected, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new ConstantScore();
@@ -81,13 +83,16 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$filter = new Ids();
@@ -98,28 +103,25 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'filter' => $filter->toArray(),
- )
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
-
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
+ $index = $this->_createIndex();
- $client = $this->_getClient();
- $index = new Index($client, 'test');
- $index->create(array(), true);
-
- $type = new Type($index, 'constant_score');
-
- $doc = new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans'));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil'));
- $type->addDocument($doc);
- $doc = new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth'));
- $type->addDocument($doc);
+ $type = $index->getType('constant_score');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'hans@test.com', 'username' => 'hans')),
+ new Document(2, array('id' => 2, 'email' => 'emil@test.com', 'username' => 'emil')),
+ new Document(3, array('id' => 3, 'email' => 'ruth@test.com', 'username' => 'ruth')),
+ ));
// Refresh index
$index->refresh();
@@ -134,8 +136,8 @@ class ConstantScoreTest extends BaseTest
$expectedArray = array(
'constant_score' => array(
'query' => $query_match->toArray(),
- 'boost' => $boost
- )
+ 'boost' => $boost,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
@@ -145,9 +147,11 @@ class ConstantScoreTest extends BaseTest
$this->assertEquals($resultSet->count(), 3);
$this->assertEquals($results[1]->getScore(), 1);
-
}
+ /**
+ * @group unit
+ */
public function testConstructEmpty()
{
$query = new ConstantScore();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
index 31c8437d..2c128018 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/DisMaxTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -10,6 +9,9 @@ use Elastica\Test\Base as BaseTest;
class DisMaxTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new DisMax();
@@ -39,29 +41,28 @@ class DisMaxTest extends BaseTest
'queries' => array(
$idsQuery1->toArray(),
$idsQuery2->toArray(),
- $idsQuery3->toArray()
- )
- )
+ $idsQuery3->toArray(),
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php
new file mode 100644
index 00000000..536a7bb3
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/EscapeStringTest.php
@@ -0,0 +1,36 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query\QueryString;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
+use Elastica\Util;
+
+class EscapeStringTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ public function testSearch()
+ {
+ $index = $this->_createIndex();
+ $index->getSettings()->setNumberOfReplicas(0);
+
+ $type = new Type($index, 'helloworld');
+
+ $doc = new Document(1, array(
+ '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'));
+ $resultSet = $type->search($queryString);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
index c6bd9096..c4bea6f2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FilteredTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -10,15 +9,18 @@ use Elastica\Test\Base as BaseTest;
class FilteredTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilteredSearch()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
$queryString = new QueryString('test*');
@@ -42,6 +44,9 @@ class FilteredTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testFilteredGetter()
{
$queryString = new QueryString('test*');
@@ -62,6 +67,7 @@ class FilteredTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testFilteredWithoutArgumentsShouldRaiseException()
@@ -69,27 +75,34 @@ class FilteredTest extends BaseTest
$query = new Filtered();
$query->toArray();
}
-
+
+ /**
+ * @group functional
+ */
public function testFilteredSearchNoQuery()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'email' => 'test@test.com', 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
+
+ $index->refresh();
$filter = new Term();
$filter->setTerm('username', 'peter');
$query = new Filtered(null, $filter);
- $index->refresh();
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
+
+ /**
+ * @group functional
+ */
public function testFilteredSearchNoFilter()
{
$index = $this->_createIndex();
@@ -108,5 +121,4 @@ class FilteredTest extends BaseTest
$resultSet = $type->search($query);
$this->assertEquals(1, $resultSet->count());
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
index 47d9dd2c..25600034 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FunctionScoreTest.php
@@ -1,70 +1,56 @@
<?php
-/**
- * User: Joe Linn
- * Date: 9/16/13
- * Time: 5:05 PM
- */
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Filter\Term;
use Elastica\Query\FunctionScore;
+use Elastica\Query\MatchAll;
use Elastica\Script;
use Elastica\Test\Base as BaseTest;
class FunctionScoreTest extends BaseTest
{
- /**
- * @var \Elastica\Index
- */
- protected $index;
-
- /**
- * @var \Elastica\Type
- */
- protected $type;
-
- protected $locationOrigin = "32.804654, -117.242594";
+ protected $locationOrigin = '32.804654, -117.242594';
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->index = $this->_createIndex('test_functionscore');
- $this->type = $this->index->getType('test');
- $this->type->setMapping(array(
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
+
+ $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
- )));
- $this->type->addDocument(new Document(2, array(
- 'name' => "Miller's Field",
- 'location' => array('lat' => 32.795964, 'lon' => -117.255028),
- 'price' => 9.5
- )));
-
- $this->index->refresh();
- }
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'name' => "Mr. Frostie's",
+ 'location' => array('lat' => 32.799605, 'lon' => -117.243027),
+ 'price' => 4.5,
+ )),
+ new Document(2, array(
+ 'name' => "Miller's Field",
+ 'location' => array('lat' => 32.795964, 'lon' => -117.255028),
+ 'price' => 9.5,
+ )),
+ ));
- protected function tearDown()
- {
- $this->index->delete();
- parent::tearDown();
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$priceOrigin = 0;
$locationScale = '2mi';
$priceScale = 9.25;
$query = new FunctionScore();
- $childQuery = new \Elastica\Query\MatchAll();
+ $childQuery = new MatchAll();
$query->setQuery($childQuery);
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, $locationScale);
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale);
@@ -76,30 +62,82 @@ class FunctionScoreTest extends BaseTest
'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());
}
+ /**
+ * @group unit
+ */
+ public function testDecayWeight()
+ {
+ $priceOrigin = 0;
+ $locationScale = '2mi';
+ $priceScale = 9.25;
+ $query = new FunctionScore();
+ $childQuery = new MatchAll();
+ $query->setQuery($childQuery);
+ $query->addDecayFunction(
+ FunctionScore::DECAY_GAUSS,
+ 'location',
+ $this->locationOrigin,
+ $locationScale,
+ null,
+ null,
+ .5
+ );
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale, null, null, 2);
+ $expected = array(
+ 'function_score' => array(
+ 'query' => $childQuery->toArray(),
+ 'functions' => array(
+ array(
+ 'gauss' => array(
+ 'location' => array(
+ 'origin' => $this->locationOrigin,
+ 'scale' => $locationScale,
+ ),
+ ),
+ 'weight' => .5,
+ ),
+ array(
+ 'gauss' => array(
+ 'price' => array(
+ 'origin' => $priceOrigin,
+ 'scale' => $priceScale,
+ ),
+ ),
+ 'weight' => 2,
+ ),
+ ),
+ ),
+ );
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testGauss()
{
$query = new FunctionScore();
- $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, "4mi");
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, '4mi');
$query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10);
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with the closest location and lowest price should be scored highest
@@ -107,7 +145,10 @@ class FunctionScoreTest extends BaseTest
$this->assertEquals("Mr. Frostie's", $result0['name']);
}
- public function testBoostFactor()
+ /**
+ * @group functional
+ */
+ public function testWeight()
{
$filter = new Term(array('price' => 4.5));
$query = new FunctionScore();
@@ -116,20 +157,20 @@ class FunctionScoreTest extends BaseTest
'function_score' => array(
'functions' => array(
array(
- 'boost_factor' => 5.0,
+ 'weight' => 5.0,
'filter' => array(
'term' => array(
- 'price' => 4.5
- )
- )
- )
- )
- )
+ 'price' => 4.5,
+ ),
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with price = 4.5 should be scored highest
@@ -137,6 +178,9 @@ class FunctionScoreTest extends BaseTest
$this->assertEquals("Mr. Frostie's", $result0['name']);
}
+ /**
+ * @group functional
+ */
public function testRandomScore()
{
$filter = new Term(array('price' => 4.5));
@@ -147,39 +191,74 @@ class FunctionScoreTest extends BaseTest
'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());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document with the random score should have a score > 1, means it is the first result
- $result0 = $results[1]->getData();
-
+ $result0 = $results[0]->getData();
+
$this->assertEquals("Miller's Field", $result0['name']);
}
+ /**
+ * @group unit
+ */
+ public function testRandomScoreWeight()
+ {
+ $filter = new Term(array('price' => 4.5));
+ $query = new FunctionScore();
+ $query->addRandomScoreFunction(2, $filter, 2);
+ $expected = array(
+ 'function_score' => array(
+ 'functions' => array(
+ array(
+ 'random_score' => array(
+ 'seed' => 2,
+ ),
+ 'filter' => array(
+ 'term' => array(
+ 'price' => 4.5,
+ ),
+ ),
+ 'weight' => 2,
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
public function testRandomScoreWithoutSeed()
{
$query = new FunctionScore();
$query->setRandomScore();
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$this->assertEquals(2, $response->count());
}
+ /**
+ * @group functional
+ */
public function testScriptScore()
{
$scriptString = "_score * doc['price'].value";
@@ -191,20 +270,55 @@ class FunctionScoreTest extends BaseTest
'functions' => array(
array(
'script_score' => array(
- 'script' => $scriptString
- )
- )
- )
- )
+ 'script' => $scriptString,
+ ),
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $query->toArray());
- $response = $this->type->search($query);
+ $response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
// the document the highest price should be scored highest
$result0 = $results[0]->getData();
$this->assertEquals("Miller's Field", $result0['name']);
}
+
+ /**
+ * @group functional
+ */
+ public function testSetMinScore()
+ {
+ $expected = array(
+ 'function_score' => array(
+ 'min_score' => 0.8,
+ 'functions' => array(
+ array(
+ 'gauss' => array(
+ 'price' => array(
+ 'origin' => 0,
+ 'scale' => 10,
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+
+ $query = new FunctionScore();
+ $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10);
+ $returnedValue = $query->setMinScore(0.8);
+
+ $this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\FunctionScore', $returnedValue);
+
+ $response = $this->_getIndexForTest()->search($query);
+ $results = $response->getResults();
+
+ $this->assertCount(1, $results);
+ $this->assertEquals(1, $results[0]->getId());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
index c842c1a8..fe11e788 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyLikeThisTest.php
@@ -1,16 +1,18 @@
<?php
-
namespace Elastica\Test\Query;
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
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -20,7 +22,7 @@ class FuzzyLikeThisTest extends BaseTest
//$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'),
));
@@ -35,14 +37,17 @@ class FuzzyLikeThisTest extends BaseTest
$index->refresh();
$fltQuery = new FuzzyLikeThis();
- $fltQuery->setLikeText("sample gmail");
- $fltQuery->addFields(array("email","content"));
+ $fltQuery->setLikeText('sample gmail');
+ $fltQuery->addFields(array('email', 'content'));
$fltQuery->setMinSimilarity(0.3);
$fltQuery->setMaxQueryTerms(3);
$resultSet = $type->search($fltQuery);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetPrefixLength()
{
$query = new FuzzyLikeThis();
@@ -55,6 +60,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($length, $data['fuzzy_like_this']['prefix_length']);
}
+ /**
+ * @group unit
+ */
public function testAddFields()
{
$query = new FuzzyLikeThis();
@@ -67,6 +75,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($fields, $data['fuzzy_like_this']['fields']);
}
+ /**
+ * @group unit
+ */
public function testSetLikeText()
{
$query = new FuzzyLikeThis();
@@ -79,6 +90,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals(trim($text), $data['fuzzy_like_this']['like_text']);
}
+ /**
+ * @group unit
+ */
public function testSetIgnoreTF()
{
$query = new FuzzyLikeThis();
@@ -94,6 +108,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($ignoreTF, $data['fuzzy_like_this']['ignore_tf']);
}
+ /**
+ * @group unit
+ */
public function testSetIgnoreTFDefault()
{
$query = new FuzzyLikeThis();
@@ -104,6 +121,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($defaultIgnoreTF, $data['fuzzy_like_this']['ignore_tf']);
}
+ /**
+ * @group unit
+ */
public function testSetMinSimilarity()
{
$query = new FuzzyLikeThis();
@@ -116,6 +136,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($similarity, $data['fuzzy_like_this']['min_similarity']);
}
+ /**
+ * @group unit
+ */
public function testSetBoost()
{
$query = new FuzzyLikeThis();
@@ -128,6 +151,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($boost, $data['fuzzy_like_this']['boost']);
}
+ /**
+ * @group unit
+ */
public function testAddAnalyzerViasetParam()
{
$analyzer = 'snowball';
@@ -139,6 +165,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $data['fuzzy_like_this']['analyzer']);
}
+ /**
+ * @group unit
+ */
public function testSetAnalyzer()
{
$analyzer = 'snowball';
@@ -150,6 +179,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $data['fuzzy_like_this']['analyzer']);
}
+ /**
+ * @group unit
+ */
public function testAnalyzerNotPresentInArrayToMaintainDefaultOfField()
{
$query = new FuzzyLikeThis();
@@ -158,6 +190,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertArrayNotHasKey('analyzer', $data);
}
+ /**
+ * @group unit
+ */
public function testArgArrayFieldsOverwrittenBySetParams()
{
$query = new FuzzyLikeThis();
@@ -168,6 +203,9 @@ class FuzzyLikeThisTest extends BaseTest
$this->assertEquals(200, $data['fuzzy_like_this']['max_query_terms']);
}
+ /**
+ * @group functional
+ */
public function testSearchSetAnalyzer()
{
$client = $this->_getClient();
@@ -177,41 +215,40 @@ class FuzzyLikeThisTest extends BaseTest
'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);
- $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'The Fuzzy Test!'));
- $type->addDocument($doc);
-
- $doc = new Document(1001, array('email' => 'testemail@gmail.com', 'content' => 'Elastica Fuzzy Test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'The Fuzzy Test!')),
+ new Document(1001, array('email' => 'testemail@gmail.com', 'content' => 'Elastica Fuzzy Test')),
+ ));
// Refresh index
$index->refresh();
$fltQuery = new FuzzyLikeThis();
- $fltQuery->addFields(array("email","content"));
- $fltQuery->setLikeText("The");
+ $fltQuery->addFields(array('email', 'content'));
+ $fltQuery->setLikeText('The');
$fltQuery->setMinSimilarity(0.1);
$fltQuery->setMaxQueryTerms(3);
@@ -225,4 +262,39 @@ class FuzzyLikeThisTest extends BaseTest
$resultSet = $type->search($fltQuery);
$this->assertEquals(0, $resultSet->count());
}
+
+ /**
+ * @group functional
+ */
+ public function testNoLikeTextProvidedShouldReturnNoResults()
+ {
+ $client = $this->_getClient();
+ $index = new Index($client, 'test');
+ $index->create(array(), true);
+ $index->getSettings()->setNumberOfReplicas(0);
+
+ $type = new Type($index, 'helloworldfuzzy');
+ $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);
+
+ $doc = new Document(1000, array('email' => 'testemail@gmail.com', 'content' => 'This is a sample post. Hello World Fuzzy Like This!'));
+ $type->addDocument($doc);
+
+ // Refresh index
+ $index->refresh();
+
+ $fltQuery = new FuzzyLikeThis();
+ $fltQuery->setLikeText('');
+ $fltQuery->addFields(array('email', 'content'));
+ $fltQuery->setMinSimilarity(0.3);
+ $fltQuery->setMaxQueryTerms(3);
+ $resultSet = $type->search($fltQuery);
+
+ $this->assertEquals(0, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
index 57659293..e9107232 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/FuzzyTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class FuzzyTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$fuzzy = new Fuzzy();
@@ -16,9 +18,9 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray(), 'Deprecated method failed');
@@ -27,8 +29,8 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- )
- )
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
@@ -38,13 +40,16 @@ class FuzzyTest extends BaseTest
'fuzzy' => array(
'user' => array(
'value' => 'Nicolas',
- 'boost' => 1.0
- )
- )
+ 'boost' => 1.0,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $fuzzy->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -52,14 +57,12 @@ class FuzzyTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
@@ -73,7 +76,10 @@ class FuzzyTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
- public function testBadArguments ()
+ /**
+ * @group unit
+ */
+ public function testBadArguments()
{
$this->setExpectedException('Elastica\Exception\InvalidException');
$query = new Fuzzy();
@@ -88,20 +94,21 @@ class FuzzyTest extends BaseTest
$query->setField('name', 'value');
$query->setField('name1', 'value1');
}
-
- public function testFuzzyWithFacets() {
+ /**
+ * @group functional
+ */
+ public function testFuzzyWithFacets()
+ {
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ ));
$index->refresh();
@@ -109,21 +116,21 @@ class FuzzyTest extends BaseTest
$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/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
index bb1b5b96..a717b1ab 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasChildTest.php
@@ -1,14 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
+use Elastica\Query;
use Elastica\Query\HasChild;
+use Elastica\Query\Match;
use Elastica\Query\MatchAll;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class HasChildTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -20,13 +25,16 @@ class HasChildTest extends BaseTest
$expectedArray = array(
'has_child' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetScope()
{
$q = new MatchAll();
@@ -42,55 +50,56 @@ class HasChildTest extends BaseTest
'has_child' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
-
+
+ /**
+ * @group functional
+ */
public function testTypeInsideHasChildSearch()
{
- $index = $this->prepareSearchData();
-
- $f = new \Elastica\Query\Match();
+ $index = $this->_getTestIndex();
+
+ $f = new Match();
$f->setField('alt.name', 'testname');
$query = new HasChild($f, 'child');
-
- $searchQuery = new \Elastica\Query();
+
+ $searchQuery = new 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()
+ }
+
+ protected function _getTestIndex()
{
- $client = $this->_getClient();
- $index = $client->getIndex('has_child_test');
- $index->create(array(), true);
-
+ $index = $this->_createIndex('has_child_test');
+
$parentType = $index->getType('parent');
-
+
$childType = $index->getType('child');
- $childMapping = new \Elastica\Type\Mapping($childType);
+ $childMapping = new 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 +109,9 @@ class HasChildTest extends BaseTest
$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/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
index d417c887..31a89852 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HasParentTest.php
@@ -1,13 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
+use Elastica\Document;
use Elastica\Query\HasParent;
+use Elastica\Query\Match;
use Elastica\Query\MatchAll;
+use Elastica\Search;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class HasParentTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$q = new MatchAll();
@@ -19,13 +25,16 @@ class HasParentTest extends BaseTest
$expectedArray = array(
'has_parent' => array(
'query' => $q->toArray(),
- 'type' => $type
- )
+ 'type' => $type,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetScope()
{
$q = new MatchAll();
@@ -41,10 +50,59 @@ class HasParentTest extends BaseTest
'has_parent' => array(
'query' => $q->toArray(),
'type' => $type,
- '_scope' => $scope
- )
+ '_scope' => $scope,
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+
+ /**
+ * @group functional
+ */
+ public function testHasParent()
+ {
+ $index = $this->_createIndex();
+
+ $shopType = $index->getType('shop');
+ $productType = $index->getType('product');
+ $mapping = new Mapping();
+ $mapping->setParent('shop');
+ $productType->setMapping($mapping);
+
+ $shopType->addDocuments(
+ array(
+ new Document('zurich', array('brand' => 'google')),
+ new Document('london', array('brand' => 'apple')),
+ )
+ );
+
+ $doc1 = new Document(1, array('device' => 'chromebook'));
+ $doc1->setParent('zurich');
+
+ $doc2 = new Document(2, array('device' => 'macmini'));
+ $doc2->setParent('london');
+
+ $productType->addDocument($doc1);
+ $productType->addDocument($doc2);
+
+ $index->refresh();
+
+ // All documents
+ $parentQuery = new HasParent(new MatchAll(), $shopType->getName());
+ $search = new Search($index->getClient());
+ $results = $search->search($parentQuery);
+ $this->assertEquals(2, $results->count());
+
+ $match = new Match();
+ $match->setField('brand', 'google');
+
+ $parentQuery = new HasParent($match, $shopType->getName());
+ $search = new Search($index->getClient());
+ $results = $search->search($parentQuery);
+ $this->assertEquals(1, $results->count());
+ $result = $results->current();
+ $data = $result->getData();
+ $this->assertEquals($data['device'], 'chromebook');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
index 4b1b6c5e..c6850019 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/HighlightTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,19 +8,20 @@ use Elastica\Test\Base as BaseTest;
class HighlightTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testHightlightSearch()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('helloworld');
$phrase = 'My name is ruflin';
- $doc = new Document(1, array('id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
- $doc = new Document(2, array('id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => array('2', '3', '5')));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'phrase' => $phrase, 'username' => 'hanswurst', 'test' => array('2', '3', '5'))),
+ new Document(2, array('id' => 2, 'phrase' => $phrase, 'username' => 'peter', 'test' => array('2', '3', '5'))),
+ ));
$queryString = new QueryString('rufl*');
$query = new Query($queryString);
@@ -44,6 +44,5 @@ class HighlightTest extends BaseTest
$this->assertEquals(array('phrase' => array(0 => 'My name is <em class="highlight">ruflin</em>')), $highlight);
}
$this->assertEquals(2, $resultSet->count());
-
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
index d1bf901e..7b39020f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/IdsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -11,11 +10,11 @@ class IdsTest extends BaseTest
protected $_index;
protected $_type;
- public function setUp()
+ protected function setUp()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ parent::setUp();
+
+ $index = $this->_createIndex();
$type1 = $index->getType('helloworld1');
$type2 = $index->getType('helloworld2');
@@ -38,13 +37,9 @@ class IdsTest extends BaseTest
$this->_index = $index;
}
- public function tearDown()
- {
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->delete();
- }
-
+ /**
+ * @group functional
+ */
public function testSetIdsSearchSingle()
{
$query = new Ids();
@@ -55,6 +50,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetIdsSearchArray()
{
$query = new Ids();
@@ -65,6 +63,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAddIdsSearchSingle()
{
$query = new Ids();
@@ -75,6 +76,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testComboIdsSearchArray()
{
$query = new Ids();
@@ -87,6 +91,9 @@ class IdsTest extends BaseTest
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingle()
{
$query = new Ids();
@@ -99,6 +106,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArray()
{
$query = new Ids();
@@ -111,6 +121,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchSingleDocInOtherType()
{
$query = new Ids();
@@ -125,6 +138,9 @@ class IdsTest extends BaseTest
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeSingleSearchArrayDocInOtherType()
{
$query = new Ids();
@@ -139,6 +155,9 @@ class IdsTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchArray()
{
$query = new Ids();
@@ -151,6 +170,9 @@ class IdsTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testSetTypeArraySearchSingle()
{
$query = new Ids();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php
new file mode 100644
index 00000000..989e4e4a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/ImageTest.php
@@ -0,0 +1,159 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query\Image;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
+use Elastica\Type\Mapping;
+
+class ImageTest extends BaseTest
+{
+ /**
+ * @var string
+ */
+ protected $_testFileContent;
+
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->_testFileContent = base64_encode(file_get_contents(BASE_PATH.'/data/test.jpg'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayFromReference()
+ {
+ $client = $this->_getClient();
+ $index = new Index($client, 'test');
+ $type = new Type($index, 'helloworld');
+ $field = 'image';
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+
+ $query->setImageByReference($field, $index->getName(), $type->getName(), 10);
+
+ $jsonString = '{"image":{"image":{"feature":"CEDD","hash":"BIT_SAMPLING","boost":100,"index":"test","type":"helloworld","id":10,"path":"image"}}}';
+ $this->assertEquals($jsonString, json_encode($query->toArray()));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArrayFromImage()
+ {
+ $field = 'image';
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+
+ $query->setFieldImage($field, BASE_PATH.'/data/test.jpg');
+
+ $jsonString = '{"image":{"image":{"feature":"CEDD","hash":"BIT_SAMPLING","boost":100,"image":"\/9j\/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP\/sABFEdWNreQABAAQAAAA8AAD\/4QN6aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI\/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjUtYzAyMSA3OS4xNTQ5MTEsIDIwMTMvMTAvMjktMTE6NDc6MTYgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6OWQ4MjQ5N2MtNzViMS0wYzQ5LTg4ZjMtMDdiNmRhMjU0ZWRhIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjA4NjBGM0Y1QkJGQTExRTM4MjQ0QzMzNjU2MjUxOEJGIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjA4NjBGM0Y0QkJGQTExRTM4MjQ0QzMzNjU2MjUxOEJGIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDQyAoV2luZG93cykiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5ZDgyNDk3Yy03NWIxLTBjNDktODhmMy0wN2I2ZGEyNTRlZGEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6OWQ4MjQ5N2MtNzViMS0wYzQ5LTg4ZjMtMDdiNmRhMjU0ZWRhIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+\/+4ADkFkb2JlAGTAAAAAAf\/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f\/8AAEQgAZABkAwERAAIRAQMRAf\/EAKwAAAEFAQEBAQAAAAAAAAAAAAgAAwQFBwYCAQkBAQEAAwEBAAAAAAAAAAAAAAABAgQFAwYQAAEDAgMCBQwOCQQDAAAAAAIBAwQABRESBiEHMUFhExRRcYEisnPDNIQVRRaRodEyQlJikiOzVGYnCLFyo9NklKQlGIIzQ2VTdhcRAAIBAgQEBAYDAQAAAAAAAAABAhEDITESBEFRMgVhcZFCgaHR4SITsVJiFf\/aAAwDAQACEQMRAD8AJyHDhlDYImG1JWwVVUBVVVRTkqge6DC+ztfMH3KgF0GF9na+YPuUAugwvs7XzB9ygF0GF9na+YPuUBR6n1NpDTTAuXUmgdcTFmK22JvuYfFbRMcOVdnLXje3MLa\/JmEpqOZmty32GbiparFGaa24OS1QzXlyNoiJ85a50+5y9q9Tyd7kiva3v6jQ8xwraY\/E5gh9tDrBdxueBP2s6ax74rK6YtXq0DFx2LJjIjzafrAooaJ1sa2LfcU+pUM1eXE0i3nY7jEblwUjyYzqYg62gEK+wnDyV0IzUlVOqPVNMkdBhfZ2vmD7lZFF0GF9na+YPuUBD6JF88c3zIc30fNkyphjnwxwwqkJkHxKP3oO5SoUfoBUAqA47eXr5rSlqEY6C7eJuIwmC2iKJ755xE+AGPZXZWpu9z+qOHU8jzuXNK8Qe813vd2UlV243WaWJmvbOGqcarsQQHsCKVw4Qnclh+UmamLZ3dn3UKQCd1lkprwx42CCnIrpIqqvWSuva7Uve\/Q9la5l0W6rT6hgCSQPiLnlL2iTCth9ss+PqX9aOcv27W725spEEimsDtJpRyvoicaInan2NvJWjf7dKKrB6l8\/uYuDRWaT1fdNN3BJcIlNhxU6XCVcG3hTh\/VcT4Jdhdlali+7bqsiRk0ETZrvBvFsj3KCfORZI5wVdipxKJJxEK7FSu9bmpxTWRtJ1VSbWZSF6b8m8JVA9B8Sj96DuUqAfoDNdab+dKaZvDtnGPIuk6MqDMSNkRtolTHIpuEKKaIqYoOOHHtoCz3bb07frsriMO3yIPm7ms\/SCbLPz2bDLkIuDJx0Bh2u9SHf9VXG5kalHEyYhp8WOwqiOCfKXE+zXzO4u67jkaM5VdTSt3ulAtdrB54E84zBFyUfGIr2wMovUFOHqlX0Gy2ytQ\/08\/oe8I0R3LTIinBW6ZEphGxLthx61Ggiw6Mw8zwIQrXk20zMxXexpMLZLG7xRysSTyShRMERxdouf68MC5a5HcLCi9a45+fP4nhcjTEsdx2oTbuEywun9DIBZcUV4nAVBdRP1kUS7FTt12jcfiWzLgbJXWNghem\/JvCVQPQfEo\/eg7lKgH6AC1m2u6h3hnajeVty63h9hySqZlFDkGpHgvCqCi4VQEvp3dvYNA2a+yLI7KcclxlN1ZTgubY7ZqCjlEMPfLjXncdIvyI8gfbLGR+4W1hzaDzzAn1lMca+b28azinzRoxWISEIUwxw4Vxr642mTxSqQfbCowTI+IqvUVNtYSM4nI70GG39JXNC4W2VcFeoQEhItae9VbMjG50syPdfKNnXtmUOFxxxov1TZPH9FcfaOl2J423+SCVr6A2yF6b8m8JVA9B8Sj96DuUqAfoAOtGF+MtrT\/v3vrXaoDAmRhlRH4x+9fbJsusYqK\/prGSqqBgjgj9ul82YqMm3vZCBeHPHcwVOyoV8zGsJeMX\/AAaGQRdjlNTobctgkJl4BdbVOMTTH2uCvrIyUkmsmbWZbtJjtrMhKbGsWyj2wRxrBmSM73v3lqHpd+Pm+muBDHaHjUcUJxewKVz+43KW6cZYfUwuukfM4PczbHJuuor+XFm3tOyHC6iqPNB7Z1ztjGt1eB5WlWQRdd42yF6b8m8JVA9B8Sj96DuUqA5jeTvJtWhLSzMnMPSn5hmzBjsiioTwgpojhqqIA7Npe1QA2borLf77vMtFwYiOOMx5x3C5TEAkjtoucyTnFTLiRnlEccaoDBqAH7fhpB60X71jihjbLqSJLUU2NS8MMS6gvImxfjJypXG31jTLWsma16NHUh7ud4Q2VUt1wNUtxkqsv7V5kiXFUJE282q7dnvV5Kz2W9UFon08Hy+xjCdDaIdyYkNi82Ym04mIOAqEJIvGhJsrtp1VVkexYDLbRMcajZUVWotV2qzQilXGQLDSJ2grtM1+K2HCS14Xr0barJ\/V+RXJLMH7VWp52qr10lwVajtpzcONjjzbeOOK4cJku0q+d3O4c5apYcvBGpOdXU3XdTo0tPWJX5LeS43DK48K++BtE+jbXl2qq8q11e3bdwhql1S+S4GzZhRVZ21dA9SF6b8m8JVA9B8Sj96DuUqA5feRu0tOvLbGh3CVIhlCcJ+K7GUNjhAoduJiWYUx4NnXoAbdz+p9R6f3m2yyx5riwJVwdt1wgqZLGcwU2+dFtVwE0IEJCTbxLilUBg1AVmpVsnmKYF7Fpy1uN83IbfVEA0NUERxXjIlRE5axkk1R5ElSmIKWoLQ9Y7m9HUSSOhKraEqkQCq4oKl8LBNmbjrlbrt8oOsMY\/NGq7b4Huz6juduPC2z3IxLtVts+1XrguI+1WjC7KHS3EwToXbu8PWxt5EupgnxgFsS9lBr1e8vP3My1y5lCy1e7\/cubYGTd7ia4YBmePsrtQE66ola6UpvCsn6mGLZtu7XdAtoNu66gyOXAVQmIIKhtslxEZcBmnFh2qcvDXT23b6PVcz4I2LdmmLNTrqnuKgIXpvybwlUD0HxKP3oO5SoB+gAo0Qf43WlPvC\/9c9VAa9QGC79NZjcLoOnIp5oVtJHJypwHKVO1DlRoVxX5S8lcff39UtCyWZq35VwMrLUN3Pmbc235yJ0xYhxDxJxTNcoNtn75MVWvXbbqcaLqRhCbQTunN2OloOmIlquFriy3hHnJTjrYuKr57XMDVMcEXYmHEldCduM+pI29KeZIa3XbvWjQwsETMm3aGZPYVVSvJbS1\/VE\/XHkYlvp3zav3fa8LTWlQtsK2JDjyBZKIiqrjqmhe8NtPgJxV7xilkZJULrcV+Ya86v1H6ranjRxnyGnHrdPiCTYuKymZxpxsiPAsmJCQrhs4KpTfKAVAQvTfk3hKoHoPiUfvQdylQD9ABHoYvxxtP8A7E\/9c9VAW28PV7WltNPzhUSnO\/QW5lfhPmi5VVPignbFyJWvub6twb48DCc9KqChcZZqpm44rjpkRuOltIzJcxEvKSrjXz0at1ZpGk\/l10Ot0vD2sZ7eMO2kUe0iSYoclUwdewX\/AMQrkH5Sr1K7Gzte5nvZhxCMroGyKgOe1ToPR2o4stLzZ4cx6QwrBynGGykICIuXK8qZxUVXEcF2LQAafl6JR3zaYRSXY7KDMvCuEV5NvXwoA7KAVAQvTfk3hKoHoPiUfvQdylQD9AA9oUvx0tKfeN\/656qAjN48yyXqZJ09emnIc+P9JalLATNvKirJil71xMVyOBwphtTai15XbMbkaSMZxTWJiZ7utS3a+x7PazbkdKcQFliuVGWse3dMC29oO3BMcV2Vzf8Anzi+aNd2WFhp2w27T9jhWW3BzcKA0LLI8aonCRdUiXElXq11IxSVEbKVFQsayKKgESISKK7UXYqUAAmu7A9uz1+o2K\/xJsq2yykQXoh85IikJqoty21Hm0MUVRIcxIqcOHBQBhblNb3bW+7i16juwMNz5ZPg8MUSFr6F82kVBMjVMUDFdvDQHc0BC9N+TeEqgeg+JR+9B3KVAP0ADOgy\/Ha0J95H\/rnqoDT1Fpiwajt62+9wm50VVQxFxFQgNOA2zFUNs04iBUWoCn0Xu4tGkpEx+HMmTSlZRBZ7ovkyCYrkBzKJqir8dSXZw0B1dAKgFQHl1VFo1HhQVVOvhQH567obLA1XvYsNnvIrJhzpjzs0CVfpUaBx9RNeHAyDAuSgP0Et9ut9tiNwrdFZhQ2UwajR2xaaBFXHtQBEFNvUSgJFAQvTfk3hKoHoPiUfvQdylQD9AABrKPedG7y7o2RlBu1tujs6A+qIiqJPq8w+CFsICEk9tKoO2\/yy3qIiY+aNibV6M5t5f9+oD5\/lpvV\/6j+Wc\/f0B5X82u9Xi80fyzn7+gPJfm43qim3zR\/LOfv6AZP83+9ZODzP\/LO\/v6Ag3P8ANvvZm2+TC5y2xkktk0siPHNHQQ0wUm1N0xQuoqitARPyqafn3XfDbJ0dslhWRqRJmPInaijjJstipcGYzc2Jx4L1KAO2gFQEL035N4SqBmJ546KzzfR+byDkzZ8cMEwxwoQe\/vf8N+0oU5bWfqdjH9c\/V7NgvRfO3NZsMdvN8\/twx4cKA5j8BuP1K\/pKA+fgL9yv6OgF+An3J\/o6A8r\/APAOP1I7PQ6A8F\/j1x+o\/Z6FQHgv8deP1F7PQqA7rRnq\/wCal9S\/MfmrOubzRzfMc5gmObo\/a5sOrtoC\/wD73\/DftKAX97\/hv2lARP7p50\/4Of5j5eTJn9nHGhD\/2Q=="}}}';
+ $this->assertEquals($jsonString, json_encode($query->toArray()));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFromReference()
+ {
+ $this->markTestSkipped('Tests skipped as plugin not working properly with ES 1.6.0. See https://github.com/ruflin/Elastica/pull/881');
+ $field = 'image';
+
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+
+ $type = $index->getType('test');
+
+ $mapping = new Mapping($type, array(
+ $field => array(
+ 'type' => 'image',
+ 'store' => false,
+ 'include_in_all' => false,
+ 'feature' => array(
+ 'CEDD' => array(
+ 'hash' => 'BIT_SAMPLING',
+ ),
+ ),
+ ),
+ )
+ );
+
+ $type->setMapping($mapping);
+
+ $type->addDocuments(array(
+ new Document(1, array($field => $this->_testFileContent)),
+ new Document(2, array($field => $this->_testFileContent)),
+ new Document(3, array($field => $this->_testFileContent)),
+ ));
+
+ $index->refresh();
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+ $query->setImageByReference($field, $index->getName(), $type->getName(), 1);
+
+ $resultSet = $index->search($query);
+ $this->assertEquals(3, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFromImage()
+ {
+ $this->markTestSkipped('Tests skipped as plugin not working properly with ES 1.6.0. See https://github.com/ruflin/Elastica/pull/881');
+
+ $field = 'image';
+
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+
+ $type = $index->getType('test');
+
+ $mapping = new Mapping($type, array(
+ $field => array(
+ 'type' => 'image',
+ 'store' => false,
+ 'include_in_all' => false,
+ 'feature' => array(
+ 'CEDD' => array(
+ 'hash' => 'BIT_SAMPLING',
+ ),
+ ),
+ ),
+ )
+ );
+
+ $type->setMapping($mapping);
+
+ $type->addDocuments(array(
+ new Document(1, array($field => $this->_testFileContent)),
+ new Document(2, array($field => $this->_testFileContent)),
+ new Document(3, array($field => $this->_testFileContent)),
+ ));
+
+ $index->refresh();
+
+ $query = new Image();
+ $query->setFieldFeature($field, 'CEDD');
+ $query->setFieldHash($field, 'BIT_SAMPLING');
+ $query->setFieldBoost($field, 100);
+ $query->setFieldImage($field, BASE_PATH.'/data/test.jpg');
+
+ $resultSet = $index->search($query);
+ $this->assertEquals(3, $resultSet->count());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
index 3731e659..7eb0fae0 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchAllTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,6 +8,9 @@ use Elastica\Test\Base as BaseTest;
class MatchAllTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new MatchAll();
@@ -18,10 +20,13 @@ class MatchAllTest extends BaseTest
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testMatchAllIndicesTypes()
{
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$client = $index1->getClient();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
index ed164663..98fdf26a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MatchTest.php
@@ -1,13 +1,17 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
use Elastica\Query\Match;
+use Elastica\Query\MatchPhrase;
+use Elastica\Query\MatchPhrasePrefix;
use Elastica\Test\Base as BaseTest;
class MatchTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$field = 'test';
@@ -46,14 +50,17 @@ class MatchTest extends BaseTest
'fuzziness' => $fuzziness,
'fuzzy_rewrite' => $fuzzyRewrite,
'prefix_length' => $prefixLength,
- 'max_expansions' => $maxExpansions
- )
- )
+ 'max_expansions' => $maxExpansions,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testMatch()
{
$client = $this->_getClient();
@@ -61,14 +68,75 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+ $operator = 'or';
+
+ $query = new Match();
+ $query->setFieldQuery($field, 'Basel New');
+ $query->setFieldOperator($field, $operator);
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(4, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testMatchSetFieldBoost()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+ $operator = 'or';
+
+ $query = new Match();
+ $query->setFieldQuery($field, 'Basel New');
+ $query->setFieldOperator($field, $operator);
+ $query->setFieldBoost($field, 1.2);
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(4, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testMatchSetFieldBoostWithString()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -78,22 +146,28 @@ class MatchTest extends BaseTest
$query = new Match();
$query->setFieldQuery($field, 'Basel New');
$query->setFieldOperator($field, $operator);
+ $query->setFieldBoost($field, '1.2');
$resultSet = $index->search($query);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testMatchZeroTerm()
{
$client = $this->_getClient();
$index = $client->getIndex('test');
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ ));
+
$index->refresh();
$query = new Match();
@@ -105,6 +179,9 @@ class MatchTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testMatchPhrase()
{
$client = $this->_getClient();
@@ -112,14 +189,12 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -135,6 +210,38 @@ class MatchTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
+ public function testMatchPhraseAlias()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+
+ $query = new MatchPhrase();
+ $query->setFieldQuery($field, 'New York');
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
+
+ /**
+ * @group functional
+ */
public function testMatchPhrasePrefix()
{
$client = $this->_getClient();
@@ -142,14 +249,12 @@ class MatchTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'New Hampshire'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Basel Land'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
$index->refresh();
@@ -164,24 +269,71 @@ class MatchTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
-
-
+
+ /**
+ * @group functional
+ */
+ public function testMatchPhrasePrefixAlias()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('test');
+ $index->create(array(), true);
+ $type = $index->getType('test');
+
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'New Hampshire')),
+ new Document(4, array('name' => 'Basel Land')),
+ ));
+
+ $index->refresh();
+
+ $field = 'name';
+
+ $query = new MatchPhrasePrefix();
+ $query->setFieldQuery($field, 'New');
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(2, $resultSet->count());
+ }
+
+ /**
+ * @group unit
+ */
public function testMatchFuzzinessType()
{
$field = 'test';
$query = new Match();
-
- $fuzziness = "AUTO";
+
+ $fuzziness = 'AUTO';
$query->setFieldFuzziness($field, $fuzziness);
-
- $parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
-
-
+
+ $parameters = $query->getParam($field);
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
+
$fuzziness = 0.3;
$query->setFieldFuzziness($field, $fuzziness);
-
- $parameters = $query->getParam($field);
- $this->assertEquals($fuzziness, $parameters['fuzziness']);
+
+ $parameters = $query->getParam($field);
+ $this->assertEquals($fuzziness, $parameters['fuzziness']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConstruct()
+ {
+ $match = new Match(null, 'values');
+ $this->assertEquals(array('match' => array()), $match->toArray());
+
+ $match = new Match('field', null);
+ $this->assertEquals(array('match' => array()), $match->toArray());
+
+ $match1 = new Match('field', 'values');
+ $match2 = new Match();
+ $match2->setField('field', 'values');
+ $this->assertEquals($match1->toArray(), $match2->toArray());
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
index b352e23a..5dfe9379 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MoreLikeThisTest.php
@@ -1,17 +1,19 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
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
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$client = $this->_getClient();
@@ -21,7 +23,7 @@ class MoreLikeThisTest extends BaseTest
//$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 +42,7 @@ class MoreLikeThisTest extends BaseTest
$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);
@@ -54,6 +56,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetFields()
{
$query = new MoreLikeThis();
@@ -65,6 +70,22 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($fields, $data['more_like_this']['fields']);
}
+ /**
+ * @group unit
+ */
+ public function testSetIds()
+ {
+ $query = new MoreLikeThis();
+ $ids = array(1, 2, 3);
+ $query->setIds($ids);
+
+ $data = $query->toArray();
+ $this->assertEquals($ids, $data['more_like_this']['ids']);
+ }
+
+ /**
+ * @group unit
+ */
public function testSetLikeText()
{
$query = new MoreLikeThis();
@@ -74,6 +95,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals('hello world', $data['more_like_this']['like_text']);
}
+ /**
+ * @group unit
+ */
public function testSetBoost()
{
$query = new MoreLikeThis();
@@ -84,6 +108,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($boost, $query->getParam('boost'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxQueryTerms()
{
$query = new MoreLikeThis();
@@ -94,6 +121,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($max, $query->getParam('max_query_terms'));
}
+ /**
+ * @group unit
+ */
public function testSetPercentTermsToMatch()
{
$query = new MoreLikeThis();
@@ -104,6 +134,22 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($match, $query->getParam('percent_terms_to_match'));
}
+ /**
+ * @group unit
+ */
+ public function testSetMinimumShouldMatch()
+ {
+ $query = new MoreLikeThis();
+
+ $match = '80%';
+ $query->setMinimumShouldMatch($match);
+
+ $this->assertEquals($match, $query->getParam('minimum_should_match'));
+ }
+
+ /**
+ * @group unit
+ */
public function testSetMinDocFrequency()
{
$query = new MoreLikeThis();
@@ -114,6 +160,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($freq, $query->getParam('min_doc_freq'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxDocFrequency()
{
$query = new MoreLikeThis();
@@ -124,6 +173,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($freq, $query->getParam('max_doc_freq'));
}
+ /**
+ * @group unit
+ */
public function testSetMinWordLength()
{
$query = new MoreLikeThis();
@@ -134,6 +186,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($length, $query->getParam('min_word_length'));
}
+ /**
+ * @group unit
+ */
public function testSetMaxWordLength()
{
$query = new MoreLikeThis();
@@ -144,6 +199,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($length, $query->getParam('max_word_length'));
}
+ /**
+ * @group unit
+ */
public function testSetBoostTerms()
{
$query = new MoreLikeThis();
@@ -154,6 +212,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($boost, $query->getParam('boost_terms'));
}
+ /**
+ * @group unit
+ */
public function testSetAnalyzer()
{
$query = new MoreLikeThis();
@@ -164,6 +225,9 @@ class MoreLikeThisTest extends BaseTest
$this->assertEquals($analyzer, $query->getParam('analyzer'));
}
+ /**
+ * @group unit
+ */
public function testSetStopWords()
{
$query = new MoreLikeThis();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
index 78a8a8fe..e32f91af 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/MultiMatchTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -22,114 +21,142 @@ class MultiMatchTest extends BaseTest
array('id' => 4, 'name' => 'John', 'last_name' => 'not Doe', 'full_name' => 'John not Doe'),
);
- protected function setUp()
- {
- $this->index = $this->_generateIndex();
- $this->multiMatch = new MultiMatch();
- }
-
+ /**
+ * @group functional
+ */
public function testMinimumShouldMatch()
{
- $this->multiMatch->setQuery('Tristan Maindron');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setMinimumShouldMatch(2);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tristan Maindron');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setMinimumShouldMatch('2<100%');
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testAndOperator()
{
- $this->multiMatch->setQuery('Monique Maindron');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setOperator(MultiMatch::OPERATOR_AND);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Monique Maindron');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setOperator(MultiMatch::OPERATOR_AND);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testType()
{
- $this->multiMatch->setQuery('Trist');
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Trist');
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testFuzzy()
{
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(2);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(2);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(0);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(0);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(0, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testFuzzyWithOptions1()
{
// Here Elasticsearch will not accept mispells
// on the first 6 letters.
- $this->multiMatch->setQuery('Tritsan'); // Mispell on purpose
- $this->multiMatch->setFields(array('full_name', 'name'));
- $this->multiMatch->setFuzziness(2);
- $this->multiMatch->setPrefixLength(6);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Tritsan'); // Mispell on purpose
+ $multiMatch->setFields(array('full_name', 'name'));
+ $multiMatch->setFuzziness(2);
+ $multiMatch->setPrefixLength(6);
+ $resultSet = $this->_getResults($multiMatch);
- $this->assertEquals(0, $resultSet->count());
+ $this->assertEquals(0, $resultSet->count());
}
-
- public function testFuzzyWithOptions2() {
+ /**
+ * @group functional
+ */
+ public function testFuzzyWithOptions2()
+ {
// Here with a 'M' search we should hit 'Moraes' first
// and then stop because MaxExpansion = 1.
// If MaxExpansion was set to 2, we could hit "Maindron" too.
- $this->multiMatch->setQuery('M');
- $this->multiMatch->setFields(array('name'));
- $this->multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
- $this->multiMatch->setPrefixLength(0);
- $this->multiMatch->setMaxExpansions(1);
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('M');
+ $multiMatch->setFields(array('name'));
+ $multiMatch->setType(MultiMatch::TYPE_PHRASE_PREFIX);
+ $multiMatch->setPrefixLength(0);
+ $multiMatch->setMaxExpansions(1);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testZeroTerm()
{
- $this->multiMatch->setQuery('not'); // This is a stopword.
- $this->multiMatch->setFields(array('full_name', 'last_name'));
- $this->multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_NONE);
- $this->multiMatch->setAnalyzer('stops');
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('not'); // This is a stopword.
+ $multiMatch->setFields(array('full_name', 'last_name'));
+ $multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_NONE);
+ $multiMatch->setAnalyzer('stops');
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(0, $resultSet->count());
- $this->multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_ALL);
- $resultSet = $this->_getResults();
+ $multiMatch->setZeroTermsQuery(MultiMatch::ZERO_TERM_ALL);
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(4, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testBaseMultiMatch()
{
- $this->multiMatch->setQuery('Rodolfo');
- $this->multiMatch->setFields(array('name', 'last_name'));
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Rodolfo');
+ $multiMatch->setFields(array('name', 'last_name'));
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
- $this->multiMatch->setQuery('Moraes');
- $this->multiMatch->setFields(array('name', 'last_name'));
- $resultSet = $this->_getResults();
+ $multiMatch = new MultiMatch();
+ $multiMatch->setQuery('Moraes');
+ $multiMatch->setFields(array('name', 'last_name'));
+ $resultSet = $this->_getResults($multiMatch);
$this->assertEquals(1, $resultSet->count());
}
@@ -137,9 +164,9 @@ class MultiMatchTest extends BaseTest
/**
* Executes the query with the current multimatch.
*/
- private function _getResults()
+ private function _getResults(MultiMatch $multiMatch)
{
- return $this->index->search(new Query($this->multiMatch));
+ return $this->_generateIndex()->search(new Query($multiMatch));
}
/**
@@ -154,21 +181,21 @@ class MultiMatchTest extends BaseTest
'analysis' => array(
'analyzer' => array(
'noStops' => array(
- 'type' => 'standard',
- 'stopwords' => '_none_'
+ 'type' => 'standard',
+ 'stopwords' => '_none_',
),
'stops' => array(
- 'type' => 'standard',
- 'stopwords' => array('not')
+ 'type' => 'standard',
+ 'stopwords' => array('not'),
),
),
- )
+ ),
), true);
$type = $index->getType('test');
$mapping = new Mapping($type, array(
- 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
+ 'name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
'last_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
'full_name' => array('type' => 'string', 'store' => 'no', 'analyzer' => 'noStops'),
));
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
index 310a728b..1b5fc368 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/NestedTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Nested;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class NestedTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSetQuery()
{
$nested = new Nested();
@@ -20,7 +22,7 @@ class NestedTest extends BaseTest
'nested' => array(
'query' => $queryString->toArray(),
'path' => $path,
- )
+ ),
);
$this->assertEquals($expected, $nested->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
index 16b7e07b..178c803e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PostFilterTest.php
@@ -1,61 +1,48 @@
<?php
-
namespace Elastica\Test\Query;
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
{
- /**
- * @var Index
- */
- protected $_index;
-
- protected function setUp()
+ protected function _getTestIndex()
{
- parent::setUp();
- $this->_index = $this->_createIndex("query");
+ $index = $this->_createIndex();
$docs = array(
- new Document("1", array("color" => "green", "make" => "ford")),
- new Document("2", array("color" => "blue", "make" => "volvo")),
- new Document("3", array("color" => "red", "make" => "ford")),
- new Document("4", array("color" => "green", "make" => "renault")),
+ new Document(1, array('color' => 'green', 'make' => 'ford')),
+ new Document(2, array('color' => 'blue', 'make' => 'volvo')),
+ new Document(3, array('color' => 'red', 'make' => 'ford')),
+ new Document(4, array('color' => 'green', 'make' => 'renault')),
);
- $this->_index->getType("test")->addDocuments($docs);
- $this->_index->refresh();
+ $index->getType('test')->addDocuments($docs);
+ $index->refresh();
+ return $index;
}
- protected function tearDown()
- {
- parent::tearDown();
- if ($this->_index instanceof Index) {
- $this->_index->delete();
- }
- }
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Query();
$post_filter = new Term(array('color' => 'green'));
- $query->setPostFilter($post_filter->toArray());
+ $query->setPostFilter($post_filter);
$data = $query->toArray();
$this->assertArrayHasKey('post_filter', $data);
$this->assertEquals(array('term' => array('color' => 'green')), $data['post_filter']);
-
- $query->setPostFilter(array());
-
- $this->assertArrayNotHasKey('post_filter', $query->toArray());
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
$query = new Query();
@@ -68,16 +55,10 @@ class PostFilterTest extends BaseTest
$filter = new Term();
$filter->setTerm('color', 'green');
- $query->setPostFilter($filter->toArray());
+ $query->setPostFilter($filter);
- $results = $this->_index->search($query);
+ $results = $this->_getTestIndex()->search($query);
$this->assertEquals(1, $results->getTotalHits());
-
- }
-
- protected function _createIndex($name = 'test', $delete = true, $shards = 1)
- {
- return parent::_createIndex('test_postfilter_' . $name, $delete, $shards);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
index e6852c2e..e12ead05 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/PrefixTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Prefix;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class PrefixTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Prefix();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
index 059bad2d..5b549a30 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/QueryStringTest.php
@@ -1,22 +1,22 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
-use Elastica\Index;
-use Elastica\Type;
use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;
class QueryStringTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testSearchMultipleFields()
{
$str = md5(rand());
$query = new QueryString($str);
$expected = array(
- 'query' => $str
+ 'query' => $str,
);
$this->assertEquals(array('query_string' => $expected), $query->toArray());
@@ -39,20 +39,17 @@ class QueryStringTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testSearch()
{
- $client = $this->_getClient();
- $index = new Index($client, 'test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$index->getSettings()->setNumberOfReplicas(0);
- //$index->getSettings()->setNumberOfShards(1);
-
- $type = new Type($index, 'helloworld');
+ $type = $index->getType('helloworld');
$doc = new Document(1, array('email' => 'test@test.com', 'username' => 'hanswurst', 'test' => array('2', '3', '5')));
$type->addDocument($doc);
-
- // Refresh index
$index->refresh();
$queryString = new QueryString('test*');
@@ -62,7 +59,9 @@ class QueryStringTest extends BaseTest
}
/**
- * Tests if search in multiple fields is possible
+ * Tests if search in multiple fields is possible.
+ *
+ * @group functional
*/
public function testSearchFields()
{
@@ -82,6 +81,9 @@ class QueryStringTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetDefaultOperator()
{
$operator = 'AND';
@@ -93,6 +95,9 @@ class QueryStringTest extends BaseTest
$this->assertEquals($data['query_string']['default_operator'], $operator);
}
+ /**
+ * @group unit
+ */
public function testSetDefaultField()
{
$default = 'field1';
@@ -104,18 +109,22 @@ class QueryStringTest extends BaseTest
$this->assertEquals($data['query_string']['default_field'], $default);
}
+ /**
+ * @group unit
+ */
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);
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testSetQueryInvalid()
@@ -123,4 +132,58 @@ class QueryStringTest extends BaseTest
$query = new QueryString();
$query->setQuery(array());
}
+
+ /**
+ * @group unit
+ */
+ public function testSetTimezone()
+ {
+ $timezone = 'Europe/Paris';
+ $text = 'date:[2012 TO 2014]';
+
+ $query = new QueryString($text);
+ $query->setTimezone($timezone);
+
+ $expected = array(
+ 'query_string' => array(
+ 'query' => $text,
+ 'time_zone' => $timezone,
+ ),
+ );
+
+ $this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\QueryString', $query->setTimezone($timezone));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetPhraseSlop()
+ {
+ $phraseSlop = 9;
+
+ $query = new QueryString('test');
+ $query->setPhraseSlop($phraseSlop);
+
+ $data = $query->toArray();
+ $this->assertEquals($phraseSlop, $data['query_string']['phrase_slop']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSetBoost()
+ {
+ $index = $this->_createIndex();
+ $query = new QueryString('test');
+ $query->setBoost(9.3);
+
+ $doc = new Document('', array('name' => 'test'));
+ $index->getType('test')->addDocument($doc);
+ $index->refresh();
+
+ $resultSet = $index->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
index 4cd75bc8..108ef0c9 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RangeTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,6 +7,9 @@ use Elastica\Test\Base as BaseTest;
class RangeTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testQuery()
{
$client = $this->_getClient();
@@ -15,14 +17,12 @@ class RangeTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $doc = new Document(1, array('age' => 16, 'height' => 140));
- $type->addDocument($doc);
- $doc = new Document(2, array('age' => 21, 'height' => 155));
- $type->addDocument($doc);
- $doc = new Document(3, array('age' => 33, 'height' => 160));
- $type->addDocument($doc);
- $doc = new Document(4, array('age' => 68, 'height' => 160));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('age' => 16, 'height' => 140)),
+ new Document(2, array('age' => 21, 'height' => 155)),
+ new Document(3, array('age' => 33, 'height' => 160)),
+ new Document(4, array('age' => 68, 'height' => 160)),
+ ));
$index->optimize();
$index->refresh();
@@ -38,6 +38,9 @@ class RangeTest extends BaseTest
$this->assertEquals(2, $result);
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$range = new Range();
@@ -48,12 +51,15 @@ class RangeTest extends BaseTest
$expectedArray = array(
'range' => array(
'age' => $field,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$ranges = array('from' => 20, 'to' => 40);
@@ -65,7 +71,7 @@ class RangeTest extends BaseTest
$expectedArray = array(
'range' => array(
'age' => $ranges,
- )
+ ),
);
$this->assertEquals($expectedArray, $range->toArray());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php
new file mode 100644
index 00000000..c67e6317
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RegexpTest.php
@@ -0,0 +1,31 @@
+<?php
+namespace Elastica\Test\Query;
+
+use Elastica\Query\Regexp;
+use Elastica\Test\Base as BaseTest;
+
+class RegexpTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $field = 'name';
+ $value = 'ruf';
+ $boost = 2;
+
+ $query = new Regexp($field, $value, $boost);
+
+ $expectedArray = array(
+ 'regexp' => array(
+ $field => array(
+ 'value' => $value,
+ 'boost' => $boost,
+ ),
+ ),
+ );
+
+ $this->assertequals($expectedArray, $query->toArray());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
index 4396ceb4..87842b0f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/RescoreTest.php
@@ -1,27 +1,17 @@
<?php
-
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
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index;
-
- protected function setUp()
- {
- parent::setUp();
- $this->_index = $this->_createIndex("rescore_test");
- $this->_index->refresh();
- }
-
public function testToArray()
{
$query = new Query();
@@ -59,6 +49,9 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetSize()
{
$query = new Query();
@@ -98,6 +91,9 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group unit
+ */
public function testSetWeights()
{
$query = new Query();
@@ -133,7 +129,7 @@ class RescoreTest extends BaseTest
),
),
'query_weight' => 0.7,
- 'rescore_query_weight' => 1.2
+ 'rescore_query_weight' => 1.2,
),
),
);
@@ -141,6 +137,79 @@ class RescoreTest extends BaseTest
$this->assertEquals($expected, $data);
}
+ /**
+ * @group functional
+ */
+ public function testMultipleQueries()
+ {
+ $query = new Query();
+ $mainQuery = new Match();
+ $mainQuery = $mainQuery->setFieldQuery('test1', 'foo');
+
+ $secQuery1 = new Term();
+ $secQuery1 = $secQuery1->setTerm('test2', 'bar', 1);
+ $rescoreQuery1 = new QueryRescore();
+ $rescoreQuery1->setRescoreQuery($secQuery1);
+
+ $secQuery2 = new Term();
+ $secQuery2 = $secQuery2->setTerm('test2', 'tom', 2);
+ $rescoreQuery2 = new QueryRescore();
+ $rescoreQuery2->setRescoreQuery($secQuery2);
+
+ $query->setQuery($mainQuery);
+ $query->setRescore(array($rescoreQuery1, $rescoreQuery2));
+ $data = $query->toArray();
+
+ $expected = array(
+ 'query' => array(
+ 'match' => array(
+ 'test1' => array(
+ 'query' => 'foo',
+ ),
+ ),
+ ),
+ 'rescore' => array(
+ array(
+ 'query' => array(
+ 'rescore_query' => array(
+ 'term' => array(
+ 'test2' => array(
+ 'value' => 'bar',
+ 'boost' => 1,
+ ),
+ ),
+ ),
+ ),
+ ),
+ array(
+ 'query' => array(
+ 'rescore_query' => array(
+ 'term' => array(
+ 'test2' => array(
+ 'value' => 'tom',
+ 'boost' => 2,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ),
+ );
+
+ $this->assertEquals($expected, $data);
+
+ $index = $this->_createIndex();
+ $index->refresh();
+ $results = $index->search($query);
+ $response = $results->getResponse();
+
+ $this->assertEquals(true, $response->isOk());
+ $this->assertEquals(0, $results->getTotalHits());
+ }
+
+ /**
+ * @group functional
+ */
public function testQuery()
{
$query = new Query();
@@ -156,7 +225,9 @@ class RescoreTest extends BaseTest
$query->setRescore($queryRescore);
$data = $query->toArray();
- $results = $this->_index->search($query);
+ $index = $this->_createIndex();
+ $index->refresh();
+ $results = $index->search($query);
$response = $results->getResponse();
$this->assertEquals(true, $response->isOk());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
index eff9b8a1..80316547 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleQueryStringTest.php
@@ -1,73 +1,103 @@
<?php
-
namespace Elastica\Test\Query;
-
use Elastica\Document;
-use Elastica\Index;
use Elastica\Query\SimpleQueryString;
use Elastica\Test\Base;
class SimpleQueryStringTest extends Base
{
/**
- * @var Index
+ * @group unit
*/
- protected $_index;
+ public function testToArray()
+ {
+ $string = 'this is a test';
+ $fields = array('field1', 'field2');
+ $query = new SimpleQueryString($string, $fields);
+ $query->setDefaultOperator(SimpleQueryString::OPERATOR_OR);
+ $query->setAnalyzer('whitespace');
+
+ $expected = array(
+ 'simple_query_string' => array(
+ 'query' => $string,
+ 'fields' => $fields,
+ 'analyzer' => 'whitespace',
+ 'default_operator' => SimpleQueryString::OPERATOR_OR,
+ ),
+ );
- protected function setUp()
+ $this->assertEquals($expected, $query->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testQuery()
{
- parent::setUp();
- $this->_index = $this->_createIndex("simple_query_string_test");
+ $index = $this->_createIndex();
$docs = array(
new Document(1, array('make' => 'Gibson', 'model' => 'Les Paul')),
new Document(2, array('make' => 'Gibson', 'model' => 'SG Standard')),
new Document(3, array('make' => 'Gibson', 'model' => 'SG Supreme')),
new Document(4, array('make' => 'Gibson', 'model' => 'SG Faded')),
- new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster'))
+ new Document(5, array('make' => 'Fender', 'model' => 'Stratocaster')),
);
- $this->_index->getType("guitars")->addDocuments($docs);
- $this->_index->refresh();
- }
+ $index->getType('guitars')->addDocuments($docs);
+ $index->refresh();
- protected function tearDown()
- {
- parent::tearDown();
- $this->_index->delete();
+ $query = new SimpleQueryString('gibson +sg +-faded', array('make', 'model'));
+ $results = $index->search($query);
+
+ $this->assertEquals(2, $results->getTotalHits());
+
+ $query->setFields(array('model'));
+ $results = $index->search($query);
+
+ // We should not get any hits, since the "make" field was not included in the query.
+ $this->assertEquals(0, $results->getTotalHits());
}
- public function testToArray()
+ /**
+ * @group unit
+ */
+ public function testSetMinimumShouldMatch()
{
- $string = "this is a test";
- $fields = array('field1', 'field2');
- $query = new SimpleQueryString($string, $fields);
- $query->setDefaultOperator(SimpleQueryString::OPERATOR_OR);
- $query->setAnalyzer("whitespace");
-
$expected = array(
- "simple_query_string" => array(
- "query" => $string,
- "fields" => $fields,
- "analyzer" => "whitespace",
- "default_operator" => SimpleQueryString::OPERATOR_OR
- )
+ 'simple_query_string' => array(
+ 'query' => 'DONT PANIC',
+ 'minimum_should_match' => '75%',
+ ),
);
+ $query = new SimpleQueryString($expected['simple_query_string']['query']);
+ $query->setMinimumShouldMatch($expected['simple_query_string']['minimum_should_match']);
+
$this->assertEquals($expected, $query->toArray());
+ $this->assertInstanceOf('Elastica\Query\SimpleQueryString', $query->setMinimumShouldMatch('75%'));
}
- public function testQuery()
+ /**
+ * @group functional
+ */
+ public function testSetMinimumShouldMatchWorks()
{
- $query = new SimpleQueryString("gibson +sg +-faded", array("make", "model"));
- $results = $this->_index->search($query);
+ $index = $this->_createIndex();
+ $type = $index->getType('foobars');
+ $type->addDocuments(array(
+ new Document(1, array('body' => 'foo')),
+ new Document(2, array('body' => 'bar')),
+ new Document(3, array('body' => 'foo bar')),
+ new Document(4, array('body' => 'foo baz bar')),
+ ));
+ $index->refresh();
- $this->assertEquals(2, $results->getTotalHits());
-
- $query->setFields(array("model"));
- $results = $this->_index->search($query);
+ $query = new SimpleQueryString('foo bar');
+ $query->setMinimumShouldMatch(2);
+ $results = $type->search($query);
- // We should not get any hits, since the "make" field was not included in the query.
- $this->assertEquals(0, $results->getTotalHits());
+ $this->assertCount(2, $results);
+ $this->assertEquals(3, $results[0]->getId());
+ $this->assertEquals(4, $results[1]->getId());
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
index 08a5f55d..b4f1dc8d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/SimpleTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Simple;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class SimpleTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testToArray()
{
$testQuery = array('hello' => array('world'), 'name' => 'ruflin');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
index 887c3849..da15f0f2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Query\Term;
@@ -7,7 +6,9 @@ use Elastica\Test\Base as BaseTest;
class TermTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testToArray()
{
$query = new Term();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
index 184f3ad6..f0c2b4b4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/TermsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -8,19 +7,19 @@ use Elastica\Test\Base as BaseTest;
class TermsTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testFilteredSearch()
{
- $client = $this->_getClient();
- $index = $client->getIndex('test');
- $index->create(array(), true);
+ $index = $this->_createIndex();
$type = $index->getType('helloworld');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'nicolas ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('name' => 'nicolas ruflin')),
+ new Document(3, array('name' => 'ruflin')),
+ ));
$query = new Terms();
$query->setTerms('name', array('nicolas', 'hello'));
@@ -37,6 +36,9 @@ class TermsTest extends BaseTest
$this->assertEquals(3, $resultSet->count());
}
+ /**
+ * @group unit
+ */
public function testSetMinimum()
{
$key = 'name';
@@ -51,6 +53,7 @@ class TermsTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidParams()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
index 077e6d4f..7a0c379e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Query/WildcardTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Query;
use Elastica\Document;
@@ -9,12 +8,18 @@ use Elastica\Type\Mapping;
class WildcardTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstructEmpty()
{
$wildcard = new Wildcard();
$this->assertEmpty($wildcard->getParams());
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$key = 'name';
@@ -27,14 +32,17 @@ class WildcardTest extends BaseTest
'wildcard' => array(
$key => array(
'value' => $value,
- 'boost' => $boost
- )
- )
+ 'boost' => $boost,
+ ),
+ ),
);
$this->assertEquals($expectedArray, $wildcard->toArray());
}
+ /**
+ * @group functional
+ */
public function testSearchWithAnalyzer()
{
$client = $this->_getClient();
@@ -46,10 +54,10 @@ class WildcardTest extends BaseTest
'lw' => array(
'type' => 'custom',
'tokenizer' => 'keyword',
- 'filter' => array('lowercase')
- )
+ 'filter' => array('lowercase'),
+ ),
),
- )
+ ),
);
$index->create($indexParams, true);
@@ -61,16 +69,13 @@ class WildcardTest extends BaseTest
);
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'Basel-Stadt'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'New York'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'Baden'));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'Baden Baden'));
- $type->addDocument($doc);
- $doc = new Document(5, array('name' => 'New Orleans'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'Basel-Stadt')),
+ new Document(2, array('name' => 'New York')),
+ new Document(3, array('name' => 'Baden')),
+ new Document(4, array('name' => 'Baden Baden')),
+ new Document(5, array('name' => 'New Orleans')),
+ ));
$index->refresh();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php
new file mode 100644
index 00000000..3e44f463
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AbstractDSLTest.php
@@ -0,0 +1,97 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Exception\NotImplementedException;
+use Elastica\QueryBuilder\DSL;
+use Elastica\Test\Base as BaseTest;
+
+abstract class AbstractDSLTest extends BaseTest
+{
+ /**
+ * @param DSL $dsl
+ * @param string $methodName
+ * @param string $className
+ * @param array $arguments
+ */
+ protected function _assertImplemented(DSL $dsl, $methodName, $className, $arguments)
+ {
+ // Check method existence
+ $this->assertTrue(method_exists($dsl, $methodName));
+
+ // Check returned value
+ $return = call_user_func_array(array($dsl, $methodName), $arguments);
+ $this->assertTrue(class_exists($className), 'Class not exists but NotImplementedException is not thrown');
+ $this->assertInstanceOf($className, $return);
+
+ // Check method signature
+ $class = new \ReflectionClass($className);
+ $method = new \ReflectionMethod(get_class($dsl), $methodName);
+ if (!$class->hasMethod('__construct')) {
+ $this->assertEmpty($method->getParameters(), 'Constructor is not defined, but method has some parameters');
+ } else {
+ $this->_assertParametersEquals($class->getMethod('__construct')->getParameters(), $method->getParameters());
+ }
+ }
+
+ /**
+ * @param DSL $dsl
+ * @param string $name
+ */
+ protected function _assertNotImplemented(DSL $dsl, $methodName, $arguments)
+ {
+ try {
+ call_user_func(array($dsl, $methodName), $arguments);
+ $this->fail('NotImplementedException is not thrown');
+ } catch (NotImplementedException $ex) {
+ // expected
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter[] $left
+ * @param \ReflectionParameter[] $right
+ */
+ protected function _assertParametersEquals($left, $right)
+ {
+ $this->assertEquals(count($left), count($right), 'Parameters count mismatch');
+
+ for ($i = 0; $i < count($left); $i++) {
+ $this->assertEquals($left[$i]->getName(), $right[$i]->getName(), 'Parameters names mismatch');
+ $this->assertEquals($left[$i]->isOptional(), $right[$i]->isOptional(), 'Parameters optionality mismatch');
+ $this->assertEquals($this->_getHintName($left[$i]), $this->_getHintName($right[$i]), 'Parameters typehints mismatch');
+ $this->assertEquals($this->_getDefaultValue($left[$i]), $this->_getDefaultValue($right[$i]), 'Default values mismatch');
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter $param
+ *
+ * @return string|null
+ */
+ protected function _getDefaultValue(\ReflectionParameter $param)
+ {
+ if ($param->isOptional()) {
+ return $param->getDefaultValue();
+ }
+ }
+
+ /**
+ * @param \ReflectionParameter $param
+ *
+ * @return string|null
+ */
+ protected function _getHintName(\ReflectionParameter $param)
+ {
+ if (version_compare(phpversion(), '5.4', '>=') && $param->isCallable()) {
+ return 'callable';
+ }
+
+ if ($param->isArray()) {
+ return 'array';
+ }
+
+ if ($class = $param->getClass()) {
+ return $class->getName();
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
new file mode 100644
index 00000000..67c70862
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/AggregationTest.php
@@ -0,0 +1,58 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\QueryBuilder\DSL;
+
+class AggregationTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $aggregationDSL = new DSL\Aggregation();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $aggregationDSL);
+ $this->assertEquals(DSL::TYPE_AGGREGATION, $aggregationDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $aggregationDSL = new DSL\Aggregation();
+
+ $this->_assertImplemented($aggregationDSL, 'avg', 'Elastica\Aggregation\Avg', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'cardinality', 'Elastica\Aggregation\Cardinality', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'date_histogram', 'Elastica\Aggregation\DateHistogram', array('name', 'field', 1));
+ $this->_assertImplemented($aggregationDSL, 'date_range', 'Elastica\Aggregation\DateRange', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'extended_stats', 'Elastica\Aggregation\ExtendedStats', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'filter', 'Elastica\Aggregation\Filter', array('name', new Exists('field')));
+ $this->_assertImplemented($aggregationDSL, 'filters', 'Elastica\Aggregation\Filters', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'geo_distance', 'Elastica\Aggregation\GeoDistance', array('name', 'field', 'origin'));
+ $this->_assertImplemented($aggregationDSL, 'geohash_grid', 'Elastica\Aggregation\GeohashGrid', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'global_agg', 'Elastica\Aggregation\GlobalAggregation', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'histogram', 'Elastica\Aggregation\Histogram', array('name', 'field', 1));
+ $this->_assertImplemented($aggregationDSL, 'ipv4_range', 'Elastica\Aggregation\IpRange', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'max', 'Elastica\Aggregation\Max', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'min', 'Elastica\Aggregation\Min', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'missing', 'Elastica\Aggregation\Missing', array('name', 'field'));
+ $this->_assertImplemented($aggregationDSL, 'nested', 'Elastica\Aggregation\Nested', array('name', 'path'));
+ $this->_assertImplemented($aggregationDSL, 'percentiles', 'Elastica\Aggregation\Percentiles', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'range', 'Elastica\Aggregation\Range', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'reverse_nested', 'Elastica\Aggregation\ReverseNested', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'scripted_metric', 'Elastica\Aggregation\ScriptedMetric', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'significant_terms', 'Elastica\Aggregation\SignificantTerms', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'stats', 'Elastica\Aggregation\Stats', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'sum', 'Elastica\Aggregation\Sum', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'terms', 'Elastica\Aggregation\Terms', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'top_hits', 'Elastica\Aggregation\TopHits', array('name'));
+ $this->_assertImplemented($aggregationDSL, 'value_count', 'Elastica\Aggregation\ValueCount', array('name', 'field'));
+
+ $this->_assertNotImplemented($aggregationDSL, 'children', array('name'));
+ $this->_assertNotImplemented($aggregationDSL, 'geo_bounds', array('name'));
+ $this->_assertNotImplemented($aggregationDSL, 'percentile_ranks', array('name'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
new file mode 100644
index 00000000..755bd18a
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/FilterTest.php
@@ -0,0 +1,58 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\Query\Match;
+use Elastica\QueryBuilder\DSL;
+
+class FilterTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $filterDSL = new DSL\Filter();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $filterDSL);
+ $this->assertEquals(DSL::TYPE_FILTER, $filterDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $filterDSL = new DSL\Filter();
+
+ $this->_assertImplemented($filterDSL, 'bool', 'Elastica\Filter\BoolFilter', array());
+ $this->_assertImplemented($filterDSL, 'bool_and', 'Elastica\Filter\BoolAnd', array(array(new Exists('field'))));
+ $this->_assertImplemented($filterDSL, 'bool_not', 'Elastica\Filter\BoolNot', array(new Exists('field')));
+ $this->_assertImplemented($filterDSL, 'bool_or', 'Elastica\Filter\BoolOr', array(array(new Exists('field'))));
+ $this->_assertImplemented($filterDSL, 'exists', 'Elastica\Filter\Exists', array('field'));
+ $this->_assertImplemented($filterDSL, 'geo_bounding_box', 'Elastica\Filter\GeoBoundingBox', array('field', array(1, 2)));
+ $this->_assertImplemented($filterDSL, 'geo_distance', 'Elastica\Filter\GeoDistance', array('key', 'location', 'distance'));
+ $this->_assertImplemented($filterDSL, 'geo_distance_range', 'Elastica\Filter\GeoDistanceRange', array('key', 'location'));
+ $this->_assertImplemented($filterDSL, 'geo_polygon', 'Elastica\Filter\GeoPolygon', array('key', array()));
+ $this->_assertImplemented($filterDSL, 'geo_shape_pre_indexed', 'Elastica\Filter\GeoShapePreIndexed', array('path', 'indexedId', 'indexedType', 'indexedIndex', 'indexedPath'));
+ $this->_assertImplemented($filterDSL, 'geo_shape_provided', 'Elastica\Filter\GeoShapeProvided', array('path', array()));
+ $this->_assertImplemented($filterDSL, 'geohash_cell', 'Elastica\Filter\GeohashCell', array('field', 'location'));
+ $this->_assertImplemented($filterDSL, 'has_child', 'Elastica\Filter\HasChild', array(new Match(), 'type'));
+ $this->_assertImplemented($filterDSL, 'has_parent', 'Elastica\Filter\HasParent', array(new Match(), 'type'));
+ $this->_assertImplemented($filterDSL, 'ids', 'Elastica\Filter\Ids', array('type', array()));
+ $this->_assertImplemented($filterDSL, 'indices', 'Elastica\Filter\Indices', array(new Exists('field'), array()));
+ $this->_assertImplemented($filterDSL, 'limit', 'Elastica\Filter\Limit', array(1));
+ $this->_assertImplemented($filterDSL, 'match_all', 'Elastica\Filter\MatchAll', array());
+ $this->_assertImplemented($filterDSL, 'missing', 'Elastica\Filter\Missing', array('field'));
+ $this->_assertImplemented($filterDSL, 'nested', 'Elastica\Filter\Nested', array());
+ $this->_assertImplemented($filterDSL, 'numeric_range', 'Elastica\Filter\NumericRange', array());
+ $this->_assertImplemented($filterDSL, 'prefix', 'Elastica\Filter\Prefix', array('field', 'prefix'));
+ $this->_assertImplemented($filterDSL, 'query', 'Elastica\Filter\Query', array(new Match()));
+ $this->_assertImplemented($filterDSL, 'range', 'Elastica\Filter\Range', array('field', array()));
+ $this->_assertImplemented($filterDSL, 'regexp', 'Elastica\Filter\Regexp', array('field', 'regex'));
+ $this->_assertImplemented($filterDSL, 'script', 'Elastica\Filter\Script', array('script'));
+ $this->_assertImplemented($filterDSL, 'term', 'Elastica\Filter\Term', array());
+ $this->_assertImplemented($filterDSL, 'terms', 'Elastica\Filter\Terms', array('field', array()));
+ $this->_assertImplemented($filterDSL, 'type', 'Elastica\Filter\Type', array('type'));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
new file mode 100644
index 00000000..d4669119
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/QueryTest.php
@@ -0,0 +1,85 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\Filter\Exists;
+use Elastica\Query\Match;
+use Elastica\QueryBuilder\DSL;
+
+class QueryTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $queryDSL = new DSL\Query();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $queryDSL);
+ $this->assertEquals(DSL::TYPE_QUERY, $queryDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testMatch()
+ {
+ $queryDSL = new DSL\Query();
+
+ $match = $queryDSL->match('field', 'match');
+ $this->assertEquals('match', $match->getParam('field'));
+ $this->assertInstanceOf('Elastica\Query\Match', $match);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $queryDSL = new DSL\Query();
+
+ $this->_assertImplemented($queryDSL, 'bool', 'Elastica\Query\BoolQuery', array());
+ $this->_assertImplemented($queryDSL, 'boosting', 'Elastica\Query\Boosting', array());
+ $this->_assertImplemented($queryDSL, 'common_terms', 'Elastica\Query\Common', array('field', 'query', 0.001));
+ $this->_assertImplemented($queryDSL, 'constant_score', 'Elastica\Query\ConstantScore', array(new Match()));
+ $this->_assertImplemented($queryDSL, 'dis_max', 'Elastica\Query\DisMax', array());
+ $this->_assertImplemented($queryDSL, 'filtered', 'Elastica\Query\Filtered', array(new Match(), new Exists('field')));
+ $this->_assertImplemented($queryDSL, 'function_score', 'Elastica\Query\FunctionScore', array());
+ $this->_assertImplemented($queryDSL, 'fuzzy', 'Elastica\Query\Fuzzy', array('field', 'type'));
+ $this->_assertImplemented($queryDSL, 'fuzzy_like_this', 'Elastica\Query\FuzzyLikeThis', array());
+ $this->_assertImplemented($queryDSL, 'has_child', 'Elastica\Query\HasChild', array(new Match()));
+ $this->_assertImplemented($queryDSL, 'has_parent', 'Elastica\Query\HasParent', array(new Match(), 'type'));
+ $this->_assertImplemented($queryDSL, 'ids', 'Elastica\Query\Ids', array('type', array()));
+ $this->_assertImplemented($queryDSL, 'match', 'Elastica\Query\Match', array('field', 'values'));
+ $this->_assertImplemented($queryDSL, 'match_all', 'Elastica\Query\MatchAll', array());
+ $this->_assertImplemented($queryDSL, 'more_like_this', 'Elastica\Query\MoreLikeThis', array());
+ $this->_assertImplemented($queryDSL, 'multi_match', 'Elastica\Query\MultiMatch', array());
+ $this->_assertImplemented($queryDSL, 'nested', 'Elastica\Query\Nested', array());
+ $this->_assertImplemented($queryDSL, 'prefix', 'Elastica\Query\Prefix', array());
+ $this->_assertImplemented($queryDSL, 'query_string', 'Elastica\Query\QueryString', array());
+ $this->_assertImplemented($queryDSL, 'range', 'Elastica\Query\Range', array('field', array()));
+ $this->_assertImplemented($queryDSL, 'regexp', 'Elastica\Query\Regexp', array('field', 'value', 1.0));
+ $this->_assertImplemented($queryDSL, 'simple_query_string', 'Elastica\Query\SimpleQueryString', array('query'));
+ $this->_assertImplemented($queryDSL, 'term', 'Elastica\Query\Term', array());
+ $this->_assertImplemented($queryDSL, 'terms', 'Elastica\Query\Terms', array('field', array()));
+ $this->_assertImplemented($queryDSL, 'top_children', 'Elastica\Query\TopChildren', array(new Match(), 'type'));
+ $this->_assertImplemented($queryDSL, 'wildcard', 'Elastica\Query\Wildcard', array());
+
+ $this->_assertNotImplemented($queryDSL, 'custom_boost_factor', array());
+ $this->_assertNotImplemented($queryDSL, 'custom_filters_score', array());
+ $this->_assertNotImplemented($queryDSL, 'custom_score', array());
+ $this->_assertNotImplemented($queryDSL, 'field', array());
+ $this->_assertNotImplemented($queryDSL, 'fuzzy_like_this_field', array());
+ $this->_assertNotImplemented($queryDSL, 'geo_shape', array());
+ $this->_assertNotImplemented($queryDSL, 'indices', array());
+ $this->_assertNotImplemented($queryDSL, 'minimum_should_match', array());
+ $this->_assertNotImplemented($queryDSL, 'more_like_this_field', array());
+ $this->_assertNotImplemented($queryDSL, 'span_first', array());
+ $this->_assertNotImplemented($queryDSL, 'span_multi_term', array());
+ $this->_assertNotImplemented($queryDSL, 'span_near', array());
+ $this->_assertNotImplemented($queryDSL, 'span_not', array());
+ $this->_assertNotImplemented($queryDSL, 'span_or', array());
+ $this->_assertNotImplemented($queryDSL, 'span_term', array());
+ $this->_assertNotImplemented($queryDSL, 'template', array());
+ $this->_assertNotImplemented($queryDSL, 'text', array());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
new file mode 100644
index 00000000..b70e0ba7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/DSL/SuggestTest.php
@@ -0,0 +1,32 @@
+<?php
+namespace Elastica\Test\QueryBuilder\DSL;
+
+use Elastica\QueryBuilder\DSL;
+
+class SuggestTest extends AbstractDSLTest
+{
+ /**
+ * @group unit
+ */
+ public function testType()
+ {
+ $suggestDSL = new DSL\Suggest();
+
+ $this->assertInstanceOf('Elastica\QueryBuilder\DSL', $suggestDSL);
+ $this->assertEquals(DSL::TYPE_SUGGEST, $suggestDSL->getType());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testInterface()
+ {
+ $suggestDSL = new DSL\Suggest();
+
+ $this->_assertImplemented($suggestDSL, 'completion', 'Elastica\Suggest\Completion', array('name', 'field'));
+ $this->_assertImplemented($suggestDSL, 'phrase', 'Elastica\Suggest\Phrase', array('name', 'field'));
+ $this->_assertImplemented($suggestDSL, 'term', 'Elastica\Suggest\Term', array('name', 'field'));
+
+ $this->_assertNotImplemented($suggestDSL, 'context', array());
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
new file mode 100644
index 00000000..d92848a7
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilder/VersionTest.php
@@ -0,0 +1,67 @@
+<?php
+namespace Elastica\Test\QueryBuilder;
+
+use Elastica\QueryBuilder\DSL;
+use Elastica\QueryBuilder\Version;
+use Elastica\Test\Base as BaseTest;
+
+class VersionTest extends BaseTest
+{
+ /**
+ * @group unit
+ */
+ public function testVersions()
+ {
+ $dsl = array(
+ new DSL\Query(),
+ new DSL\Filter(),
+ new DSL\Aggregation(),
+ new DSL\Suggest(),
+ );
+
+ $versions = array(
+ new Version\Version090(),
+ new Version\Version100(),
+ new Version\Version110(),
+ new Version\Version120(),
+ new Version\Version130(),
+ new Version\Version140(),
+ new Version\Version150(),
+ );
+
+ foreach ($versions as $version) {
+ $this->assertVersions($version, $dsl);
+ }
+ }
+
+ 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])
+ );
+ }
+
+ 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])
+ );
+ }
+
+ 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])
+ );
+ }
+
+ 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])
+ );
+ }
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php
new file mode 100644
index 00000000..6cbfd37b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryBuilderTest.php
@@ -0,0 +1,88 @@
+<?php
+namespace Elastica\Test;
+
+use Elastica\Exception\QueryBuilderException;
+use Elastica\Query;
+use Elastica\QueryBuilder;
+use Elastica\Suggest;
+
+class QueryBuilderTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @group unit
+ */
+ public function testCustomDSL()
+ {
+ $qb = new QueryBuilder();
+
+ // test custom DSL
+ $qb->addDSL(new CustomDSL());
+
+ $this->assertTrue($qb->custom()->custom_method(), 'custom DSL execution failed');
+
+ // test custom DSL exception message
+ $exceptionMessage = '';
+ try {
+ $qb->invalid();
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('DSL "invalid" not supported', $exceptionMessage);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFacade()
+ {
+ $qb = new QueryBuilder();
+
+ // test one example QueryBuilder flow for each default DSL type
+ $this->assertInstanceOf('Elastica\Query\AbstractQuery', $qb->query()->match());
+ $this->assertInstanceOf('Elastica\Filter\AbstractFilter', $qb->filter()->bool());
+ $this->assertInstanceOf('Elastica\Aggregation\AbstractAggregation', $qb->aggregation()->avg('name'));
+ $this->assertInstanceOf('Elastica\Suggest\AbstractSuggest', $qb->suggest()->term('name', 'field'));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testFacadeException()
+ {
+ $qb = new QueryBuilder(new QueryBuilder\Version\Version100());
+
+ // undefined
+ $exceptionMessage = '';
+ try {
+ $qb->query()->invalid();
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('undefined query "invalid"', $exceptionMessage);
+
+ // unsupported
+ $exceptionMessage = '';
+ try {
+ $qb->aggregation()->top_hits('top_hits');
+ } catch (QueryBuilderException $exception) {
+ $exceptionMessage = $exception->getMessage();
+ }
+
+ $this->assertEquals('aggregation "top_hits" in Version100 not supported', $exceptionMessage);
+ }
+}
+
+class CustomDSL implements QueryBuilder\DSL
+{
+ public function getType()
+ {
+ return 'custom';
+ }
+
+ public function custom_method()
+ {
+ return true;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
index ece9f4c2..a39ab23a 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/QueryTest.php
@@ -1,18 +1,24 @@
<?php
-
namespace Elastica\Test;
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\Script;
+use Elastica\ScriptFields;
+use Elastica\Suggest;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type;
class QueryTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testStringConversion()
{
$queryString = '{
@@ -51,6 +57,9 @@ class QueryTest extends BaseTest
$this->assertEquals('2011-07-18 00:00:00', $queryArray['query']['filtered']['filter']['range']['due']['gte']);
}
+ /**
+ * @group unit
+ */
public function testRawQuery()
{
$textQuery = new Term(array('title' => 'test'));
@@ -63,14 +72,47 @@ class QueryTest extends BaseTest
$this->assertEquals($query1->toArray(), $query2->toArray());
}
+ /**
+ * @group unit
+ */
+ public function testSuggestShouldNotRemoveOtherParameters()
+ {
+ $query1 = new Query();
+ $query2 = new Query();
+
+ $suggest = new Suggest();
+ $suggest->setGlobalText('test');
+
+ $query1->setSize(40);
+ $query1->setSuggest($suggest);
+
+ $query2->setSuggest($suggest);
+ $query2->setSize(40);
+
+ $this->assertEquals($query1->toArray(), $query2->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSuggestMustReturnQueryInstance()
+ {
+ $query = new Query();
+ $suggest = new Suggest();
+ $this->assertInstanceOf('Elastica\Query', $query->setSuggest($suggest));
+ }
+
+ /**
+ * @group unit
+ */
public function testArrayQuery()
{
$query = array(
'query' => array(
'text' => array(
- 'title' => 'test'
- )
- )
+ 'title' => 'test',
+ ),
+ ),
);
$query1 = Query::create($query);
@@ -81,17 +123,19 @@ class QueryTest extends BaseTest
$this->assertEquals($query1->toArray(), $query2->toArray());
}
+ /**
+ * @group functional
+ */
public function testSetSort()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'hello world'));
- $type->addDocument($doc);
- $doc = new Document(2, array('firstname' => 'guschti', 'lastname' => 'ruflin'));
- $type->addDocument($doc);
- $doc = new Document(3, array('firstname' => 'nicolas', 'lastname' => 'ruflin'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'hello world')),
+ new Document(2, array('firstname' => 'guschti', 'lastname' => 'ruflin')),
+ new Document(3, array('firstname' => 'nicolas', 'lastname' => 'ruflin')),
+ ));
$queryTerm = new Term();
$queryTerm->setTerm('lastname', 'ruflin');
@@ -123,6 +167,9 @@ class QueryTest extends BaseTest
$this->assertEquals('guschti', $second['firstname']);
}
+ /**
+ * @group unit
+ */
public function testAddSort()
{
$query = new Query();
@@ -132,6 +179,9 @@ class QueryTest extends BaseTest
$this->assertEquals($query->getParam('sort'), array($sortParam));
}
+ /**
+ * @group unit
+ */
public function testSetRawQuery()
{
$query = new Query();
@@ -142,6 +192,9 @@ class QueryTest extends BaseTest
$this->assertEquals($params, $query->toArray());
}
+ /**
+ * @group unit
+ */
public function testSetFields()
{
$query = new Query();
@@ -154,9 +207,12 @@ class QueryTest extends BaseTest
$this->assertContains('firstname', $data['fields']);
$this->assertContains('lastname', $data['fields']);
- $this->assertEquals(2, count($data['fields']));
+ $this->assertCount(2, $data['fields']);
}
+ /**
+ * @group unit
+ */
public function testGetQuery()
{
$query = new Query();
@@ -175,6 +231,9 @@ class QueryTest extends BaseTest
$this->assertEquals($termQuery->toArray(), $query->getQuery());
}
+ /**
+ * @group unit
+ */
public function testSetFacets()
{
$query = new Query();
@@ -191,4 +250,209 @@ class QueryTest extends BaseTest
$this->assertArrayNotHasKey('facets', $query->toArray());
}
+
+ /**
+ * @group unit
+ */
+ public function testSetQueryToArrayCast()
+ {
+ $query = new Query();
+ $termQuery = new Term();
+ $termQuery->setTerm('text', 'value');
+ $query->setQuery($termQuery);
+
+ $termQuery->setTerm('text', 'another value');
+
+ $anotherQuery = new Query();
+ $anotherQuery->setQuery($termQuery);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetQueryToArrayChangeQuery()
+ {
+ $query = new Query();
+ $termQuery = new Term();
+ $termQuery->setTerm('text', 'value');
+ $query->setQuery($termQuery);
+
+ $queryArray = $query->toArray();
+
+ $termQuery = $query->getQuery();
+ $termQuery['term']['text']['value'] = 'another value';
+
+ $this->assertEquals($queryArray, $query->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScriptFieldsToArrayCast()
+ {
+ $query = new Query();
+ $scriptFields = new ScriptFields();
+ $scriptFields->addScript('script', new Script('script'));
+
+ $query->setScriptFields($scriptFields);
+
+ $scriptFields->addScript('another script', new Script('another script'));
+
+ $anotherQuery = new Query();
+ $anotherQuery->setScriptFields($scriptFields);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddScriptFieldsToArrayCast()
+ {
+ $query = new Query();
+ $scriptField = new Script('script');
+
+ $query->addScriptField('script', $scriptField);
+
+ $scriptField->setScript('another script');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addScriptField('script', $scriptField);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddFacetToArrayCast()
+ {
+ $query = new Query();
+ $facet = new Terms('text');
+
+ $query->addFacet($facet);
+
+ $facet->setName('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addFacet($facet);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testAddAggregationToArrayCast()
+ {
+ $query = new Query();
+ $aggregation = new \Elastica\Aggregation\Terms('text');
+
+ $query->addAggregation($aggregation);
+
+ $aggregation->setName('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->addAggregation($aggregation);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetSuggestToArrayCast()
+ {
+ $query = new Query();
+ $suggest = new Suggest();
+ $suggest->setGlobalText('text');
+
+ $query->setSuggest($suggest);
+
+ $suggest->setGlobalText('another text');
+
+ $anotherQuery = new Query();
+ $anotherQuery->setSuggest($suggest);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetRescoreToArrayCast()
+ {
+ $query = new Query();
+ $rescore = new \Elastica\Rescore\Query();
+ $rescore->setQueryWeight(1);
+
+ $query->setRescore($rescore);
+
+ $rescore->setQueryWeight(2);
+
+ $anotherQuery = new Query();
+ $anotherQuery->setRescore($rescore);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetPostFilterToArrayCast()
+ {
+ $query = new Query();
+ $postFilter = new \Elastica\Filter\Terms();
+ $postFilter->setTerms('key', array('term'));
+ $query->setPostFilter($postFilter);
+
+ $postFilter->setTerms('another key', array('another term'));
+
+ $anotherQuery = new Query();
+ $anotherQuery->setPostFilter($postFilter);
+
+ $this->assertNotEquals($query->toArray(), $anotherQuery->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testNoSource()
+ {
+ $index = $this->_createIndex();
+
+ $type = new Type($index, 'user');
+
+ // Adds 1 document to the index
+ $doc1 = new Document(1,
+ array('username' => 'ruflin', 'test' => array('2', '3', '5'))
+ );
+ $type->addDocument($doc1);
+
+ // To update index
+ $index->refresh();
+
+ $query = Query::create('ruflin');
+ $resultSet = $type->search($query);
+
+ // Disable source
+ $query->setSource(false);
+
+ $resultSetNoSource = $type->search($query);
+
+ $this->assertEquals(1, $resultSet->count());
+ $this->assertEquals(1, $resultSetNoSource->count());
+
+ // Tests if no source is in response except id
+ $result = $resultSetNoSource->current();
+ $this->assertEquals(1, $result->getId());
+ $this->assertEmpty($result->getData());
+
+ // Tests if source is in response except id
+ $result = $resultSet->current();
+ $this->assertEquals(1, $result->getId());
+ $this->assertNotEmpty($result->getData());
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
index 8896adeb..987f2391 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/RequestTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Connection;
@@ -8,7 +7,9 @@ use Elastica\Test\Base as BaseTest;
class RequestTest extends BaseTest
{
-
+ /**
+ * @group unit
+ */
public function testConstructor()
{
$path = 'test';
@@ -25,6 +26,7 @@ class RequestTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidConnection()
@@ -33,10 +35,13 @@ class RequestTest extends BaseTest
$request->send();
}
+ /**
+ * @group functional
+ */
public function testSend()
{
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request('_status', Request::GET, array(), array(), $connection);
@@ -46,6 +51,9 @@ class RequestTest extends BaseTest
$this->assertInstanceOf('Elastica\Response', $response);
}
+ /**
+ * @group unit
+ */
public function testToString()
{
$path = 'test';
@@ -54,7 +62,7 @@ class RequestTest extends BaseTest
$data = array('key' => 'value');
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request($path, $method, $data, $query, $connection);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
index 1e026eae..e7b83ade 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResponseTest.php
@@ -1,16 +1,20 @@
<?php
-
namespace Elastica\Test;
+
use Elastica\Document;
use Elastica\Facet\DateHistogram;
use Elastica\Query;
use Elastica\Query\MatchAll;
use Elastica\Request;
-use Elastica\Type\Mapping;
+use Elastica\Response;
use Elastica\Test\Base as BaseTest;
+use Elastica\Type\Mapping;
class ResponseTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testClassHierarchy()
{
$facet = new DateHistogram('dateHist1');
@@ -19,25 +23,26 @@ class ResponseTest extends BaseTest
unset($facet);
}
+ /**
+ * @group functional
+ */
public function testResponse()
{
$index = $this->_createIndex();
$type = $index->getType('helloworld');
$mapping = new Mapping($type, array(
- 'name' => array('type' => 'string', 'store' => 'no'),
- 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss')
- ));
+ 'name' => array('type' => 'string', 'store' => 'no'),
+ 'dtmPosted' => array('type' => 'date', 'store' => 'no', 'format' => 'yyyy-MM-dd HH:mm:ss'),
+ ));
$type->setMapping($mapping);
- $doc = new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => "2011-06-23 21:53:00"));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => "2011-06-23 09:53:00"));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => "2011-07-08 08:53:00"));
- $type->addDocument($doc);
- $doc = new Document(4, array('name' => 'elastica search', 'dtmPosted' => "2011-07-08 01:53:00"));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'nicolas ruflin', 'dtmPosted' => '2011-06-23 21:53:00')),
+ new Document(2, array('name' => 'raul martinez jr', 'dtmPosted' => '2011-06-23 09:53:00')),
+ new Document(3, array('name' => 'rachelle clemente', 'dtmPosted' => '2011-07-08 08:53:00')),
+ new Document(4, array('name' => 'elastica search', 'dtmPosted' => '2011-07-08 01:53:00')),
+ ));
$query = new Query();
$query->setQuery(new MatchAll());
@@ -54,6 +59,9 @@ class ResponseTest extends BaseTest
$this->assertArrayHasKey('successful', $shardsStats);
}
+ /**
+ * @group functional
+ */
public function testIsOk()
{
$index = $this->_createIndex();
@@ -65,6 +73,9 @@ class ResponseTest extends BaseTest
$this->assertTrue($response->isOk());
}
+ /**
+ * @group functional
+ */
public function testIsOkMultiple()
{
$index = $this->_createIndex();
@@ -72,13 +83,114 @@ class ResponseTest extends BaseTest
$docs = array(
new Document(1, array('name' => 'ruflin')),
- new Document(2, array('name' => 'ruflin'))
+ new Document(2, array('name' => 'ruflin')),
);
$response = $type->addDocuments($docs);
$this->assertTrue($response->isOk());
}
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkWithErrorsField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'errors' => false,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkWithErrorsField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'errors' => true,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkItemsWithOkField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => true)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkItemsWithOkField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'ok' => true)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'ok' => false)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsOkBulkItemsWithStatusField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 200)),
+ ),
+ )));
+
+ $this->assertTrue($response->isOk());
+ }
+
+ /**
+ * @group unit
+ */
+ public function testIsNotOkBulkItemsWithStatusField()
+ {
+ $response = new Response(json_encode(array(
+ 'took' => 213,
+ 'items' => array(
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707891', '_version' => 4, 'status' => 200)),
+ array('index' => array('_index' => 'rohlik', '_type' => 'grocery', '_id' => '707893', '_version' => 4, 'status' => 301)),
+ ),
+ )));
+
+ $this->assertFalse($response->isOk());
+ }
+
+ /**
+ * @group functional
+ */
public function testGetDataEmpty()
{
$index = $this->_createIndex();
@@ -90,5 +202,4 @@ class ResponseTest extends BaseTest
$this->assertEquals(0, count($response));
}
-
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
index 2a62111d..be76d4a2 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultSetTest.php
@@ -1,27 +1,25 @@
<?php
-
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;
class ResultSetTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetters()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'elastica search'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'elastica library'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'elastica test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'elastica search')),
+ new Document(2, array('name' => 'elastica library')),
+ new Document(3, array('name' => 'elastica test')),
+ ));
$index->refresh();
$resultSet = $type->search('elastica search');
@@ -33,17 +31,19 @@ class ResultSetTest extends BaseTest
$this->assertEquals(3, count($resultSet));
}
+ /**
+ * @group functional
+ */
public function testArrayAccess()
{
$index = $this->_createIndex();
$type = $index->getType('test');
- $doc = new Document(1, array('name' => 'elastica search'));
- $type->addDocument($doc);
- $doc = new Document(2, array('name' => 'elastica library'));
- $type->addDocument($doc);
- $doc = new Document(3, array('name' => 'elastica test'));
- $type->addDocument($doc);
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'elastica search')),
+ new Document(2, array('name' => 'elastica library')),
+ new Document(3, array('name' => 'elastica test')),
+ ));
$index->refresh();
$resultSet = $type->search('elastica search');
@@ -57,6 +57,7 @@ class ResultSetTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidOffsetCreation()
@@ -75,6 +76,7 @@ class ResultSetTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testInvalidOffsetGet()
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
index 54d3ce55..a905fcc5 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ResultTest.php
@@ -1,15 +1,16 @@
<?php
-
namespace Elastica\Test;
-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
{
+ /**
+ * @group functional
+ */
public function testGetters()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
@@ -42,6 +43,9 @@ class ResultTest extends BaseTest
$this->assertEquals('hans', $result->username);
}
+ /**
+ * @group functional
+ */
public function testGetIdNoSource()
{
// Creates a new index 'xodoa' and a type 'user' inside this index
@@ -80,6 +84,9 @@ class ResultTest extends BaseTest
$this->assertInternalType('array', $result->getData());
}
+ /**
+ * @group functional
+ */
public function testGetTotalTimeReturnsExpectedResults()
{
$typeName = 'user';
@@ -103,17 +110,20 @@ class ResultTest extends BaseTest
'Total Time should be an integer'
);
}
-
+
+ /**
+ * @group unit
+ */
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/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
index a64670bb..9f06f9e6 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScanAndScrollTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
@@ -9,102 +8,66 @@ use Elastica\ScanAndScroll;
use Elastica\Search;
use Elastica\Test\Base as BaseTest;
-class ScanAndScrollTest extends BaseTest {
-
- public function testConstruct() {
- $scanAndScroll = $this->_prepareScanAndScroll();
-
- $this->assertInstanceOf('Elastica\ScanAndScroll', $scanAndScroll);
- }
-
- public function testDefaultProperties() {
- $scanAndScroll = $this->_prepareScanAndScroll();
+class ScanAndScrollTest extends BaseTest
+{
+ /**
+ * Full foreach test.
+ *
+ * @gropu functional
+ */
+ public function testForeach()
+ {
+ $scanAndScroll = new ScanAndScroll($this->_prepareSearch(), '1m', 2);
+ $docCount = 0;
+
+ /** @var ResultSet $resultSet */
+ foreach ($scanAndScroll as $scrollId => $resultSet) {
+ $docCount += $resultSet->count();
+ }
- $this->assertEquals('1m', $scanAndScroll->expiryTime);
- $this->assertEquals(1000, $scanAndScroll->sizePerShard);
+ /*
+ * number of loops and documents per iteration may fluctuate
+ * => only test end results
+ */
+ $this->assertEquals(12, $docCount);
}
- public function testQuerySizeOverride() {
- $query = new Query();
- $query->setSize(100);
-
- $index = $this->_createIndex('test_1');
- $index->refresh(); // Waits for the index to be fully created.
- $type = $index->getType('scanAndScrollTest');
-
- $search = new Search($this->_getClient());
- $search->addIndex($index)->addType($type);
- $search->setQuery($query);
+ /**
+ * query size revert options.
+ *
+ * @group functional
+ */
+ public function testQuerySizeRevert()
+ {
+ $search = $this->_prepareSearch();
+ $search->getQuery()->setSize(9);
$scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 10;
- $scanAndScroll->rewind();
-
- $this->assertEquals(10, $query->getParam('size'));
- }
-
- public function testSizePerShard() {
- $search = $this->_prepareSearch('test_2', 2, 20);
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 5;
$scanAndScroll->rewind();
+ $this->assertEquals(9, $search->getQuery()->getParam('size'));
- $this->assertEquals(10, $scanAndScroll->current()->count());
- }
-
- public function testScrollId() {
- $search = $this->_prepareSearch('test_3', 1, 2);
-
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 1;
-
- $scanAndScroll->rewind();
- $this->assertEquals(
- $scanAndScroll->current()->getResponse()->getScrollId(),
- $scanAndScroll->key()
- );
+ $scanAndScroll->next();
+ $this->assertEquals(9, $search->getQuery()->getParam('size'));
}
- public function testForeach() {
- $search = $this->_prepareSearch('test_4', 2, 11);
-
- $scanAndScroll = new ScanAndScroll($search);
- $scanAndScroll->sizePerShard = 5;
-
- // We expect 2 scrolls:
- // 1. with 10 hits,
- // 2. with 1 hit
- // Note: there is a 3. scroll with 0 hits
-
- $count = 0;
- foreach($scanAndScroll as $resultSet) {
- /** @var ResultSet $resultSet */
- $count++;
+ /**
+ * index: 12 docs, 2 shards.
+ *
+ * @return Search
+ */
+ private function _prepareSearch()
+ {
+ $index = $this->_createIndex('', true, 2);
+ $index->refresh();
- switch(true) {
- case $count == 1: $this->assertEquals(10, $resultSet->count()); break;
- case $count == 2: $this->assertEquals(1, $resultSet->count()); break;
- }
+ $docs = array();
+ for ($x = 1; $x <= 12; $x++) {
+ $docs[] = new Document($x, array('id' => $x, 'key' => 'value'));
}
- $this->assertEquals(2, $count);
- }
-
- private function _prepareScanAndScroll() {
- return new ScanAndScroll(new Search($this->_getClient()));
- }
-
- private function _prepareSearch($indexName, $indexShards, $docs) {
- $index = $this->_createIndex($indexName, true, $indexShards);
$type = $index->getType('scanAndScrollTest');
-
- $insert = array();
- for ($x = 1; $x <= $docs; $x++) {
- $insert[] = new Document($x, array('id' => $x, 'key' => 'value'));
- }
-
- $type->addDocuments($insert);
+ $type->addDocuments($docs);
$index->refresh();
$search = new Search($this->_getClient());
@@ -112,4 +75,4 @@ class ScanAndScrollTest extends BaseTest {
return $search;
}
-} \ No newline at end of file
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
index a3dd0d51..5448209d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptFieldsTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Document;
@@ -10,59 +9,54 @@ use Elastica\Test\Base as BaseTest;
class ScriptFieldsTest extends BaseTest
{
- protected $index;
-
- public function setUp()
- {
- $this->index = $this->_createIndex();
- }
-
- public function tearDown()
- {
- $this->index->delete();
- }
-
+ /**
+ * @group unit
+ */
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());
}
+ /**
+ * @group unit
+ */
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());
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testNameException()
@@ -71,18 +65,22 @@ class ScriptFieldsTest extends BaseTest
$scriptFields = new ScriptFields(array($script));
}
+ /**
+ * @group functional
+ */
public function testQuery()
{
- $type = $this->index->getType('test');
+ $index = $this->_createIndex();
+ $type = $index->getType('test');
$doc = new Document(1, array('firstname' => 'guschti', 'lastname' => 'ruflin'));
$type->addDocument($doc);
- $this->index->refresh();
+ $index->refresh();
$query = new Query();
$script = new Script('1 + 2');
$scriptFields = new ScriptFields(array(
- 'test' => $script
+ 'test' => $script,
));
$query->setScriptFields($scriptFields);
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
index 0a11d118..b42d8646 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScriptTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test;
use Elastica\Script;
@@ -7,6 +6,9 @@ use Elastica\Test\Base as BaseTest;
class ScriptTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstructor()
{
$value = "_score * doc['my_numeric_field'].value";
@@ -50,6 +52,9 @@ class ScriptTest extends BaseTest
$this->assertEquals($expected, $script->toArray());
}
+ /**
+ * @group unit
+ */
public function testCreateString()
{
$string = '_score * 2.0';
@@ -65,6 +70,9 @@ class ScriptTest extends BaseTest
$this->assertEquals($expected, $script->toArray());
}
+ /**
+ * @group unit
+ */
public function testCreateScript()
{
$data = new Script('_score * 2.0');
@@ -75,6 +83,9 @@ class ScriptTest extends BaseTest
$this->assertSame($data, $script);
}
+ /**
+ * @group unit
+ */
public function testCreateArray()
{
$string = '_score * 2.0';
@@ -101,6 +112,7 @@ class ScriptTest extends BaseTest
}
/**
+ * @group unit
* @dataProvider dataProviderCreateInvalid
* @expectedException \Elastica\Exception\InvalidException
*/
@@ -116,14 +128,42 @@ class ScriptTest extends BaseTest
{
return array(
array(
- new \stdClass
+ new \stdClass(),
),
array(
array('params' => array('param1' => 'one')),
),
array(
array('script' => '_score * 2.0', 'params' => 'param'),
- )
+ ),
);
}
+
+ /**
+ * @group unit
+ */
+ public function testSetLang()
+ {
+ $script = new Script('foo', array(), Script::LANG_GROOVY);
+ $this->assertEquals(Script::LANG_GROOVY, $script->getLang());
+
+ $script->setLang(Script::LANG_PYTHON);
+ $this->assertEquals(Script::LANG_PYTHON, $script->getLang());
+
+ $this->assertInstanceOf('Elastica\Script', $script->setLang(Script::LANG_PYTHON));
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetScript()
+ {
+ $script = new Script('foo');
+ $this->assertEquals('foo', $script->getScript());
+
+ $script->setScript('bar');
+ $this->assertEquals('bar', $script->getScript());
+
+ $this->assertInstanceOf('Elastica\Script', $script->setScript('foo'));
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php
new file mode 100644
index 00000000..df5b0317
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ScrollTest.php
@@ -0,0 +1,105 @@
+<?php
+namespace Elastica\Test;
+
+use Elastica\Document;
+use Elastica\Query;
+use Elastica\ResultSet;
+use Elastica\Scroll;
+use Elastica\Search;
+
+class ScrollTest extends Base
+{
+ /**
+ * Full foreach test.
+ *
+ * @group functional
+ */
+ public function testForeach()
+ {
+ $scroll = new Scroll($this->_prepareSearch());
+ $count = 1;
+
+ /** @var ResultSet $resultSet */
+ foreach ($scroll as $scrollId => $resultSet) {
+ $this->assertNotEmpty($scrollId);
+
+ $results = $resultSet->getResults();
+ switch (true) {
+ case $count === 1:
+ // hits: 1 - 5
+ $this->assertEquals(5, $resultSet->count());
+ $this->assertEquals('1', $results[0]->getId());
+ $this->assertEquals('5', $results[4]->getId());
+ break;
+ case $count === 2:
+ // hits: 6 - 10
+ $this->assertEquals(5, $resultSet->count());
+ $this->assertEquals('6', $results[0]->getId());
+ $this->assertEquals('10', $results[4]->getId());
+ break;
+ case $count === 3:
+ // hit: 11
+ $this->assertEquals(1, $resultSet->count());
+ $this->assertEquals('11', $results[0]->getId());
+ break;
+ case $count === 4:
+ $this->assertEquals(0, $resultSet->count());
+ break;
+ default:
+ $this->fail('too many iterations');
+ }
+
+ $count++;
+ }
+ }
+
+ /**
+ * Scroll must not overwrite options.
+ *
+ * @group functional
+ */
+ public function testSearchRevert()
+ {
+ $search = $this->_prepareSearch();
+
+ $search->setOption(Search::OPTION_SCROLL, 'must');
+ $search->setOption(Search::OPTION_SCROLL_ID, 'not');
+ $search->setOption(Search::OPTION_SEARCH_TYPE, 'change');
+ $old = $search->getOptions();
+
+ $scroll = new Scroll($search);
+
+ $scroll->rewind();
+ $this->assertEquals($old, $search->getOptions());
+
+ $scroll->next();
+ $this->assertEquals($old, $search->getOptions());
+ }
+
+ /**
+ * index: 11 docs
+ * query size: 5.
+ *
+ * @return Search
+ */
+ private function _prepareSearch()
+ {
+ $index = $this->_createIndex();
+ $index->refresh();
+
+ $docs = array();
+ for ($x = 1; $x <= 11; $x++) {
+ $docs[] = new Document($x, array('id' => $x, 'key' => 'value'));
+ }
+
+ $type = $index->getType('scrollTest');
+ $type->addDocuments($docs);
+ $index->refresh();
+
+ $search = new Search($this->_getClient());
+ $search->addIndex($index)->addType($type);
+ $search->getQuery()->setSize(5);
+
+ return $search;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
index e08d2d60..905f8462 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SearchTest.php
@@ -1,15 +1,14 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
+use Elastica\Aggregation;
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;
@@ -17,6 +16,9 @@ use Elastica\Type;
class SearchTest extends BaseTest
{
+ /**
+ * @group unit
+ */
public function testConstruct()
{
$client = $this->_getClient();
@@ -26,13 +28,16 @@ class SearchTest extends BaseTest
$this->assertSame($client, $search->getClient());
}
+ /**
+ * @group functional
+ */
public function testAddIndex()
{
$client = $this->_getClient();
$search = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$search->addIndex($index1);
$indices = $search->getIndices();
@@ -55,6 +60,9 @@ class SearchTest extends BaseTest
$this->assertTrue(in_array('test3', $indices));
}
+ /**
+ * @group unit
+ */
public function testAddIndices()
{
$client = $this->_getClient();
@@ -69,6 +77,9 @@ class SearchTest extends BaseTest
$this->assertEquals(2, count($search->getIndices()));
}
+ /**
+ * @group functional
+ */
public function testAddType()
{
$client = $this->_getClient();
@@ -102,12 +113,15 @@ class SearchTest extends BaseTest
$this->assertTrue(in_array('test3', $types));
}
+ /**
+ * @group unit
+ */
public function testAddTypes()
{
$client = $this->_getClient();
$search = new Search($client);
- $index = $this->_createIndex();
+ $index = $client->getIndex('foo');
$types = array();
$types[] = $index->getType('type1');
@@ -119,6 +133,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddTypeInvalid()
@@ -130,6 +145,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\InvalidException
*/
public function testAddIndexInvalid()
@@ -140,14 +156,30 @@ class SearchTest extends BaseTest
$search->addIndex(new \stdClass());
}
+ /**
+ * @group unit
+ */
+ public function testAddNumericIndex()
+ {
+ $client = $this->_getClient();
+ $search = new Search($client);
+
+ $search->addIndex(1);
+
+ $this->assertContains('1', $search->getIndices(), 'Make sure it has been added and converted to string');
+ }
+
+ /**
+ * @group functional
+ */
public function testGetPath()
{
$client = $this->_getClient();
$search1 = new Search($client);
$search2 = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$type1 = $index1->getType('type1');
$type2 = $index1->getType('type2');
@@ -157,32 +189,35 @@ class SearchTest extends BaseTest
// 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());
}
+ /**
+ * @group functional
+ */
public function testSearchRequest()
{
$client = $this->_getClient();
$search1 = new Search($client);
- $index1 = $this->_createIndex('test1');
- $index2 = $this->_createIndex('test2');
+ $index1 = $this->_createIndex();
+ $index2 = $this->_createIndex();
$type1 = $index1->getType('hello1');
@@ -205,11 +240,14 @@ class SearchTest extends BaseTest
$this->assertFalse($result->getResponse()->hasError());
}
+ /**
+ * @group functional
+ */
public function testSearchScrollRequest()
{
$client = $this->_getClient();
- $index = $this->_createIndex('test');
+ $index = $this->_createIndex();
$type = $index->getType('scrolltest');
$docs = array();
@@ -265,7 +303,9 @@ class SearchTest extends BaseTest
}
/**
- * Default Limit tests for \Elastica\Search
+ * Default Limit tests for \Elastica\Search.
+ *
+ * @group functional
*/
public function testLimitDefaultSearch()
{
@@ -275,20 +315,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -303,6 +343,7 @@ class SearchTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testArrayConfigSearch()
@@ -357,6 +398,13 @@ class SearchTest extends BaseTest
$this->assertTrue(($resultSet->count() === 0) && $resultSet->getTotalHits() === 11);
//Timeout - this one is a bit more tricky to test
+ $mockResponse = new \Elastica\Response(json_encode(array('timed_out' => true)));
+ $client = $this->getMockBuilder('Elastica\\Client')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $client->method('request')
+ ->will($this->returnValue($mockResponse));
+ $search = new Search($client);
$script = new Script('Thread.sleep(100); return _score;');
$query = new FunctionScore();
$query->addScriptScoreFunction($script);
@@ -367,9 +415,12 @@ class SearchTest extends BaseTest
$resultSet = $search->search('test', array('invalid_option' => 'invalid_option_value'));
}
+ /**
+ * @group functional
+ */
public function testSearchWithVersionOption()
{
- $index = $this->_createIndex('test1');
+ $index = $this->_createIndex();
$doc = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'ruflin'));
$index->getType('test')->addDocument($doc);
$index->refresh();
@@ -388,6 +439,9 @@ class SearchTest extends BaseTest
$this->assertEquals(1, $hit->getParam('_version'));
}
+ /**
+ * @group functional
+ */
public function testCountRequest()
{
$client = $this->_getClient();
@@ -396,21 +450,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley'));
-
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'marley')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -431,6 +484,9 @@ class SearchTest extends BaseTest
$this->assertEquals(0, $count);
}
+ /**
+ * @group functional
+ */
public function testEmptySearch()
{
$client = $this->_getClient();
@@ -438,20 +494,20 @@ class SearchTest extends BaseTest
$index = $client->getIndex('zero');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley'));
- $docs[] = new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
- $docs[] = new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny'));
$type = $index->getType('zeroType');
- $type->addDocuments($docs);
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(2, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(3, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(4, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(5, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(6, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(7, array('id' => 1, 'email' => 'test@test.com', 'username' => 'farrelley')),
+ new Document(8, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(9, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(10, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ new Document(11, array('id' => 1, 'email' => 'test@test.com', 'username' => 'bunny')),
+ ));
$index->refresh();
$search->addIndex($index)->addType($type);
@@ -470,31 +526,122 @@ class SearchTest extends BaseTest
$source = $resultSet->current()->getSource();
$this->assertEquals('bunny', $source['username']);
}
-
- public function testCount() {
- $index = $this->_createIndex('eeee');
+
+ /**
+ * @group functional
+ */
+ public function testCount()
+ {
+ $index = $this->_createIndex();
$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);
-
- $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());
- }
-
- public function testScanAndScroll() {
+
+ $type->addDocument($doc);
+ $index->refresh();
+
+ $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());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testScanAndScroll()
+ {
$search = new Search($this->_getClient());
$this->assertInstanceOf('Elastica\ScanAndScroll', $search->scanAndScroll());
}
+
+ /**
+ * @group functional
+ */
+ public function testIgnoreUnavailableOption()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_7086b4c2ee585bbb6740ece5ed7ece01');
+ $query = new MatchAll();
+
+ $search = new Search($client);
+ $search->addIndex($index);
+
+ $exception = null;
+ try {
+ $search->search($query);
+ } catch (ResponseException $e) {
+ $exception = $e;
+ }
+ $this->assertEquals('IndexMissingException', $exception->getElasticsearchException()->getExceptionName());
+
+ $results = $search->search($query, array(Search::OPTION_SEARCH_IGNORE_UNAVAILABLE => true));
+ $this->assertInstanceOf('\Elastica\ResultSet', $results);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testQueryCacheOption()
+ {
+ $client = $this->_getClient();
+
+ $index = $client->getIndex('zero');
+ $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
+ $type = $index->getType('zeroType');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'username' => 'farrelley')),
+ new Document(2, array('id' => 2, 'username' => 'bunny')),
+ ));
+ $index->refresh();
+
+ $aggregation = new Aggregation\Terms('username');
+ $aggregation->setField('username');
+
+ $query = new Query();
+ $query->addAggregation($aggregation);
+
+ $search = new Search($client);
+ $search->addIndex($index);
+ $search->setQuery($query);
+ $search->setOption(Search::OPTION_SEARCH_TYPE, Search::OPTION_SEARCH_TYPE_COUNT);
+ $search->setOption(Search::OPTION_QUERY_CACHE, true);
+
+ // before search query cache should be empty
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(0, $queryCache['hit_count']);
+ $this->assertEquals(0, $queryCache['miss_count']);
+
+ // first search should result in cache miss and save data to cache
+ $search->search();
+ $index->getStats()->refresh();
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(0, $queryCache['hit_count']);
+ $this->assertEquals(1, $queryCache['miss_count']);
+
+ // next search should result in cache hit
+ $search->search();
+ $index->getStats()->refresh();
+ $statsData = $index->getStats()->getData();
+ $queryCache = $statsData['_all']['primaries']['query_cache'];
+
+ $this->assertNotEquals(0, $queryCache['memory_size_in_bytes']);
+ $this->assertEquals(0, $queryCache['evictions']);
+ $this->assertEquals(1, $queryCache['hit_count']);
+ $this->assertEquals(1, $queryCache['miss_count']);
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php
new file mode 100644
index 00000000..93d6e32b
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/ShutdownTest.php
@@ -0,0 +1,74 @@
+<?php
+
+use Elastica\Test\Base as BaseTest;
+
+/**
+ * These tests shuts down node/cluster, so can't be executed with rest testsuite
+ * Please use `sudo service elasticsearch restart` after every run of these tests.
+ */
+class ShutdownTest extends BaseTest
+{
+ /**
+ * @group shutdown
+ */
+ public function testNodeShutdown()
+ {
+ // Get cluster nodes
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ $nodesCount = count($nodes);
+
+ if ($nodesCount < 2) {
+ $this->markTestIncomplete('At least two nodes have to be running, because 1 node is shutdown');
+ }
+
+ $portFound = false;
+ // sayonara, wolverine, we'd never love you
+ foreach ($nodes as $node) {
+ if ((int) $node->getInfo()->getPort() === 9201) {
+ $portFound = true;
+ $node->shutdown('1s');
+ break;
+ }
+ }
+
+ if (!$portFound) {
+ $this->markTestSkipped('This test was skipped as in the new docker environment all elasticsearch instances run on the same port');
+ }
+
+ // Wait until node is shutdown
+ sleep(5);
+
+ // Get nodes again
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ // Only one left
+ $this->assertCount($nodesCount - 1, $nodes);
+ }
+
+ /**
+ * @group shutdown
+ * @depends testNodeShutdown
+ * @expectedException \Elastica\Exception\Connection\HttpException
+ */
+ public function testClusterShutdown()
+ {
+ // Get cluster nodes
+ $client = $this->_getClient();
+ $cluster = $client->getCluster();
+ $nodes = $cluster->getNodes();
+
+ // Shutdown cluster
+ $cluster->shutdown('1s');
+
+ // Wait...
+ sleep(5);
+
+ // Now exception must be thrown
+ $client->getStatus();
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
index 3ac5bfe2..fa190e8c 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/SnapshotTest.php
@@ -1,8 +1,6 @@
<?php
-
namespace Elastica\Test;
-
use Elastica\Document;
use Elastica\Index;
use Elastica\Snapshot;
@@ -29,62 +27,62 @@ class SnapshotTest extends Base
parent::setUp();
$this->_snapshot = new Snapshot($this->_getClient());
- $this->_index = $this->_createIndex("test_snapshot");
+ $this->_index = $this->_createIndex();
$this->_docs = array(
- new Document("1", array("city" => "San Diego")),
- new Document("2", array("city" => "San Luis Obispo")),
- new Document("3", array("city" => "San Francisco")),
+ new Document('1', array('city' => 'San Diego')),
+ new Document('2', array('city' => 'San Luis Obispo')),
+ new Document('3', array('city' => 'San Francisco')),
);
- $this->_index->getType("test")->addDocuments($this->_docs);
+ $this->_index->getType('test')->addDocuments($this->_docs);
$this->_index->refresh();
}
- protected function tearDown()
- {
- parent::tearDown();
- $this->_index->delete();
- }
-
+ /**
+ * @group functional
+ */
public function testRegisterRepository()
{
- $name = "test_register";
- $location = "/tmp/test_register";
+ $name = 'test_register';
+ $location = '/tmp/test_register';
- $response = $this->_snapshot->registerRepository($name, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($name, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
$response = $this->_snapshot->getRepository($name);
- $this->assertEquals($location, $response["settings"]["location"]);
+ $this->assertEquals($location, $response['settings']['location']);
// attempt to retrieve a repository which does not exist
$this->setExpectedException('Elastica\Exception\NotFoundException');
- $this->_snapshot->getRepository("foobar");
+ $this->_snapshot->getRepository('foobar');
}
+ /**
+ * @group functional
+ */
public function testSnapshotAndRestore()
{
- $repositoryName = "test_repository";
+ $repositoryName = 'test_repository';
$location = "/tmp/{$repositoryName}";
// register the repository
- $response = $this->_snapshot->registerRepository($repositoryName, "fs", array("location" => $location));
+ $response = $this->_snapshot->registerRepository($repositoryName, 'fs', array('location' => $location));
$this->assertTrue($response->isOk());
// create a snapshot of our test index
- $snapshotName = "test_snapshot_1";
- $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array("indices" => $this->_index->getName()), true);
+ $snapshotName = 'test_snapshot_1';
+ $response = $this->_snapshot->createSnapshot($repositoryName, $snapshotName, array('indices' => $this->_index->getName()), true);
// ensure that the snapshot was created properly
$this->assertTrue($response->isOk());
- $this->assertArrayHasKey("snapshot", $response->getData());
+ $this->assertArrayHasKey('snapshot', $response->getData());
$data = $response->getData();
- $this->assertContains($this->_index->getName(), $data["snapshot"]["indices"]);
- $this->assertEquals(1, sizeof($data["snapshot"]["indices"])); // only the specified index should be present
- $this->assertEquals($snapshotName, $data["snapshot"]["snapshot"]);
+ $this->assertContains($this->_index->getName(), $data['snapshot']['indices']);
+ $this->assertEquals(1, sizeof($data['snapshot']['indices'])); // only the specified index should be present
+ $this->assertEquals($snapshotName, $data['snapshot']['snapshot']);
// retrieve data regarding the snapshot
$response = $this->_snapshot->getSnapshot($repositoryName, $snapshotName);
- $this->assertContains($this->_index->getName(), $response["indices"]);
+ $this->assertContains($this->_index->getName(), $response['indices']);
// delete our test index
$this->_index->delete();
@@ -97,7 +95,7 @@ class SnapshotTest extends Base
$this->_index->optimize();
// ensure that the index has been restored
- $count = $this->_index->getType("test")->count();
+ $count = $this->_index->getType('test')->count();
$this->assertEquals(sizeof($this->_docs), $count);
// delete the snapshot
@@ -109,4 +107,3 @@ class SnapshotTest extends Base
$this->_snapshot->getSnapshot($repositoryName, $snapshotName);
}
}
- \ No newline at end of file
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
index 14d7950a..fe6bb091 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/StatusTest.php
@@ -1,13 +1,15 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
+
use Elastica\Exception\ResponseException;
use Elastica\Status;
use Elastica\Test\Base as BaseTest;
class StatusTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testGetResponse()
{
$index = $this->_createIndex();
@@ -15,6 +17,9 @@ class StatusTest extends BaseTest
$this->assertInstanceOf('Elastica\Response', $status->getResponse());
}
+ /**
+ * @group functional
+ */
public function testGetIndexStatuses()
{
$index = $this->_createIndex();
@@ -29,6 +34,9 @@ class StatusTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testGetIndexNames()
{
$indexName = 'test';
@@ -36,8 +44,8 @@ class StatusTest extends BaseTest
$index = $client->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();
@@ -50,6 +58,9 @@ class StatusTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testIndexExists()
{
$indexName = 'elastica_test';
@@ -72,12 +83,15 @@ class StatusTest extends BaseTest
$this->assertTrue($status->indexExists($indexName));
}
+ /**
+ * @group functional
+ */
public function testAliasExists()
{
- $indexName = 'test';
$aliasName = 'elastica_test-alias';
$index1 = $this->_createIndex();
+ $indexName = $index1->getName();
$status = new Status($index1->getClient());
@@ -92,19 +106,22 @@ class StatusTest extends BaseTest
$this->assertTrue($status->aliasExists($aliasName));
$indicesWithAlias = $status->getIndicesWithAlias($aliasName);
- $this->assertEquals(array("elastica_$indexName"), array_map(
- function($index) {
+ $this->assertEquals(array($indexName), array_map(
+ function ($index) {
return $index->getName();
}, $indicesWithAlias));
}
+ /**
+ * @group functional
+ */
public function testServerStatus()
{
$client = $this->_getClient();
$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/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php
new file mode 100644
index 00000000..6120743c
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/CompletionTest.php
@@ -0,0 +1,140 @@
+<?php
+namespace Elastica\Test\Suggest;
+
+use Elastica\Document;
+use Elastica\Index;
+use Elastica\Query;
+use Elastica\Suggest\Completion;
+use Elastica\Test\Base as BaseTest;
+
+class CompletionTest extends BaseTest
+{
+ /**
+ * @return Index
+ */
+ protected function _getIndexForTest()
+ {
+ $index = $this->_createIndex();
+ $type = $index->getType('song');
+
+ $type->setMapping(array(
+ 'fieldName' => array(
+ 'type' => 'completion',
+ 'payloads' => true,
+ ),
+ ));
+
+ $type->addDocuments(array(
+ new Document(1, array(
+ 'fieldName' => array(
+ 'input' => array('Nevermind', 'Nirvana'),
+ 'output' => 'Nevermind - Nirvana',
+ 'payload' => array(
+ 'year' => 1991,
+ ),
+ ),
+ )),
+ new Document(2, array(
+ 'fieldName' => array(
+ 'input' => array('Bleach', 'Nirvana'),
+ 'output' => 'Bleach - Nirvana',
+ 'payload' => array(
+ 'year' => 1989,
+ ),
+ ),
+ )),
+ new Document(3, array(
+ 'fieldName' => array(
+ 'input' => array('Incesticide', 'Nirvana'),
+ 'output' => 'Incesticide - Nirvana',
+ 'payload' => array(
+ 'year' => 1992,
+ ),
+ ),
+ )),
+ ));
+
+ $index->refresh();
+
+ return $index;
+ }
+
+ /**
+ * @group unit
+ */
+ public function testToArray()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setText('foo');
+ $suggest->setSize(10);
+ $expected = array(
+ 'text' => 'foo',
+ 'completion' => array(
+ 'size' => 10,
+ 'field' => 'fieldName',
+ ),
+ );
+ $this->assertEquals($expected, $suggest->toArray());
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSuggestWorks()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setText('Never');
+
+ $index = $this->_getIndexForTest();
+ $resultSet = $index->search(Query::create($suggest));
+
+ $this->assertTrue($resultSet->hasSuggests());
+
+ $suggests = $resultSet->getSuggests();
+ $options = $suggests['suggestName'][0]['options'];
+
+ $this->assertCount(1, $options);
+ $this->assertEquals('Nevermind - Nirvana', $options[0]['text']);
+ $this->assertEquals(1991, $options[0]['payload']['year']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testFuzzySuggestWorks()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+ $suggest->setFuzzy(array('fuzziness' => 2));
+ $suggest->setText('Neavermint');
+
+ $index = $this->_getIndexForTest();
+ $resultSet = $index->search(Query::create($suggest));
+
+ $this->assertTrue($resultSet->hasSuggests());
+
+ $suggests = $resultSet->getSuggests();
+ $options = $suggests['suggestName'][0]['options'];
+
+ $this->assertCount(1, $options);
+ $this->assertEquals('Nevermind - Nirvana', $options[0]['text']);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testSetFuzzy()
+ {
+ $suggest = new Completion('suggestName', 'fieldName');
+
+ $fuzzy = array(
+ 'unicode_aware' => true,
+ 'fuzziness' => 3,
+ );
+
+ $suggest->setFuzzy($fuzzy);
+
+ $this->assertEquals($fuzzy, $suggest->getParam('fuzzy'));
+
+ $this->assertInstanceOf('Elastica\\Suggest\\Completion', $suggest->setFuzzy($fuzzy));
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
index eda08ba0..9ce345d4 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/PhraseTest.php
@@ -1,44 +1,37 @@
<?php
-
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
{
- const TEST_TYPE = 'testSuggestType';
-
/**
- * @var Index
+ * @return Index
*/
- protected $_index;
-
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('test_suggest_phrase');
- $docs = array();
- $docs[] = new Document(1, array('text' => 'Github is pretty cool'));
- $docs[] = new Document(2, array('text' => 'Elasticsearch is bonsai cool'));
- $docs[] = new Document(3, array('text' => 'This is a test phrase'));
- $docs[] = new Document(4, array('text' => 'Another sentence for testing'));
- $docs[] = new Document(5, array('text' => 'Some more words here'));
- $type = $this->_index->getType(self::TEST_TYPE);
- $type->addDocuments($docs);
- $this->_index->refresh();
- }
+ $index = $this->_createIndex();
+ $type = $index->getType('testSuggestType');
+ $type->addDocuments(array(
+ new Document(1, array('text' => 'Github is pretty cool')),
+ new Document(2, array('text' => 'Elasticsearch is bonsai cool')),
+ new Document(3, array('text' => 'This is a test phrase')),
+ new Document(4, array('text' => 'Another sentence for testing')),
+ new Document(5, array('text' => 'Some more words here')),
+ ));
+ $index->refresh();
- protected function tearDown()
- {
- $this->_index->delete();
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$suggest = new Suggest();
@@ -55,31 +48,35 @@ class PhraseTest extends BaseTest
'text' => 'elasticsearch is bansai coor',
'phrase' => array(
'field' => 'text',
- 'analyzer' => 'simple'
- )
- )
- )
+ 'analyzer' => 'simple',
+ ),
+ ),
+ ),
);
$this->assertEquals($expected, $suggest->toArray());
}
+ /**
+ * @group functional
+ */
public function testPhraseSuggest()
{
$suggest = new Suggest();
$phraseSuggest = new Phrase('suggest1', 'text');
- $phraseSuggest->setText("elasticsearch is bansai coor");
- $phraseSuggest->setAnalyzer("simple")->setHighlight("<suggest>", "</suggest>")->setStupidBackoffSmoothing(0.4);
- $phraseSuggest->addCandidateGenerator(new DirectGenerator("text"));
+ $phraseSuggest->setText('elasticsearch is bansai coor');
+ $phraseSuggest->setAnalyzer('simple')->setHighlight('<suggest>', '</suggest>')->setStupidBackoffSmoothing(0.4);
+ $phraseSuggest->addCandidateGenerator(new DirectGenerator('text'));
$suggest->addSuggestion($phraseSuggest);
- $result = $this->_index->search($suggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($suggest);
$suggests = $result->getSuggests();
// 3 suggestions should be returned: One in which both misspellings are corrected, and two in which only one misspelling is corrected.
$this->assertEquals(3, sizeof($suggests['suggest1'][0]['options']));
- $this->assertEquals("elasticsearch is <suggest>bonsai cool</suggest>", $suggests['suggest1'][0]['options'][0]['highlighted']);
- $this->assertEquals("elasticsearch is bonsai cool", $suggests['suggest1'][0]['options'][0]['text']);
+ $this->assertEquals('elasticsearch is <suggest>bonsai cool</suggest>', $suggests['suggest1'][0]['options'][0]['highlighted']);
+ $this->assertEquals('elasticsearch is bonsai cool', $suggests['suggest1'][0]['options'][0]['text']);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
index 7765f1bb..f1250e6f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Suggest/TermTest.php
@@ -1,44 +1,37 @@
<?php
-
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
{
- const TEST_TYPE = 'testSuggestType';
-
/**
- * @var Index
+ * @return Index
*/
- protected $_index;
-
- protected function setUp()
+ protected function _getIndexForTest()
{
- parent::setUp();
- $this->_index = $this->_createIndex('test_suggest');
- $docs = array();
- $docs[] = new Document(1, array('id' => 1, 'text' => 'GitHub'));
- $docs[] = new Document(2, array('id' => 1, 'text' => 'Elastic'));
- $docs[] = new Document(3, array('id' => 1, 'text' => 'Search'));
- $docs[] = new Document(4, array('id' => 1, 'text' => 'Food'));
- $docs[] = new Document(5, array('id' => 1, 'text' => 'Flood'));
- $docs[] = new Document(6, array('id' => 1, 'text' => 'Folks'));
- $type = $this->_index->getType(self::TEST_TYPE);
- $type->addDocuments($docs);
- $this->_index->refresh();
- }
-
- protected function tearDown()
- {
- $this->_index->delete();
+ $index = $this->_createIndex();
+ $type = $index->getType('testSuggestType');
+ $type->addDocuments(array(
+ new Document(1, array('id' => 1, 'text' => 'GitHub')),
+ new Document(2, array('id' => 1, 'text' => 'Elastic')),
+ new Document(3, array('id' => 1, 'text' => 'Search')),
+ new Document(4, array('id' => 1, 'text' => 'Food')),
+ new Document(5, array('id' => 1, 'text' => 'Flood')),
+ new Document(6, array('id' => 1, 'text' => 'Folks')),
+ ));
+ $index->refresh();
+
+ return $index;
}
+ /**
+ * @group unit
+ */
public function testToArray()
{
$suggest = new Suggest();
@@ -51,22 +44,25 @@ class TermTest extends BaseTest
'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());
}
+ /**
+ * @group functional
+ */
public function testSuggestResults()
{
$suggest = new Suggest();
@@ -75,7 +71,8 @@ class TermTest extends BaseTest
$suggest2 = new Term('suggest2', '_all');
$suggest->addSuggestion($suggest2->setText('Girhub'));
- $result = $this->_index->search($suggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($suggest);
$this->assertEquals(2, $result->countSuggests());
@@ -88,12 +85,16 @@ class TermTest extends BaseTest
$this->assertEquals('food', $suggests['suggest1'][0]['options'][0]['text']);
}
+ /**
+ * @group functional
+ */
public function testSuggestNoResults()
{
$termSuggest = new Term('suggest1', '_all');
$termSuggest->setText('Foobar')->setSize(4);
- $result = $this->_index->search($termSuggest);
+ $index = $this->_getIndexForTest();
+ $result = $index->search($termSuggest);
$this->assertEquals(1, $result->countSuggests());
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php
new file mode 100644
index 00000000..f8fbf280
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Tool/CrossIndexTest.php
@@ -0,0 +1,135 @@
+<?php
+namespace Elastica\Test\Tool;
+
+use Elastica\Document;
+use Elastica\Test\Base;
+use Elastica\Tool\CrossIndex;
+use Elastica\Type;
+
+class CrossIndexTest extends Base
+{
+ /**
+ * Test default reindex.
+ */
+ public function testReindex()
+ {
+ $oldIndex = $this->_createIndex(null, true, 2);
+ $this->_addDocs($oldIndex->getType('crossIndexTest'), 10);
+
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ $this->assertInstanceOf(
+ 'Elastica\Index',
+ CrossIndex::reindex($oldIndex, $newIndex)
+ );
+
+ $this->assertEquals(10, $newIndex->count());
+ }
+
+ /**
+ * Test reindex type option.
+ */
+ public function testReindexTypeOption()
+ {
+ $oldIndex = $this->_createIndex('', true, 2);
+ $type1 = $oldIndex->getType('crossIndexTest_1');
+ $type2 = $oldIndex->getType('crossIndexTest_2');
+
+ $docs1 = $this->_addDocs($type1, 10);
+ $docs2 = $this->_addDocs($type2, 10);
+
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ // \Elastica\Type
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => $type1,
+ ));
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs1);
+
+ // string
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => 'crossIndexTest_2',
+ ));
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs2);
+
+ // array
+ CrossIndex::reindex($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => array(
+ 'crossIndexTest_1',
+ $type2,
+ ),
+ ));
+ $this->assertEquals(20, $newIndex->count());
+ }
+
+ /**
+ * Test default copy.
+ */
+ public function testCopy()
+ {
+ $oldIndex = $this->_createIndex(null, true, 2);
+ $newIndex = $this->_createIndex(null, true, 2);
+
+ $oldType = $oldIndex->getType('copy_test');
+ $oldMapping = array(
+ 'name' => array(
+ 'type' => 'string',
+ 'store' => true,
+ ),
+ );
+ $oldType->setMapping($oldMapping);
+ $docs = $this->_addDocs($oldType, 10);
+
+ // mapping
+ $this->assertInstanceOf(
+ 'Elastica\Index',
+ CrossIndex::copy($oldIndex, $newIndex)
+ );
+
+ $newMapping = $newIndex->getType('copy_test')->getMapping();
+ if (!isset($newMapping['copy_test']['properties']['name'])) {
+ $this->fail('could not request new mapping');
+ }
+
+ $this->assertEquals(
+ $oldMapping['name'],
+ $newMapping['copy_test']['properties']['name']
+ );
+
+ // document copy
+ $this->assertEquals(10, $newIndex->count());
+ $newIndex->deleteDocuments($docs);
+
+ // ignore mapping
+ $ignoredType = $oldIndex->getType('copy_test_1');
+ $this->_addDocs($ignoredType, 10);
+
+ CrossIndex::copy($oldIndex, $newIndex, array(
+ CrossIndex::OPTION_TYPE => $oldType,
+ ));
+
+ $this->assertFalse($newIndex->getType($ignoredType->getName())->exists());
+ $this->assertEquals(10, $newIndex->count());
+ }
+
+ /**
+ * @param Type $type
+ * @param int $docs
+ *
+ * @return array
+ */
+ private function _addDocs(Type $type, $docs)
+ {
+ $insert = array();
+ for ($i = 1; $i <= $docs; $i++) {
+ $insert[] = new Document($i, array('_id' => $i, 'key' => 'value'));
+ }
+
+ $type->addDocuments($insert);
+ $type->getIndex()->refresh();
+
+ return $insert;
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
index 4f1c7114..20573cc7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
@@ -1,16 +1,14 @@
<?php
-
namespace Elastica\Test\Transport;
+use Elastica\Connection;
use Elastica\Transport\AbstractTransport;
use Elastica\Transport\Http;
-use Elastica\Connection;
-use Elastica\Exception\InvalidException;
class AbstractTransportTest extends \PHPUnit_Framework_TestCase
{
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -27,6 +25,7 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @group unit
* @dataProvider getValidDefinitions
*/
public function testCanCreateTransportInstances($transport)
@@ -47,6 +46,7 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
}
/**
+ * @group unit
* @dataProvider getInvalidDefinitions
* @expectedException Elastica\Exception\InvalidException
* @expectedExceptionMessage Invalid transport
@@ -56,6 +56,9 @@ class AbstractTransportTest extends \PHPUnit_Framework_TestCase
AbstractTransport::create($transport, new Connection());
}
+ /**
+ * @group unit
+ */
public function testCanInjectParamsWhenUsingArray()
{
$connection = new Connection();
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
index b2e385bb..04e7ee2d 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
@@ -1,13 +1,10 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class GuzzleTest extends BaseTest
{
@@ -18,19 +15,8 @@ class GuzzleTest extends BaseTest
}
}
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -38,26 +24,27 @@ class GuzzleTest extends BaseTest
{
return array(
array(
- array('transport' => 'Guzzle'),
- 'GET'
+ array('persistent' => false, 'transport' => 'Guzzle'),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
- 'GET'
+ array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
- 'POST'
+ array('persistent' => false, 'transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
+ 'POST',
),
);
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('dynamic_http_method_test');
$index->create(array(), true);
@@ -70,22 +57,26 @@ class GuzzleTest extends BaseTest
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$status = $client->getStatus();
$info = $status->getResponse()->getTransferInfo();
$this->assertStringStartsWith('GET', $info['request_header']);
}
+ /**
+ * @group functional
+ */
public function testWithEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12345/');
+ putenv('http_proxy='.$this->_getProxyUrl().'/');
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -96,16 +87,18 @@ class GuzzleTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithEnabledEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ putenv('http_proxy='.$this->_getProxyUrl403().'/');
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(403, $transferInfo['http_code']);
- $client = new \Elastica\Client();
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -113,31 +106,40 @@ class GuzzleTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithProxy()
{
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
+ $client->getConnection()->setProxy($this->_getProxyUrl());
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testWithoutProxy()
{
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testBodyReuse()
{
- $client = new Client(array('transport' => 'Guzzle'));
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'persistent' => false));
$index = $client->getIndex('elastica_body_reuse_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -160,4 +162,19 @@ class GuzzleTest extends BaseTest
$this->assertEquals(1, $resultSet->getTotalHits());
}
+ /**
+ * @group unit
+ * @expectedException Elastica\Exception\Connection\GuzzleException
+ */
+ public function testInvalidConnection()
+ {
+ $client = $this->_getClient(array('transport' => 'Guzzle', 'port' => 4500, 'persistent' => false));
+ $response = $client->request('_status', 'GET');
+ }
+
+ protected function tearDown()
+ {
+ parent::tearDown();
+ putenv('http_proxy=');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
index 88c93bea..53ee105f 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
@@ -1,29 +1,15 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
use Elastica\Query;
use Elastica\ResultSet;
use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
class HttpTest extends BaseTest
{
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
/**
- * Return transport configuration and the expected HTTP method
+ * Return transport configuration and the expected HTTP method.
*
* @return array[]
*/
@@ -31,30 +17,31 @@ class HttpTest extends BaseTest
{
return array(
array(
- array('transport' => 'Http'),
- 'GET'
+ array('transport' => 'Http', 'curl' => array(CURLINFO_HEADER_OUT => true)),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => false)),
- 'GET'
+ array('transport' => array('type' => 'Http', 'postWithRequestBody' => false, 'curl' => array(CURLINFO_HEADER_OUT => true))),
+ 'GET',
),
array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => true)),
- 'POST'
+ array('transport' => array('type' => 'Http', 'postWithRequestBody' => true, 'curl' => array(CURLINFO_HEADER_OUT => true))),
+ 'POST',
),
);
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('dynamic_http_method_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -68,23 +55,29 @@ class HttpTest extends BaseTest
}
/**
+ * @group functional
* @dataProvider getConfig
*/
public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
{
- $client = new Client($config);
+ $client = $this->_getClient($config);
$status = $client->getStatus();
$info = $status->getResponse()->getTransferInfo();
$this->assertStringStartsWith('GET', $info['request_header']);
}
+ /**
+ * @group functional
+ */
public function testCurlNobodyOptionIsResetAfterHeadRequest()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$index = $client->getIndex('curl_test');
- $type = $index->getType('item');
+ $index->create(array(), true);
+ $this->_waitForAllocation($index);
+ $type = $index->getType('item');
// Force HEAD request to set CURLOPT_NOBODY = true
$index->exists();
@@ -103,10 +96,16 @@ class HttpTest extends BaseTest
$this->assertEquals($id, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testUnicodeData()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$index = $client->getIndex('curl_test');
+ $index->create(array(), true);
+ $this->_waitForAllocation($index);
+
$type = $index->getType('item');
// Force HEAD request to set CURLOPT_NOBODY = true
@@ -132,11 +131,14 @@ class HttpTest extends BaseTest
$this->assertEquals($id, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testWithEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12345/');
+ putenv('http_proxy='.$this->_getProxyUrl().'/');
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
@@ -147,48 +149,56 @@ class HttpTest extends BaseTest
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithEnabledEnvironmentalProxy()
{
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client();
-
+ putenv('http_proxy='.$this->_getProxyUrl403().'/');
+ $client = $this->_getClient();
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(403, $transferInfo['http_code']);
-
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
-
putenv('http_proxy=');
}
+ /**
+ * @group functional
+ */
public function testWithProxy()
{
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
+ $client = $this->_getClient();
+ $client->getConnection()->setProxy($this->_getProxyUrl());
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testWithoutProxy()
{
- $client = new \Elastica\Client();
+ $client = $this->_getClient();
$client->getConnection()->setProxy('');
$transferInfo = $client->request('/_nodes')->getTransferInfo();
$this->assertEquals(200, $transferInfo['http_code']);
}
+ /**
+ * @group functional
+ */
public function testBodyReuse()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('elastica_body_reuse_test');
-
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$type = $index->getType('test');
$type->addDocument(new Document(1, array('test' => 'test')));
@@ -211,12 +221,16 @@ class HttpTest extends BaseTest
$this->assertEquals(1, $resultSet->getTotalHits());
}
+ /**
+ * @group functional
+ */
public function testPostWith0Body()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = $client->getIndex('elastica_0_body');
$index->create(array(), true);
+ $this->_waitForAllocation($index);
$index->refresh();
$tokens = $index->analyze('0');
@@ -224,4 +238,9 @@ class HttpTest extends BaseTest
$this->assertNotEmpty($tokens);
}
+ protected function tearDown()
+ {
+ parent::tearDown();
+ putenv('http_proxy=');
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
index 17d46d88..30897073 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
@@ -1,51 +1,176 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Document;
+use Elastica\Query;
+use Elastica\Query\QueryString;
+use Elastica\Request;
use Elastica\Test\Base as BaseTest;
class MemcacheTest extends BaseTest
{
- public function setUp()
+ public static function setUpBeforeClass()
{
if (!extension_loaded('Memcache')) {
- $this->markTestSkipped('pecl/memcache must be installed to run this test case');
+ self::markTestSkipped('pecl/memcache must be installed to run this test case');
}
}
- public function testExample()
+ protected function _getMemcacheClient()
{
- // Creates a new index 'xodoa' and a type 'user' inside this index
- $host = 'localhost';
- $port = 11211;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Memcache'));
+ return $this->_getClient(array(
+ 'host' => $this->_getHost(),
+ 'port' => 11211,
+ 'transport' => 'Memcache',
+ ));
+ }
- $index = $client->getIndex('elastica_test1');
- $index->create(array(), true);
+ /**
+ * @group functional
+ */
+ public function testConstruct()
+ {
+ $client = $this->_getMemcacheClient();
+ $this->assertEquals($this->_getHost(), $client->getConnection()->getHost());
+ $this->assertEquals(11211, $client->getConnection()->getPort());
+ }
- $type = $index->getType('user');
+ /**
+ * @group functional
+ */
+ public function testCreateDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
- // Adds 1 document to the index
- $doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
- );
- $type->addDocument($doc1);
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
- );
- $docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
+ // Check it was saved
+ $document = $type->getDocument(1);
+ $this->assertEquals('John Doe', $document->get('username'));
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\NotFoundException
+ */
+ public function testDeleteDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
+
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
+
+ // Delete document
+ $type->deleteById(1);
+
+ // Check if document is not exists
+ $document = $type->getDocument(1);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('foo');
+
+ // Create document
+ $document = new Document(1, array('username' => 'John Doe'));
+ $type->addDocument($document);
+ $index->refresh();
+
+ // Check it was saved
+ $savedDocument = $type->getDocument(1);
+ $this->assertEquals('John Doe', $savedDocument->get('username'));
+
+ // Update document
+ $newDocument = new Document(1, array('username' => 'Doe John'));
+ $type->updateDocument($newDocument);
+ $index->refresh();
+
+ // Check it was updated
+ $newSavedDocument = $type->getDocument(1);
+ $this->assertEquals('Doe John', $newSavedDocument->get('username'));
+ }
+
+ /**
+ * @group functional
+ */
+ public function testSearchDocument()
+ {
+ $index = $this->_createIndex();
+ $this->_waitForAllocation($index);
+ $type = $index->getType('fruits');
+
+ // Create documents
+ $docs = array(
+ new Document(1, array('name' => 'banana')),
+ new Document(2, array('name' => 'apple')),
+ new Document(3, array('name' => 'orange')),
);
$type->addDocuments($docs);
-
- // Refresh index
$index->refresh();
- $this->markTestIncomplete('Memcache implementation is not finished yet');
- $resultSet = $type->search('rolf');
+
+ // Search documents
+ $queryString = new QueryString('orange');
+ $query = new Query($queryString);
+ $resultSet = $type->search($query);
+
+ // Check if correct document was found
+ $this->assertEquals(1, $resultSet->getTotalHits());
+ $this->assertEquals(3, $resultSet[0]->getId());
+ $data = $resultSet[0]->getData();
+ $this->assertEquals('orange', $data['name']);
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\InvalidException
+ * @expectedExceptionMessage is not supported in memcache transport
+ */
+ public function testHeadRequest()
+ {
+ $client = $this->_getMemcacheClient();
+ $client->request('foo', Request::HEAD);
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\InvalidException
+ * @expectedExceptionMessage is not supported in memcache transport
+ */
+ public function testInvalidRequest()
+ {
+ $client = $this->_getMemcacheClient();
+ $client->request('foo', 'its_fail');
+ }
+
+ /**
+ * @group functional
+ * @expectedException Elastica\Exception\Connection\MemcacheException
+ * @expectedExceptionMessage is too long
+ */
+ public function testRequestWithLongPath()
+ {
+ $client = $this->_getMemcacheClient();
+ $index = $client->getIndex('memcache-test');
+ $index->create();
+
+ $this->_waitForAllocation($index);
+
+ $queryString = new QueryString(str_repeat('z', 300));
+ $query = new Query($queryString);
+ $index->search($query);
}
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
deleted file mode 100644
index c07f5da1..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Connection;
-use Elastica\Query;
-use Elastica\Test\Base as BaseTest;
-
-/**
- * Elastica Null Transport Test
- *
- * @package Elastica
- * @author James Boehmer <james.boehmer@jamesboehmer.com>
- */
-class NullTest extends BaseTest
-{
-
- public function testEmptyResult()
- {
- // Creates a client with any destination, and verify it returns a response object when executed
- $client = $this->_getClient();
- $connection = new Connection(array('transport' => 'Null'));
- $client->setConnections(array($connection));
-
- $index = $client->getIndex('elasticaNullTransportTest1');
-
- $resultSet = $index->search(new Query());
- $this->assertNotNull($resultSet);
-
- $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"]);
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php
new file mode 100644
index 00000000..cea3e3ba
--- /dev/null
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php
@@ -0,0 +1,96 @@
+<?php
+namespace Elastica\Test\Transport;
+
+use Elastica\Connection;
+use Elastica\Query;
+use Elastica\Request;
+use Elastica\Test\Base as BaseTest;
+use Elastica\Transport\NullTransport;
+
+/**
+ * Elastica Null Transport Test.
+ *
+ * @author James Boehmer <james.boehmer@jamesboehmer.com>
+ */
+class NullTransportTest extends BaseTest
+{
+ /**
+ * @group functional
+ */
+ public function testEmptyResult()
+ {
+ // Creates a client with any destination, and verify it returns a response object when executed
+ $client = $this->_getClient();
+ $connection = new Connection(array('transport' => 'NullTransport'));
+ $client->setConnections(array($connection));
+
+ $index = $client->getIndex('elasticaNullTransportTest1');
+
+ $resultSet = $index->search(new Query());
+ $this->assertNotNull($resultSet);
+
+ $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']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testExec()
+ {
+ $request = new Request('/test');
+ $params = array('name' => 'ruflin');
+ $transport = new NullTransport();
+ $response = $transport->exec($request, $params);
+
+ $this->assertInstanceOf('\Elastica\Response', $response);
+
+ $data = $response->getData();
+ $this->assertEquals($params, $data['params']);
+ }
+
+ /**
+ * @group functional
+ */
+ public function testOldObject()
+ {
+ if (version_compare(phpversion(), 7, '>=')) {
+ self::markTestSkipped('These objects are not supported in PHP 7');
+ }
+
+ $request = new Request('/test');
+ $params = array('name' => 'ruflin');
+ $transport = new \Elastica\Transport\Null();
+ $response = $transport->exec($request, $params);
+
+ $this->assertInstanceOf('\Elastica\Response', $response);
+
+ $data = $response->getData();
+ $this->assertEquals($params, $data['params']);
+ }
+}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
index f1698ff6..b73ef4f7 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
@@ -1,12 +1,9 @@
<?php
-
namespace Elastica\Test\Transport;
-use Elastica\Client;
use Elastica\Connection;
use Elastica\Document;
use Elastica\Index;
-use Elastica\Query;
use Elastica\Test\Base as BaseTest;
class ThriftTest extends BaseTest
@@ -18,17 +15,21 @@ class ThriftTest extends BaseTest
}
}
+ /**
+ * @group unit
+ */
public function testConstruct()
{
- $host = 'localhost';
+ $host = $this->_getHost();
$port = 9500;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Thrift'));
+ $client = $this->_getClient(array('host' => $host, 'port' => $port, 'transport' => 'Thrift'));
$this->assertEquals($host, $client->getConnection()->getHost());
$this->assertEquals($port, $client->getConnection()->getPort());
}
/**
+ * @group functional
* @dataProvider configProvider
*/
public function testSearchRequest($config)
@@ -36,7 +37,7 @@ class ThriftTest extends BaseTest
$this->_checkPlugin();
// Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client($config);
+ $client = $this->_getClient($config);
$index = $client->getIndex('elastica_test1');
$index->create(array(), true);
@@ -68,17 +69,19 @@ class ThriftTest extends BaseTest
}
/**
+ * @group unit
* @expectedException \Elastica\Exception\ConnectionException
*/
public function testInvalidHostRequest()
{
$this->_checkPlugin();
- $client = new Client(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
+ $client = $this->_getClient(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
$client->getStatus();
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\ResponseException
*/
public function testInvalidElasticRequest()
@@ -86,11 +89,11 @@ class ThriftTest extends BaseTest
$this->_checkPlugin();
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort(9500);
$connection->setTransport('Thrift');
- $client = new Client();
+ $client = $this->_getClient();
$client->addConnection($connection);
$index = new Index($client, 'missing_index');
@@ -102,23 +105,23 @@ class ThriftTest extends BaseTest
return array(
array(
array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
- 'transport' => 'Thrift'
- )
+ 'transport' => 'Thrift',
+ ),
),
array(
array(
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
'transport' => 'Thrift',
'config' => array(
'framedTransport' => false,
'sendTimeout' => 10000,
'recvTimeout' => 20000,
- )
- )
- )
+ ),
+ ),
+ ),
);
}
@@ -126,7 +129,7 @@ class ThriftTest extends BaseTest
{
$nodes = $this->_getClient()->getCluster()->getNodes();
if (!$nodes[0]->getInfo()->hasPlugin('transport-thrift')) {
- $this->markTestSkipped("transport-thrift plugin not installed.");
+ $this->markTestSkipped('transport-thrift plugin not installed.');
}
}
}
diff --git a/vendor/ruflin/elastica/test/benchmark/TransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php
index 42d6ac0c..11a16a34 100644
--- a/vendor/ruflin/elastica/test/benchmark/TransportTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/TransportBenchmarkTest.php
@@ -1,29 +1,18 @@
<?php
+namespace Elastica\Test\Transport;
-use Elastica\Client;
-use Elastica\Request;
use Elastica\Document;
+use Elastica\Index;
use Elastica\Query;
-use Elastica\Type\Mapping;
-use Elastica\Query\MatchAll as MatchAllQuery;
-use Elastica\Filter\Term as TermFilter;
+use Elastica\Test\Base as BaseTest;
-class TransportTest extends \PHPUnit_Framework_TestCase
+class TransportBenchmarkTest extends BaseTest
{
protected $_max = 1000;
protected $_maxData = 20;
- static protected $_results = array();
-
- public static function setUpBeforeClass()
- {
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- } else if (false == DEBUG) {
- self::markTestIncomplete('DEBUG const is set to false, it prevents query time measuring.');
- }
- }
+ protected static $_results = array();
public static function tearDownAfterClass()
{
@@ -32,20 +21,26 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @param array $config
+ *
* @return \Elastica\Type
*/
protected function getType(array $config)
{
- $client = new Client($config);
- $index = $client->getIndex('test');
- return $index->getType('test');
+ $client = $this->_getClient($config);
+ $index = $client->getIndex('benchmark'.uniqid());
+ $index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
+
+ return $index->getType('benchmark');
}
/**
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testAddDocument(array $config, $transport)
{
+ $this->_checkThrift($transport);
+
$type = $this->getType($config);
$index = $type->getIndex();
$index->create(array(), true);
@@ -67,9 +62,12 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @depends testAddDocument
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testRandomRead(array $config, $transport)
{
+ $this->_checkThrift($transport);
+
$type = $this->getType($config);
$type->search('test');
@@ -78,8 +76,8 @@ class TransportTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < $this->_max; $i++) {
$test = rand(1, $this->_max);
$query = new Query();
- $query->setQuery(new MatchAllQuery());
- $query->setFilter(new TermFilter(array('test' => $test)));
+ $query->setQuery(new \Elastica\Query\MatchAll());
+ $query->setPostFilter(new \Elastica\Filter\Term(array('test' => $test)));
$result = $type->search($query);
$times[] = $result->getResponse()->getQueryTime();
}
@@ -90,6 +88,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @depends testAddDocument
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testBulk(array $config, $transport)
{
@@ -99,7 +98,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
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);
}
@@ -112,30 +111,31 @@ class TransportTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider providerTransport
+ * @group benchmark
*/
public function testGetMapping(array $config, $transport)
{
- $client = new Client($config);
- $index = $client->getIndex('test');
+ $client = $this->_getClient($config);
+ $index = $client->getIndex('benchmark');
$index->create(array(), true);
$type = $index->getType('mappingTest');
// Define mapping
- $mapping = new Mapping();
+ $mapping = new \Elastica\Type\Mapping();
$mapping->setParam('_boost', array('name' => '_boost', 'null_value' => 1.0));
$mapping->setProperties(array(
- 'id' => array('type' => 'integer', 'include_in_all' => FALSE),
+ '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);
@@ -143,7 +143,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
$times = array();
for ($i = 0; $i < $this->_max; $i++) {
- $response = $type->request('_mapping', Request::GET);
+ $response = $type->request('_mapping', \Elastica\Request::GET);
$times[] = $response->getQueryTime();
}
self::logResults('get mapping', $transport, $times);
@@ -155,37 +155,38 @@ class TransportTest extends \PHPUnit_Framework_TestCase
array(
array(
'transport' => 'Http',
- 'host' => 'localhost',
- 'port' => 9200,
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
'persistent' => false,
),
- 'Http:NotPersistent'
+ 'Http:NotPersistent',
),
array(
array(
'transport' => 'Http',
- 'host' => 'localhost',
- 'port' => 9200,
+ 'host' => $this->_getHost(),
+ 'port' => $this->_getPort(),
'persistent' => true,
),
- 'Http:Persistent'
+ 'Http:Persistent',
),
array(
array(
'transport' => 'Thrift',
- 'host' => 'localhost',
+ 'host' => $this->_getHost(),
'port' => 9500,
'config' => array(
'framedTransport' => false,
),
),
- 'Thrift:Buffered'
+ 'Thrift:Buffered',
),
);
}
/**
* @param string $test
+ *
* @return array
*/
protected function getData($test)
@@ -197,6 +198,7 @@ class TransportTest extends \PHPUnit_Framework_TestCase
for ($i = 0; $i < $this->_maxData; $i++) {
$data['name'][] = uniqid();
}
+
return $data;
}
@@ -209,9 +211,9 @@ class TransportTest extends \PHPUnit_Framework_TestCase
{
self::$_results[$name][$transport] = array(
'count' => count($times),
- 'max' => max($times) * 1000,
- 'min' => min($times) * 1000,
- 'mean' => (array_sum($times) / count($times)) * 1000,
+ 'max' => max($times) * 1000,
+ 'min' => min($times) * 1000,
+ 'mean' => (array_sum($times) / count($times)) * 1000,
);
}
@@ -249,4 +251,11 @@ class TransportTest extends \PHPUnit_Framework_TestCase
echo "\n";
}
}
+
+ protected function _checkThrift($transport)
+ {
+ if (strpos($transport, 'Thrift') !== false && !class_exists('Elasticsearch\\RestClient')) {
+ self::markTestSkipped('munkie/elasticsearch-thrift-php package should be installed to run thrift transport tests');
+ }
+ }
}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
index 796bfb8d..925c23bb 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Type/MappingTest.php
@@ -1,5 +1,4 @@
<?php
-
namespace Elastica\Test\Type;
use Elastica\Document;
@@ -11,6 +10,9 @@ use Elastica\Type\Mapping;
class MappingTest extends BaseTest
{
+ /**
+ * @group functional
+ */
public function testMappingStoreFields()
{
$client = $this->_getClient();
@@ -34,7 +36,7 @@ class MappingTest extends BaseTest
$doc = new Document(1,
array(
'firstname' => $firstname,
- 'lastname' => 'Ruflin'
+ 'lastname' => 'Ruflin',
)
);
@@ -61,6 +63,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableAllField()
{
$index = $this->_createIndex();
@@ -79,6 +84,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testEnableTtl()
{
$client = $this->_getClient();
@@ -97,6 +105,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testNestedMapping()
{
$client = $this->_getClient();
@@ -105,7 +116,7 @@ class MappingTest extends BaseTest
$index->create(array(), true);
$type = $index->getType('test');
- $this->markTestIncomplete('nested mapping is not set right yet');
+ //$this->markTestIncomplete('nested mapping is not set right yet');
$mapping = new Mapping($type,
array(
'test' => array(
@@ -115,20 +126,21 @@ class MappingTest extends BaseTest
'firstname' => array('type' => 'string', 'store' => 'yes'),
'lastname' => array('type' => 'string', 'store' => 'yes'),
'age' => array('type' => 'integer', 'store' => 'yes'),
- )
+ ),
),
),
),
)
);
- $type->setMapping($mapping);
+ $response = $type->setMapping($mapping);
+ $this->assertFalse($response->hasError());
$doc = new Document(1, array(
'user' => array(
'firstname' => 'Nicolas',
'lastname' => 'Ruflin',
- 'age' => 9
+ 'age' => 9,
),
));
@@ -136,17 +148,21 @@ class MappingTest extends BaseTest
$index->refresh();
$resultSet = $type->search('ruflin');
+ $this->assertEquals($resultSet->count(), 1);
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testParentMapping()
{
$index = $this->_createIndex();
$parenttype = new Type($index, 'parenttype');
$parentmapping = new Mapping($parenttype,
array(
- 'name' => array('type' => 'string', 'store' => 'yes')
+ 'name' => array('type' => 'string', 'store' => 'yes'),
)
);
@@ -168,6 +184,9 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testMappingExample()
{
$index = $this->_createIndex();
@@ -177,10 +196,10 @@ class MappingTest extends BaseTest
array(
'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)
- )
- )
+ '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),
+ ),
+ ),
)
);
@@ -189,14 +208,14 @@ class MappingTest extends BaseTest
$doc = new Document(1, array(
'note' => array(
array(
- 'titulo' => 'nota1',
- 'contenido' => 'contenido1'
+ 'titulo' => 'nota1',
+ 'contenido' => 'contenido1',
),
array(
- 'titulo' => 'nota2',
- 'contenido' => 'contenido2'
- )
- )
+ 'titulo' => 'nota2',
+ 'contenido' => 'contenido2',
+ ),
+ ),
)
);
@@ -206,36 +225,38 @@ class MappingTest extends BaseTest
}
/**
+ * @group functional
+ *
* 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/
+ *
+ * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-root-object-type.html
*/
public function testDynamicTemplate()
{
$index = $this->_createIndex();
- $type = $index->getType('person');
-
- // set a dynamic template "template_1" which creates a multi field for multi* matches.
+ $type = $index->getType('person');
+
+ // 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(
- 'match' => 'multi*',
+ 'match' => 'multi*',
'mapping' => array(
- 'type' => 'multi_field',
+ '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));
@@ -260,13 +281,16 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testSetMeta()
{
$index = $this->_createIndex();
$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);
@@ -277,18 +301,21 @@ class MappingTest extends BaseTest
$index->delete();
}
+ /**
+ * @group functional
+ */
public function testGetters()
{
$index = $this->_createIndex();
$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"
+ 'enabled' => true,
+ 'store' => 'yes',
);
$mapping->setParam('_all', $all);
$get_all = $mapping->getParam('_all');
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
index 40e56c3b..dcb74ac5 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/TypeTest.php
@@ -1,24 +1,25 @@
<?php
-
namespace Elastica\Test;
-use Elastica\Client;
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
{
+ /**
+ * @group functional
+ */
public function testSearch()
{
$index = $this->_createIndex();
@@ -55,6 +56,9 @@ class TypeTest extends BaseTest
$this->assertEquals('rolf', $data['username']);
}
+ /**
+ * @group functional
+ */
public function testCreateSearch()
{
$client = $this->_getClient();
@@ -72,11 +76,11 @@ class TypeTest extends BaseTest
$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());
@@ -91,6 +95,9 @@ class TypeTest extends BaseTest
$this->assertFalse($search->hasType('test_type2'));
}
+ /**
+ * @group functional
+ */
public function testCreateSearchWithArray()
{
$client = $this->_getClient();
@@ -100,9 +107,9 @@ class TypeTest extends BaseTest
$query = array(
'query' => array(
'query_string' => array(
- 'query' => 'test'
- )
- )
+ 'query' => 'test',
+ ),
+ ),
);
$options = array(
@@ -115,11 +122,11 @@ class TypeTest extends BaseTest
$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());
@@ -134,6 +141,9 @@ class TypeTest extends BaseTest
$this->assertFalse($search->hasType('test_type2'));
}
+ /**
+ * @group functional
+ */
public function testNoSource()
{
$index = $this->_createIndex();
@@ -183,6 +193,9 @@ class TypeTest extends BaseTest
$this->assertEmpty($result->getData());
}
+ /**
+ * @group functional
+ */
public function testDeleteById()
{
$index = $this->_createIndex();
@@ -281,6 +294,9 @@ class TypeTest extends BaseTest
$this->assertEquals(1, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteDocument()
{
$index = $this->_createIndex();
@@ -314,6 +330,7 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\NotFoundException
*/
public function testGetDocumentNotExist()
@@ -329,17 +346,21 @@ class TypeTest extends BaseTest
}
/**
- * @expectedException \Elastica\Exception\NotFoundException
+ * @group functional
+ * @expectedException \Elastica\Exception\ResponseException
*/
public function testGetDocumentNotExistingIndex()
{
- $client = new Client();
+ $client = $this->_getClient();
$index = new Index($client, 'index');
$type = new Type($index, 'type');
$type->getDocument(1);
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQueryString()
{
$index = $this->_createIndex();
@@ -368,6 +389,9 @@ class TypeTest extends BaseTest
$this->assertEquals(0, $response->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQuery()
{
$index = $this->_createIndex();
@@ -396,9 +420,12 @@ class TypeTest extends BaseTest
$this->assertEquals(0, $response->count());
}
+ /**
+ * @group functional
+ */
public function testDeleteByQueryWithQueryAndOptions()
{
- $index = $this->_createIndex('test', true, 2);
+ $index = $this->_createIndex(null, true, 2);
$type = new Type($index, 'test');
$type->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
$type->addDocument(new Document(2, array('name' => 'ruflin')));
@@ -411,7 +438,7 @@ class TypeTest extends BaseTest
$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 +450,7 @@ class TypeTest extends BaseTest
$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();
@@ -438,7 +465,9 @@ class TypeTest extends BaseTest
/**
* Test to see if Elastica_Type::getDocument() is properly using
- * the fields array when available instead of _source
+ * the fields array when available instead of _source.
+ *
+ * @group functional
*/
public function testGetDocumentWithFieldsSelection()
{
@@ -456,7 +485,9 @@ class TypeTest extends BaseTest
}
/**
- * Test to see if search Default Limit works
+ * Test to see if search Default Limit works.
+ *
+ * @group functional
*/
public function testLimitDefaultType()
{
@@ -492,34 +523,47 @@ class TypeTest extends BaseTest
/**
* Test Delete of index type. After delete will check for type mapping.
+ *
+ * @group functional
*/
public function testDeleteType()
{
$index = $this->_createIndex();
$type = new Type($index, 'test');
- $type->addDocument(new Document(1, array('name' => 'ruflin nicolas')));
- $type->addDocument(new Document(2, array('name' => 'ruflin')));
+ $type->addDocuments(array(
+ new Document(1, array('name' => 'ruflin nicolas')),
+ new Document(2, array('name' => 'ruflin')),
+ ));
$index->refresh();
+ // sleep a moment to be sure that all nodes in cluster has new type
+ sleep(5);
+
$type->delete();
+ $index->optimize();
+
$this->assertFalse($type->exists());
}
+ /**
+ * @group functional
+ */
public function testMoreLikeThisApi()
{
- $client = new Client(array('persistent' => false));
+ $client = $this->_getClient(array('persistent' => false));
$index = $client->getIndex('elastica_test');
$index->create(array('index' => array('number_of_shards' => 1, 'number_of_replicas' => 0)), true);
$type = new Type($index, 'mlt_test');
- $type->addDocument(new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')));
- $type->addDocument(new Document(2, array('visible' => true, 'name' => 'bruce wayne')));
- $type->addDocument(new Document(3, array('visible' => false, 'name' => 'bruce wayne')));
- $type->addDocument(new Document(4, array('visible' => true, 'name' => 'batman')));
- $type->addDocument(new Document(5, array('visible' => false, 'name' => 'batman')));
- $type->addDocument(new Document(6, array('visible' => true, 'name' => 'superman')));
- $type->addDocument(new Document(7, array('visible' => true, 'name' => 'spiderman')));
-
+ $type->addDocuments(array(
+ new Document(1, array('visible' => true, 'name' => 'bruce wayne batman')),
+ new Document(2, array('visible' => true, 'name' => 'bruce wayne')),
+ new Document(3, array('visible' => false, 'name' => 'bruce wayne')),
+ new Document(4, array('visible' => true, 'name' => 'batman')),
+ new Document(5, array('visible' => false, 'name' => 'batman')),
+ new Document(6, array('visible' => true, 'name' => 'superman')),
+ new Document(7, array('visible' => true, 'name' => 'spiderman')),
+ ));
$index->refresh();
$document = $type->getDocument(1);
@@ -529,15 +573,18 @@ class TypeTest extends BaseTest
$this->assertEquals(4, $resultSet->count());
// Return just the visible similar
- $query = new Query();
- $filterTerm = new Term();
+ $query = new Query();
+ $filterTerm = new Term();
$filterTerm->setTerm('visible', true);
- $query->setFilter($filterTerm);
+ $query->setPostFilter($filterTerm);
$resultSet = $type->moreLikeThis($document, array('min_term_freq' => '1', 'min_doc_freq' => '1'), $query);
$this->assertEquals(2, $resultSet->count());
}
+ /**
+ * @group functional
+ */
public function testUpdateDocument()
{
$client = $this->_getClient();
@@ -549,7 +596,37 @@ class TypeTest extends BaseTest
$document = new Document();
$script = new Script(
- "ctx._source.name = name; ctx._source.counter += count",
+ 'ctx._source.name = name; ctx._source.counter += count',
+ array(
+ 'name' => $newName,
+ 'count' => 2,
+ ),
+ null,
+ $id
+ );
+ $script->setUpsert($document);
+
+ $type->updateDocument($script, array('refresh' => true));
+ $updatedDoc = $type->getDocument($id)->getData();
+ $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated');
+ $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocumentWithIdForwardSlashes()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_test');
+ $type = $index->getType('update_type');
+ $id = '/id/with/forward/slashes';
+ $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1)));
+ $newName = 'batman';
+
+ $document = new Document();
+ $script = new Script(
+ 'ctx._source.name = name; ctx._source.counter += count',
array(
'name' => $newName,
'count' => 2,
@@ -561,10 +638,47 @@ class TypeTest extends BaseTest
$type->updateDocument($script, array('refresh' => true));
$updatedDoc = $type->getDocument($id)->getData();
- $this->assertEquals($newName, $updatedDoc['name'], "Name was not updated");
- $this->assertEquals(3, $updatedDoc['counter'], "Counter was not incremented");
+ $this->assertEquals($newName, $updatedDoc['name'], 'Name was not updated');
+ $this->assertEquals(3, $updatedDoc['counter'], 'Counter was not incremented');
+ }
+
+ /**
+ * @group functional
+ */
+ public function testUpdateDocumentWithParameter()
+ {
+ $client = $this->_getClient();
+ $index = $client->getIndex('elastica_test');
+ $type = $index->getType('update_type');
+ $id = 1;
+ $type->addDocument(new Document($id, array('name' => 'bruce wayne batman', 'counter' => 1)));
+ $newName = 'batman';
+
+ $document = new Document();
+ $script = new Script(
+ 'ctx._source.name = name; ctx._source.counter += count',
+ array(
+ 'name' => $newName,
+ 'count' => 2,
+ ),
+ null,
+ $id
+ );
+ $script->setUpsert($document);
+
+ try {
+ $type->updateDocument($script, array('version' => 999)); // Wrong version number to make the update fail
+ } catch (ResponseException $e) {
+ $this->assertContains('VersionConflictEngineException', $e->getMessage());
+ }
+ $updatedDoc = $type->getDocument($id)->getData();
+ $this->assertNotEquals($newName, $updatedDoc['name'], 'Name was updated');
+ $this->assertNotEquals(3, $updatedDoc['counter'], 'Counter was incremented');
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentWithFieldsSource()
{
$client = $this->_getClient();
@@ -612,11 +726,13 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\InvalidException
*/
public function testUpdateDocumentWithoutId()
{
$index = $this->_createIndex();
+ $this->_waitForAllocation($index);
$type = $index->getType('elastica_type');
$document = new Document();
@@ -624,6 +740,9 @@ class TypeTest extends BaseTest
$type->updateDocument($document);
}
+ /**
+ * @group functional
+ */
public function testUpdateDocumentWithoutSource()
{
$index = $this->_createIndex();
@@ -633,10 +752,10 @@ class TypeTest extends BaseTest
$mapping->setProperties(array(
'name' => array(
'type' => 'string',
- 'store' => 'yes'),
+ 'store' => 'yes', ),
'counter' => array(
'type' => 'integer',
- 'store' => 'no'
+ 'store' => 'no',
),
));
$mapping->disableSource();
@@ -673,6 +792,9 @@ class TypeTest extends BaseTest
}
}
+ /**
+ * @group functional
+ */
public function testAddDocumentHashId()
{
$index = $this->_createIndex();
@@ -694,6 +816,9 @@ class TypeTest extends BaseTest
$this->assertEquals($hashId, $doc->getId());
}
+ /**
+ * @group functional
+ */
public function testAddDocumentAutoGeneratedId()
{
$index = $this->_createIndex();
@@ -719,23 +844,28 @@ class TypeTest extends BaseTest
}
/**
+ * @group functional
* @expectedException \Elastica\Exception\RuntimeException
*/
public function testAddDocumentWithoutSerializer()
{
$index = $this->_createIndex();
+ $this->_waitForAllocation($index);
$type = new Type($index, 'user');
$type->addObject(new \stdClass());
}
+ /**
+ * @group functional
+ */
public function testAddObject()
{
$index = $this->_createIndex();
$type = new Type($index, 'user');
- $type->setSerializer(array(new SerializerMock(), 'serialize'));
+ $type->setSerializer('get_object_vars');
$userObject = new \stdClass();
$userObject->username = 'hans';
@@ -754,6 +884,20 @@ class TypeTest extends BaseTest
$this->assertEquals('hans', $data['username']);
}
+ /**
+ * @group unit
+ */
+ public function testSetSerializer()
+ {
+ $index = $this->_getClient()->getIndex('foo');
+ $type = $index->getType('user');
+ $ret = $type->setSerializer('get_object_vars');
+ $this->assertInstanceOf('Elastica\Type', $ret);
+ }
+
+ /**
+ * @group functional
+ */
public function testExists()
{
$index = $this->_createIndex();
@@ -765,6 +909,9 @@ class TypeTest extends BaseTest
$type->addDocument(new Document(1, array('name' => 'test name')));
$index->optimize();
+ // sleep a moment to be sure that all nodes in cluster has new type
+ sleep(5);
+
//Test if type exists
$this->assertTrue($type->exists());
@@ -772,15 +919,18 @@ class TypeTest extends BaseTest
$this->assertFalse($index->exists());
}
- public function testGetMapping() {
- $indexName = 'test';
+ /**
+ * @group functional
+ */
+ public function testGetMapping()
+ {
$typeName = 'test-type';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$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);
@@ -792,16 +942,19 @@ class TypeTest extends BaseTest
);
}
- public function testGetMappingAlias() {
- $indexName = 'test';
+ /**
+ * @group functional
+ */
+ public function testGetMappingAlias()
+ {
$aliasName = 'test-alias';
$typeName = 'test-alias-type';
- $index = $this->_createIndex($indexName);
+ $index = $this->_createIndex();
$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);
@@ -813,11 +966,3 @@ class TypeTest extends BaseTest
);
}
}
-
-class SerializerMock
-{
- public function serialize($object)
- {
- return get_object_vars($object);
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
index 09d4b5b1..a5b0f42e 100644
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
+++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/UtilTest.php
@@ -1,15 +1,15 @@
<?php
-
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
{
/**
+ * @group unit
* @dataProvider getEscapeTermPairs
*/
public function testEscapeTerm($unescaped, $escaped)
@@ -25,18 +25,45 @@ class UtilTest extends BaseTest
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.'),
);
}
+ /**
+ * @group unit
+ * @dataProvider getReplaceBooleanWordsPairs
+ */
+ public function testReplaceBooleanWords($before, $after)
+ {
+ $this->assertEquals($after, Util::replaceBooleanWords($before));
+ }
+
+ public function getReplaceBooleanWordsPairs()
+ {
+ return array(
+ array('to be OR not to be', 'to be || not to be'),
+ array('ORIGINAL GIFTS', 'ORIGINAL GIFTS'),
+ array('Black AND White', 'Black && White'),
+ array('TIMBERLAND Men`s', 'TIMBERLAND Men`s'),
+ array('hello NOT kitty', 'hello !kitty'),
+ array('SEND NOTIFICATION', 'SEND NOTIFICATION'),
+ );
+ }
+
+ /**
+ * @group unit
+ */
public function testEscapeTermSpecialCharacters()
{
- $before = '\\+-&&||!(){}[]^"~*?:/';
- $after = '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:\\\\/';
+ $before = '\\+-&&||!(){}[]^"~*?:/<>';
+ $after = '\\\\\\+\\-\\&&\\||\\!\\(\\)\\{\\}\\[\\]\\^\\"\\~\\*\\?\\:\\/\<\>';
$this->assertEquals(Util::escapeTerm($before), $after);
}
+ /**
+ * @group unit
+ */
public function testToCamelCase()
{
$string = 'hello_world';
@@ -46,6 +73,9 @@ class UtilTest extends BaseTest
$this->assertEquals('HowAreYouToday', Util::toCamelCase($string));
}
+ /**
+ * @group unit
+ */
public function testToSnakeCase()
{
$string = 'HelloWorld';
@@ -55,6 +85,9 @@ class UtilTest extends BaseTest
$this->assertEquals('how_are_you_today', Util::toSnakeCase($string));
}
+ /**
+ * @group unit
+ */
public function testConvertRequestToCurlCommand()
{
$path = 'test';
@@ -63,15 +96,44 @@ class UtilTest extends BaseTest
$data = array('key' => 'value');
$connection = new Connection();
- $connection->setHost('localhost');
+ $connection->setHost($this->_getHost());
$connection->setPort('9200');
$request = new Request($path, $method, $data, $query, $connection);
$curlCommand = Util::convertRequestToCurlCommand($request);
- $expected = 'curl -XPOST \'http://localhost:9200/test?no=params\' -d \'{"key":"value"}\'';
+ $expected = 'curl -XPOST \'http://'.$this->_getHost().':9200/test?no=params\' -d \'{"key":"value"}\'';
$this->assertEquals($expected, $curlCommand);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertDateTimeObjectWithTimezone()
+ {
+ $dateTimeObject = new \DateTime();
+ $timestamp = $dateTimeObject->getTimestamp();
+
+ $convertedString = Util::convertDateTimeObject($dateTimeObject);
+
+ $date = date('Y-m-d\TH:i:sP', $timestamp);
+
+ $this->assertEquals($convertedString, $date);
+ }
+
+ /**
+ * @group unit
+ */
+ public function testConvertDateTimeObjectWithoutTimezone()
+ {
+ $dateTimeObject = new \DateTime();
+ $timestamp = $dateTimeObject->getTimestamp();
+
+ $convertedString = Util::convertDateTimeObject($dateTimeObject, false);
+
+ $date = date('Y-m-d\TH:i:s\Z', $timestamp);
+ $this->assertEquals($convertedString, $date);
}
}
diff --git a/vendor/ruflin/elastica/test/nginx/nginx.conf b/vendor/ruflin/elastica/test/nginx/nginx.conf
deleted file mode 100644
index 97f45fbc..00000000
--- a/vendor/ruflin/elastica/test/nginx/nginx.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-events {
- worker_connections 1024;
-}
-
-http {
- access_log logs/access.log;
- error_log logs/error.log;
-
- server {
- listen 127.0.0.1:12345;
-
- location / {
- proxy_pass http://127.0.0.1:9201;
- }
- }
-
- server {
- listen 127.0.0.1:12346;
-
- location / {
- return 403;
- }
- }
-}
diff --git a/vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml b/vendor/ruflin/elastica/test/phpunit.xhprof.xml
index 2293155a..59878cc2 100644
--- a/vendor/ruflin/elastica/test/benchmark/phpunit.xhprof.xml
+++ b/vendor/ruflin/elastica/test/phpunit.xhprof.xml
@@ -4,7 +4,7 @@
colors="true">
<testsuites>
<testsuite name="Transport">
- <file>TransportTest.php</file>
+ <file>lib/Elastica/Test/Transport/TransportBenchmarkTest.php</file>
</testsuite>
</testsuites>
<listeners>
@@ -36,4 +36,4 @@
</arguments>
</listener>
</listeners>
-</phpunit> \ No newline at end of file
+</phpunit>
diff --git a/vendor/ruflin/elastica/test/phpunit.xml.dist b/vendor/ruflin/elastica/test/phpunit.xml.dist
index a863692c..51993e0a 100644
--- a/vendor/ruflin/elastica/test/phpunit.xml.dist
+++ b/vendor/ruflin/elastica/test/phpunit.xml.dist
@@ -1,32 +1,27 @@
-<phpunit
- bootstrap="./bootstrap.php"
+<?xml version="1.0"?>
+<phpunit
backupGlobals="false"
backupStaticAttributes="false"
+ bootstrap="./bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
+ processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
syntaxCheck="false"
- processIsolation="false">
-
- <testsuites>
- <testsuite name="Elastica">
- <directory>./lib/Elastica/</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist>
- <directory suffix=".php">../lib/</directory>
- </whitelist>
- </filter>
- <logging>
- <log type="coverage-html" target="../build/coverage" title="Elastica"
- charset="UTF-8" yui="true" highlight="true"
- lowUpperBound="35" highLowerBound="70"/>
- <log type="coverage-clover" target="../build/logs/clover.xml"/>
- <log type="junit" target="../build/logs/junit.xml" logIncompleteSkipped="false"/>
- </logging>
+ verbose="true"
+ >
+ <filter>
+ <whitelist>
+ <directory suffix=".php">../lib/</directory>
+ </whitelist>
+ </filter>
+ <testsuites>
+ <testsuite name="default">
+ <directory>./lib/Elastica/</directory>
+ </testsuite>
+ </testsuites>
</phpunit>