From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../Elastica/Test/Filter/GeoShapeProvidedTest.php | 103 +++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php new file mode 100644 index 00000000..d631e44e --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php @@ -0,0 +1,103 @@ +_createIndex(); + $type = $index->getType('test'); + + // create mapping + $mapping = new Mapping($type, array( + 'location' => array( + 'type' => 'geo_shape', + ), + )); + $type->setMapping($mapping); + + // add docs + $type->addDocument(new Document(1, array( + 'location' => array( + 'type' => 'envelope', + 'coordinates' => array( + array(-50.0, 50.0), + array(50.0, -50.0), + ), + ), + ))); + + $index->optimize(); + $index->refresh(); + + $envelope = array( + array(25.0, 75.0), + array(75.0, 25.0), + ); + $gsp = new GeoShapeProvided('location', $envelope); + + $expected = array( + 'geo_shape' => array( + 'location' => array( + 'shape' => array( + 'type' => GeoShapeProvided::TYPE_ENVELOPE, + 'coordinates' => $envelope, + ), + 'relation' => AbstractGeoShape::RELATION_INTERSECT, + ), + ), + ); + + $this->assertEquals($expected, $gsp->toArray()); + + $query = new Filtered(new MatchAll(), $gsp); + $results = $type->search($query); + + $this->assertEquals(1, $results->count()); + } + + /** + * @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)); + $gsp = new GeoShapeProvided('location', $polygon, GeoShapeProvided::TYPE_POLYGON); + + $expected = array( + 'geo_shape' => array( + 'location' => array( + 'shape' => array( + 'type' => GeoShapeProvided::TYPE_POLYGON, + 'coordinates' => $polygon, + ), + 'relation' => $gsp->getRelation(), + ), + ), + ); + + $this->assertEquals($expected, $gsp->toArray()); + } + + /** + * @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)); + } +} -- cgit v1.2.3-54-g00ecf