summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter')
-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
33 files changed, 1320 insertions, 637 deletions
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());