summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Filter/GeoBoundingBoxTest.php55
1 files changed, 55 insertions, 0 deletions
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());
+ }
+}