diff options
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapePreIndexedTest.php | 64 |
1 files changed, 38 insertions, 26 deletions
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)); + } +} |