Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Elasticsearch DSL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Public
Elasticsearch DSL
Commits
47b3d116
Commit
47b3d116
authored
9 years ago
by
Simonas Šerlinskas
Browse files
Options
Downloads
Patches
Plain Diff
added more test cases to bool query
parent
bed67f70
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/Query/BoolQueryTest.php
+40
-14
40 additions, 14 deletions
tests/Query/BoolQueryTest.php
with
40 additions
and
14 deletions
tests/
Filt
er/Bool
Filt
erTest.php
→
tests/
Qu
er
y
/Bool
Qu
er
y
Test.php
+
40
−
14
View file @
47b3d116
...
...
@@ -11,9 +11,9 @@
namespace
ONGR\ElasticsearchDSL\Tests\Unit\DSL\Aggregation
;
use
ONGR\ElasticsearchDSL\
Filt
er\Bool
Filt
er
;
use
ONGR\ElasticsearchDSL\
Filt
er\M
issingFilt
er
;
use
ONGR\ElasticsearchDSL\
Filt
er\Term
Filt
er
;
use
ONGR\ElasticsearchDSL\
Qu
er
y
\Bool
Qu
er
y
;
use
ONGR\ElasticsearchDSL\
Qu
er
y
\M
atchAllQu
er
y
;
use
ONGR\ElasticsearchDSL\
Qu
er
y
\Term
Qu
er
y
;
/**
* Unit test for Bool.
...
...
@@ -23,11 +23,37 @@ class BoolFilterTest extends \PHPUnit_Framework_TestCase
/**
* Tests isRelevant method.
*/
public
function
testBoolIsRelevant
()
public
function
testBoolIsRelevant
WithOneQuery
()
{
$bool
=
new
Bool
Filt
er
();
$bool
=
new
Bool
Qu
er
y
();
$this
->
assertFalse
(
$bool
->
isRelevant
());
$bool
->
add
(
new
MissingFilter
(
'test'
));
$bool
->
add
(
new
TermQuery
(
'acme'
,
'foo'
));
$this
->
assertFalse
(
$bool
->
isRelevant
());
}
/**
* Tests isRelevant method when there is query added to should case.
*/
public
function
testBoolIsRelevantWithOneShouldQuery
()
{
$bool
=
new
BoolQuery
();
$this
->
assertFalse
(
$bool
->
isRelevant
());
$bool
->
add
(
new
TermQuery
(
'acme'
,
'foo'
),
BoolQuery
::
SHOULD
);
$this
->
assertFalse
(
$bool
->
isRelevant
());
}
/**
* Tests isRelevant method with 2 queries.
*/
public
function
testBoolIsRelevantWithTwoQuery
()
{
$bool
=
new
BoolQuery
();
$this
->
assertFalse
(
$bool
->
isRelevant
());
$bool
->
add
(
new
TermQuery
(
'acme'
,
'foo'
));
$bool
->
add
(
new
TermQuery
(
'bar'
,
'go'
));
$this
->
assertTrue
(
$bool
->
isRelevant
());
}
...
...
@@ -35,12 +61,12 @@ class BoolFilterTest extends \PHPUnit_Framework_TestCase
* Test for addToBool() without setting a correct bool operator.
*
* @expectedException \UnexpectedValueException
* @expectedExceptionMessage The bool operator
Should
is not supported
* @expectedExceptionMessage The
provided
bool operator is not supported
*/
public
function
testBoolAddToBoolException
()
{
$bool
=
new
Bool
Filt
er
();
$bool
->
add
(
new
M
issingFilter
(
'test'
),
'Should
'
);
$bool
=
new
Bool
Qu
er
y
();
$bool
->
add
(
new
M
atchAllQuery
(),
'acme
'
);
}
/**
...
...
@@ -48,10 +74,10 @@ class BoolFilterTest extends \PHPUnit_Framework_TestCase
*/
public
function
testBoolToArray
()
{
$bool
=
new
Bool
Filt
er
();
$bool
->
add
(
new
Term
Filt
er
(
'key1'
,
'value1'
),
'should'
);
$bool
->
add
(
new
Term
Filt
er
(
'key2'
,
'value2'
),
'must'
);
$bool
->
add
(
new
Term
Filt
er
(
'key3'
,
'value3'
),
'must_not'
);
$bool
=
new
Bool
Qu
er
y
();
$bool
->
add
(
new
Term
Qu
er
y
(
'key1'
,
'value1'
),
BoolQuery
::
SHOULD
);
$bool
->
add
(
new
Term
Qu
er
y
(
'key2'
,
'value2'
),
BoolQuery
::
MUST
);
$bool
->
add
(
new
Term
Qu
er
y
(
'key3'
,
'value3'
),
BoolQuery
::
MUST_NOT
);
$expected
=
[
'should'
=>
[
[
...
...
@@ -83,7 +109,7 @@ class BoolFilterTest extends \PHPUnit_Framework_TestCase
*/
public
function
testBoolGetType
()
{
$bool
=
new
Bool
Filt
er
();
$bool
=
new
Bool
Qu
er
y
();
$result
=
$bool
->
getType
();
$this
->
assertEquals
(
'bool'
,
$result
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment