diff -r 706f10bcdc3c -r f5690d918358 server/src/tests/Controllers/GeoStatsControllerTest.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/server/src/tests/Controllers/GeoStatsControllerTest.php Sun Oct 02 19:14:07 2016 +0200 @@ -0,0 +1,65 @@ + env('ELASTICSEARCH_INDEX'), + 'body' => [ + "size" => 0, + "aggs" => [ + "geos" => [ + "terms" => [ + "size" => 0, + "field" => "geonames_hierarchy" + ] + ] + ] + ] + ]; + + Es::shouldReceive('search') + ->once() + ->with($query) + ->andReturn(json_decode("{ + \"took\" : 17, + \"timed_out\" : false, + \"_shards\" : { + \"total\" : 1, + \"successful\" : 1, + \"failed\" : 0 + }, + \"hits\" : { + \"total\" : 3011, + \"max_score\" : 0.0, + \"hits\" : [ ] + }, + \"aggregations\" : { + \"geos\" : { + \"doc_count_error_upper_bound\" : 0, + \"sum_other_doc_count\" : 0, + \"buckets\" : [ { + \"key\" : 6255148, + \"doc_count\" : 2684 + }, { + \"key\" : 3017382, + \"doc_count\" : 2674 + }, { + \"key\" : 3027939, + \"doc_count\" : 851 + } ] + } + } +}", true)); + + $this->get('/api/v1/stats/geostats/')->assertTrue($this->response->isOk(), $this->response->content()); + $this->seeJsonEquals(["geostats" => [ + '6255148' => 2684, + '3017382' => 2674, + '3027939' => 851 + ]]); + } +}