equal
deleted
inserted
replaced
5 /** |
5 /** |
6 * |
6 * |
7 */ |
7 */ |
8 class DiscourseControllerTest extends TestCase { |
8 class DiscourseControllerTest extends TestCase { |
9 |
9 |
10 const ES_QUERY = [ |
10 private $ES_QUERY; |
11 'index' => 'corpus', |
11 |
12 'body' => [ |
12 public function setUp() { |
13 "size" => 0, |
13 $this->ES_QUERY = [ |
14 "query" => [ "match_all" => [] ], |
14 'index' => 'corpus', |
15 "aggs" => [ |
15 'body' => [ |
16 "discourses" => [ |
16 "size" => 0, |
17 "terms" => [ "field" => "discourse_types", "order" => [ "_count" => "desc" ], "size" => 0 ] |
17 "query" => [ "match_all" => (object) null ], |
|
18 "aggs" => [ |
|
19 "discourses" => [ |
|
20 "terms" => [ "field" => "discourse_types", "order" => [ "_count" => "desc" ], "size" => 2147483647 ] |
|
21 ] |
18 ] |
22 ] |
19 ] |
23 ] |
20 ] |
24 ]; |
21 ]; |
|
22 |
|
23 public function setUp() { |
|
24 |
|
25 parent::setup(); |
25 parent::setup(); |
26 |
26 |
27 } |
27 } |
28 |
28 |
29 public function tearDown() { |
29 public function tearDown() { |
33 |
33 |
34 public function testIndex() { |
34 public function testIndex() { |
35 |
35 |
36 Es::shouldReceive('search') |
36 Es::shouldReceive('search') |
37 ->once() |
37 ->once() |
38 ->with(self::ES_QUERY) |
38 ->with($this->ES_QUERY) |
39 ->andReturn(json_decode('{ |
39 ->andReturn(json_decode('{ |
40 "took" : 116, |
40 "took" : 116, |
41 "timed_out" : false, |
41 "timed_out" : false, |
42 "_shards" : { |
42 "_shards" : { |
43 "total" : 1, |
43 "total" : 1, |
78 } |
78 } |
79 |
79 |
80 public function testIndexQuery() { |
80 public function testIndexQuery() { |
81 Es::shouldReceive('search') |
81 Es::shouldReceive('search') |
82 ->once() |
82 ->once() |
83 ->with(self::ES_QUERY) |
83 ->with($this->ES_QUERY) |
84 ->andReturn(json_decode('{ |
84 ->andReturn(json_decode('{ |
85 "took" : 116, |
85 "took" : 116, |
86 "timed_out" : false, |
86 "timed_out" : false, |
87 "_shards" : { |
87 "_shards" : { |
88 "total" : 1, |
88 "total" : 1, |