server/src/tests/Controllers/GeoStatsControllerTest.php
author ymh <ymh.work@gmail.com>
Mon, 12 Jun 2017 14:53:59 +0200
changeset 537 d2e6ee099125
parent 407 2dba812c7ef2
permissions -rw-r--r--
upgrade ember + laravel + make everything work
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
308
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
class GeoStatsControllerTest extends TestCase
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
{
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
   public function testGetIndex()
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
    {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
        $query = [
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
            'index' => env('ELASTICSEARCH_INDEX'),
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
            'body' => [
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
                "size" => 0,
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    11
                "query" => [
407
2dba812c7ef2 add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents: 387
diff changeset
    12
                    'match_all' => (object) null
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    13
                ],
308
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
                "aggs" => [
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
                    "geos" => [
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
                        "terms" => [
407
2dba812c7ef2 add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents: 387
diff changeset
    17
                            "size" => 2147483647,
308
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
                            "field" => "geonames_hierarchy"
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
                        ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
                    ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
                ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
            ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        ];
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
        Es::shouldReceive('search')
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
                    ->once()
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
                    ->with($query)
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
                    ->andReturn(json_decode("{
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
  \"took\" : 17,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
  \"timed_out\" : false,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
  \"_shards\" : {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
    \"total\" : 1,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
    \"successful\" : 1,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
    \"failed\" : 0
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
  },
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
  \"hits\" : {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
    \"total\" : 3011,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
    \"max_score\" : 0.0,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
    \"hits\" : [ ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
  },
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
  \"aggregations\" : {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
    \"geos\" : {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
      \"doc_count_error_upper_bound\" : 0,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
      \"sum_other_doc_count\" : 0,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
      \"buckets\" : [ {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
        \"key\" : 6255148,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
        \"doc_count\" : 2684
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
      }, {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
        \"key\" : 3017382,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
        \"doc_count\" : 2674
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
      }, {
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
        \"key\" : 3027939,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
        \"doc_count\" : 851
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
      } ]
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
    }
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
  }
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
}", true));
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
537
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
    59
        $response = $this->get('/api/v1/stats/geostats/');
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
    60
        $response
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
    61
            ->assertStatus(200)
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
    62
            ->assertJson(["geostats" => [
308
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
            '6255148' => 2684,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
            '3017382' => 2674,
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
            '3027939' => 851
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
        ]]);
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
    }
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    68
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    69
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    70
    public function testGetIndexEarth()
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    71
    {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    72
        $query = [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    73
            'index' => env('ELASTICSEARCH_INDEX'),
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    74
            'body' => [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    75
                "size" => 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    76
                "query" => [
407
2dba812c7ef2 add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents: 387
diff changeset
    77
                    'match_all' => (object) null
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    78
                ],
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    79
                "aggs" => [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    80
                    "geos" => [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    81
                        "terms" => [
407
2dba812c7ef2 add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents: 387
diff changeset
    82
                            "size" => 2147483647,
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    83
                            "field" => "geonames_hierarchy"
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    84
                        ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    85
                    ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    86
                ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    87
            ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    88
        ];
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    89
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    90
        Es::shouldReceive('search')
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    91
                ->once()
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    92
                ->with($query)
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    93
                ->andReturn(json_decode("{
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    94
  \"took\" : 17,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    95
  \"timed_out\" : false,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    96
  \"_shards\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    97
    \"total\" : 1,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    98
    \"successful\" : 1,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
    99
    \"failed\" : 0
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   100
  },
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   101
  \"hits\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   102
    \"total\" : 3011,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   103
    \"max_score\" : 0.0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   104
    \"hits\" : [ ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   105
  },
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   106
  \"aggregations\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   107
    \"geos\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   108
      \"doc_count_error_upper_bound\" : 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   109
      \"sum_other_doc_count\" : 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   110
      \"buckets\" : []
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   111
    }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   112
  }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   113
}", true));
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   114
537
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
   115
        $response = $this->get('/api/v1/stats/geostats/?area='.config('corpusparole.geonames_earth_geonamesid'));
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
   116
        $response->assertStatus(200);
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   117
    }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   118
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   119
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   120
    public function testGetIndexArea()
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   121
    {
387
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   122
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   123
        $query = [
387
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   124
            "index" => env('ELASTICSEARCH_INDEX'),
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   125
            "body" => [
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   126
                "size" => 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   127
                "query" => [
387
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   128
                    "constant_score" => [
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   129
                        "filter" => [
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   130
                            "bool" => [
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   131
                                "must" => [ [
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   132
                                    "term" => [ "geonames_hierarchy" => "code_area" ]
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   133
                                ] ]
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   134
                            ]
7fba86fa8604 Sparql client implementation
ymh <ymh.work@gmail.com>
parents: 320
diff changeset
   135
                        ]
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   136
                    ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   137
                ],
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   138
                "aggs" => [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   139
                    "geos" => [
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   140
                        "terms" => [
407
2dba812c7ef2 add a way to build rpm for puppet files, correct elasticsearch provisioning, correct error on elasticsearch queries + tests
ymh <ymh.work@gmail.com>
parents: 387
diff changeset
   141
                            "size" => 2147483647,
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   142
                            "field" => "geonames_hierarchy"
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   143
                        ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   144
                    ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   145
                ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   146
            ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   147
        ];
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   148
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   149
        Es::shouldReceive('search')
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   150
                ->once()
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   151
                ->with($query)
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   152
                ->andReturn(json_decode("{
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   153
  \"took\" : 17,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   154
  \"timed_out\" : false,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   155
  \"_shards\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   156
    \"total\" : 1,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   157
    \"successful\" : 1,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   158
    \"failed\" : 0
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   159
  },
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   160
  \"hits\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   161
    \"total\" : 3011,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   162
    \"max_score\" : 0.0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   163
    \"hits\" : [ ]
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   164
  },
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   165
  \"aggregations\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   166
    \"geos\" : {
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   167
      \"doc_count_error_upper_bound\" : 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   168
      \"sum_other_doc_count\" : 0,
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   169
      \"buckets\" : []
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   170
    }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   171
  }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   172
}", true));
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   173
537
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
   174
        $response = $this->get('/api/v1/stats/geostats/?area=code_area');
d2e6ee099125 upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents: 407
diff changeset
   175
        $response->assertStatus(200);
320
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   176
    }
0fce13da58af filter geostat by area + tests
ymh <ymh.work@gmail.com>
parents: 319
diff changeset
   177
308
e032d686d88e add hierarchy info in document indexation + geostats api controllers + add some keys to geonames resolver
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
}