/** * Tests getArray method. * * @param array $filterData * @param array $expected * * @dataProvider getArrayDataProvider */ public function testGeoHashGridAggregationGetArray($filterData, $expected) { $aggregation = new GeoHashGridAggregation('foo'); $aggregation->setPrecision($filterData['precision']); $aggregation->setSize($filterData['size']); $aggregation->setShardSize($filterData['shard_size']); $aggregation->setField($filterData['field']); $result = $aggregation->getArray(); $this->assertEquals($result, $expected); }
/** * Test geohash grid with multiple parameters. */ public function testGeoHashGridAggregationWithAditionalParameters() { $repo = $this->getManager()->getRepository('AcmeTestBundle:Product'); $agg = new GeoHashGridAggregation('test_agg'); $agg->setField('location'); $agg->setPrecision(2); $agg->setSize(2); $agg->setShardSize(1); $search = $repo->createSearch()->addAggregation($agg); $results = $repo->execute($search, Repository::RESULTS_RAW)['aggregations']['agg_test_agg']; $expectedResults = ['buckets' => [['key' => 'dr', 'doc_count' => 2], ['key' => 'u6', 'doc_count' => 1]]]; $this->assertEquals($expectedResults, $results); }