author | ymh <ymh.work@gmail.com> |
Tue, 20 Mar 2018 15:02:40 +0100 | |
changeset 573 | 25f3d28f51b2 |
parent 537 | d2e6ee099125 |
permissions | -rw-r--r-- |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
use Mockery as m; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
use EasyRdf\Resource; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
use EasyRdf\Literal; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
use CorpusParole\Services\ViafResolverException; |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
/** |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
* |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
*/ |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
class LanguageControllerTest extends TestCase { |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
|
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:
377
diff
changeset
|
14 |
private $ES_QUERY; |
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:
377
diff
changeset
|
15 |
|
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:
377
diff
changeset
|
16 |
public function setUp() { |
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:
377
diff
changeset
|
17 |
$this->ES_QUERY = [ |
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:
377
diff
changeset
|
18 |
'index' => 'corpus', |
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:
377
diff
changeset
|
19 |
'body' => [ |
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:
377
diff
changeset
|
20 |
"size" => 0, |
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:
377
diff
changeset
|
21 |
"query" => [ "match_all" => (object) null ], |
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:
377
diff
changeset
|
22 |
"aggs" => [ |
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:
377
diff
changeset
|
23 |
"languages" => [ |
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:
377
diff
changeset
|
24 |
"terms" => [ "field" => "language", "order" => [ "_count" => "desc" ], "size" => 2147483647 ] |
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:
377
diff
changeset
|
25 |
] |
377
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
26 |
] |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
27 |
] |
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:
377
diff
changeset
|
28 |
]; |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
parent::setup(); |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
} |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
public function tearDown() { |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
m::close(); |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
parent::tearDown(); |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
} |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
|
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
public function testIndex() { |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
377
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
39 |
Es::shouldReceive('search') |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
40 |
->once() |
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:
377
diff
changeset
|
41 |
->with($this->ES_QUERY) |
377
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
42 |
->andReturn(json_decode('{ |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
43 |
"took": 92, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
44 |
"timed_out": false, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
45 |
"_shards": { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
46 |
"total": 1, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
47 |
"successful": 1, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
48 |
"failed": 0 |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
49 |
}, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
50 |
"hits": { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
51 |
"total": 3373, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
52 |
"max_score": 0.0, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
53 |
"hits": [] |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
54 |
}, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
55 |
"aggregations": { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
56 |
"languages": { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
57 |
"doc_count_error_upper_bound": 0, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
58 |
"sum_other_doc_count": 0, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
59 |
"buckets": [{ |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
60 |
"key": "http://lexvo.org/id/iso639-3/fra", |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
61 |
"doc_count": 1669 |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
62 |
}, { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
63 |
"key": "http://lexvo.org/id/iso639-3/gsw", |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
64 |
"doc_count": 851 |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
65 |
}, { |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
66 |
"key": "http://lexvo.org/id/iso639-3/bre", |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
67 |
"doc_count": 403 |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
68 |
}] |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
69 |
} |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
70 |
} |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
71 |
}', true)); |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
72 |
|
537
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
73 |
$response = $this->get('/api/v1/stats/languages/'); |
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
74 |
$response |
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
75 |
->assertStatus(200) |
d2e6ee099125
upgrade ember + laravel + make everything work
ymh <ymh.work@gmail.com>
parents:
407
diff
changeset
|
76 |
->assertJson(['languages' => [ |
377
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
77 |
'http://lexvo.org/id/iso639-3/fra' => 1669, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
78 |
'http://lexvo.org/id/iso639-3/gsw' => 851, |
52169c718513
make all stats view use elasticsearch. Make sure that the document discourse types are taken form the predefined list
ymh <ymh.work@gmail.com>
parents:
306
diff
changeset
|
79 |
'http://lexvo.org/id/iso639-3/bre' => 403, |
126
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
]]); |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
} |
e87a340711a4
improve on dataloading. add fixture management with proper interface to load data.
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
} |