From 15e69f7b20b6596b9148030acce5b59993b95a45 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Dec 2015 06:00:00 +0100 Subject: Update to MediaWiki 1.25.4 --- .../Elastica/Test/Filter/GeoShapeProvidedTest.php | 88 ++++++++++++++++++++++ 1 file changed, 88 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..146150a3 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoShapeProvidedTest.php @@ -0,0 +1,88 @@ +_createIndex('geo_shape_filter_test'); + $type = $index->getType('test'); + + // create mapping + $mapping = new \Elastica\Type\Mapping($type, array( + 'location' => array( + 'type' => 'geo_shape' + ) + )); + $type->setMapping($mapping); + + // add docs + $type->addDocument(new \Elastica\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()); + + $index->delete(); + } + + 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()); + } +} \ No newline at end of file -- cgit v1.2.2