Skip to content

Commit 0bcc642

Browse files
committed
TASK: Adapt Unit test to test driver version 5
1 parent b26ae0a commit 0bcc642

1 file changed

Lines changed: 48 additions & 55 deletions

File tree

Tests/Unit/Eel/ElasticSearchQueryBuilderTest.php

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* source code.
1212
*/
1313

14-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version1\Query\FilteredQuery;
14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Driver\Version5\Query\FilteredQuery;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder;
1616
use Neos\Flow\Tests\UnitTestCase;
1717
use Neos\ContentRepository\Domain\Model\NodeInterface;
@@ -45,42 +45,38 @@ public function setUp()
4545
$this->queryBuilder = new ElasticSearchQueryBuilder();
4646

4747
$request = [
48-
'query' => [
49-
'filtered' => [
50-
'query' => [
51-
'bool' => [
52-
'must' => [
53-
['match_all' => []]
54-
]
55-
]
56-
],
57-
'filter' => [
58-
'bool' => [
59-
'must' => [],
60-
'should' => [],
61-
'must_not' => [
62-
[
63-
'term' => ['_hidden' => true]
64-
],
65-
[
66-
'range' => [
67-
'_hiddenBeforeDateTime' => [
68-
'gt' => 'now'
69-
]
70-
]
71-
],
72-
[
73-
'range' => [
74-
'_hiddenAfterDateTime' => [
75-
'lt' => 'now'
76-
]
77-
]
78-
]
79-
]
80-
]
81-
]
82-
]
83-
],
48+
'query' => [
49+
'bool' => [
50+
'must' => [
51+
['match_all' => []]
52+
],
53+
'filter' => [
54+
'bool' => [
55+
'must' => [],
56+
'should' => [],
57+
'must_not' => [
58+
[
59+
'term' => ['_hidden' => true]
60+
],
61+
[
62+
'range' => [
63+
'_hiddenBeforeDateTime' => [
64+
'gt' => 'now'
65+
]
66+
]
67+
],
68+
[
69+
'range' => [
70+
'_hiddenAfterDateTime' => [
71+
'lt' => 'now'
72+
]
73+
]
74+
]
75+
]
76+
]
77+
]
78+
]
79+
],
8480
'fields' => ['__path']
8581
];
8682
$unsupportedFieldsInCountRequest = ['fields', 'sort', 'from', 'size', 'highlight', 'aggs', 'aggregations'];
@@ -99,13 +95,9 @@ public function basicRequestStructureTakesContextNodeIntoAccount()
9995
{
10096
$expected = [
10197
'query' => [
102-
'filtered' => [
103-
'query' => [
104-
'bool' => [
105-
'must' => [
106-
['match_all' => []]
107-
]
108-
]
98+
'bool' => [
99+
'must' => [
100+
['match_all' => []]
109101
],
110102
'filter' => [
111103
'bool' => [
@@ -191,7 +183,7 @@ public function nodeTypeFilterWorks()
191183
]
192184
];
193185
$actual = $this->queryBuilder->getRequest()->toArray();
194-
$this->assertInArray($expected, $actual['query']['filtered']['filter']['bool']['must']);
186+
$this->assertInArray($expected, $actual['query']['bool']['filter']['bool']['must']);
195187
}
196188

197189
/**
@@ -281,7 +273,7 @@ public function rangeConstraintsWork($constraint, $operator, $value)
281273
]
282274
];
283275
$actual = $this->queryBuilder->getRequest()->toArray();
284-
$this->assertInArray($expected, $actual['query']['filtered']['filter']['bool']['must']);
276+
$this->assertInArray($expected, $actual['query']['bool']['filter']['bool']['must']);
285277
}
286278

287279
/**
@@ -306,6 +298,7 @@ public function simpleAggregationExamples()
306298
* @param string $name
307299
* @param string $field
308300
* @param integer size
301+
* @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception\QueryBuildingException
309302
*/
310303
public function anSimpleAggregationCanBeAddedToTheRequest($type, $name, $field, $size)
311304
{
@@ -368,8 +361,8 @@ public function anAggregationCanBeSubbedUnderAPath()
368361
*/
369362
public function ifTheParentPathDoesNotExistAnExceptionisThrown()
370363
{
371-
$this->queryBuilder->fieldBasedAggregation("foo", "bar");
372-
$this->queryBuilder->fieldBasedAggregation("bar", "bar", "terms", "doesNotExist");
364+
$this->queryBuilder->fieldBasedAggregation('foo', 'bar');
365+
$this->queryBuilder->fieldBasedAggregation('bar', 'bar', 'terms', 'doesNotExist');
373366
}
374367

375368
/**
@@ -378,8 +371,8 @@ public function ifTheParentPathDoesNotExistAnExceptionisThrown()
378371
*/
379372
public function ifSubbedParentPathDoesNotExistAnExceptionisThrown()
380373
{
381-
$this->queryBuilder->fieldBasedAggregation("foo", "bar");
382-
$this->queryBuilder->fieldBasedAggregation("bar", "bar", "terms", "foo.doesNotExist");
374+
$this->queryBuilder->fieldBasedAggregation('foo', 'bar');
375+
$this->queryBuilder->fieldBasedAggregation('bar', 'bar', 'terms', 'foo.doesNotExist');
383376
}
384377

385378
/**
@@ -388,14 +381,14 @@ public function ifSubbedParentPathDoesNotExistAnExceptionisThrown()
388381
public function aCustomAggregationDefinitionCanBeApplied()
389382
{
390383
$expected = [
391-
"foo" => [
392-
"some" => ["field" => "bar"],
393-
"custom" => ["field" => "bar"],
394-
"arrays" => ["field" => "bar"]
384+
'foo' => [
385+
'some' => ['field' => 'bar'],
386+
'custom' => ['field' => 'bar'],
387+
'arrays' => ['field' => 'bar']
395388
]
396389
];
397390

398-
$this->queryBuilder->aggregation("foo", $expected['foo']);
391+
$this->queryBuilder->aggregation('foo', $expected['foo']);
399392
$actual = $this->queryBuilder->getRequest()->toArray();
400393

401394
$this->assertInArray($expected, $actual);

0 commit comments

Comments
 (0)