equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 use Es; |
|
4 |
|
5 class GeoStatsControllerTest extends TestCase |
|
6 { |
|
7 public function testGetIndex() |
|
8 { |
|
9 $query = [ |
|
10 'index' => env('ELASTICSEARCH_INDEX'), |
|
11 'body' => [ |
|
12 "size" => 0, |
|
13 "aggs" => [ |
|
14 "geos" => [ |
|
15 "terms" => [ |
|
16 "size" => 0, |
|
17 "field" => "geonames_hierarchy" |
|
18 ] |
|
19 ] |
|
20 ] |
|
21 ] |
|
22 ]; |
|
23 |
|
24 Es::shouldReceive('search') |
|
25 ->once() |
|
26 ->with($query) |
|
27 ->andReturn(json_decode("{ |
|
28 \"took\" : 17, |
|
29 \"timed_out\" : false, |
|
30 \"_shards\" : { |
|
31 \"total\" : 1, |
|
32 \"successful\" : 1, |
|
33 \"failed\" : 0 |
|
34 }, |
|
35 \"hits\" : { |
|
36 \"total\" : 3011, |
|
37 \"max_score\" : 0.0, |
|
38 \"hits\" : [ ] |
|
39 }, |
|
40 \"aggregations\" : { |
|
41 \"geos\" : { |
|
42 \"doc_count_error_upper_bound\" : 0, |
|
43 \"sum_other_doc_count\" : 0, |
|
44 \"buckets\" : [ { |
|
45 \"key\" : 6255148, |
|
46 \"doc_count\" : 2684 |
|
47 }, { |
|
48 \"key\" : 3017382, |
|
49 \"doc_count\" : 2674 |
|
50 }, { |
|
51 \"key\" : 3027939, |
|
52 \"doc_count\" : 851 |
|
53 } ] |
|
54 } |
|
55 } |
|
56 }", true)); |
|
57 |
|
58 $this->get('/api/v1/stats/geostats/')->assertTrue($this->response->isOk(), $this->response->content()); |
|
59 $this->seeJsonEquals(["geostats" => [ |
|
60 '6255148' => 2684, |
|
61 '3017382' => 2674, |
|
62 '3027939' => 851 |
|
63 ]]); |
|
64 } |
|
65 } |