Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
e407d048
Commit
e407d048
authored
Feb 06, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated elasticsearch querybuilder test to use yiitest index
better not delete all to avoid data loss pr #2324
parent
bad9c0cc
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
QueryBuilderTest.php
tests/unit/extensions/elasticsearch/QueryBuilderTest.php
+12
-8
No files found.
tests/unit/extensions/elasticsearch/QueryBuilderTest.php
View file @
e407d048
...
@@ -15,18 +15,22 @@ class QueryBuilderTest extends ElasticSearchTestCase
...
@@ -15,18 +15,22 @@ class QueryBuilderTest extends ElasticSearchTestCase
{
{
parent
::
setUp
();
parent
::
setUp
();
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
->
deleteAllIndexes
();
// delete index
if
(
$command
->
indexExists
(
'yiitest'
))
{
$command
->
deleteIndex
(
'yiitest'
);
}
}
}
private
function
prepareDbData
()
private
function
prepareDbData
()
{
{
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
->
insert
(
'test'
,
'article'
,
[
'title'
=>
'I love yii!'
],
1
);
$command
->
insert
(
'
yii
test'
,
'article'
,
[
'title'
=>
'I love yii!'
],
1
);
$command
->
insert
(
'test'
,
'article'
,
[
'title'
=>
'Symfony2 is another framework'
],
2
);
$command
->
insert
(
'
yii
test'
,
'article'
,
[
'title'
=>
'Symfony2 is another framework'
],
2
);
$command
->
insert
(
'test'
,
'article'
,
[
'title'
=>
'Yii2 out now!'
],
3
);
$command
->
insert
(
'
yii
test'
,
'article'
,
[
'title'
=>
'Yii2 out now!'
],
3
);
$command
->
insert
(
'test'
,
'article'
,
[
'title'
=>
'yii test'
],
4
);
$command
->
insert
(
'
yii
test'
,
'article'
,
[
'title'
=>
'yii test'
],
4
);
$command
->
flushIndex
();
$command
->
flushIndex
(
'yiitest'
);
}
}
public
function
testQueryBuilderRespectsQuery
()
public
function
testQueryBuilderRespectsQuery
()
...
@@ -47,7 +51,7 @@ class QueryBuilderTest extends ElasticSearchTestCase
...
@@ -47,7 +51,7 @@ class QueryBuilderTest extends ElasticSearchTestCase
$this
->
prepareDbData
();
$this
->
prepareDbData
();
$queryParts
=
[
'field'
=>
[
'title'
=>
'yii'
]];
$queryParts
=
[
'field'
=>
[
'title'
=>
'yii'
]];
$query
=
new
Query
();
$query
=
new
Query
();
$query
->
from
(
'test'
,
'article'
);
$query
->
from
(
'
yii
test'
,
'article'
);
$query
->
query
=
$queryParts
;
$query
->
query
=
$queryParts
;
$result
=
$query
->
search
(
$this
->
getConnection
());
$result
=
$query
->
search
(
$this
->
getConnection
());
$this
->
assertEquals
(
2
,
$result
[
'hits'
][
'total'
]);
$this
->
assertEquals
(
2
,
$result
[
'hits'
][
'total'
]);
...
@@ -64,7 +68,7 @@ class QueryBuilderTest extends ElasticSearchTestCase
...
@@ -64,7 +68,7 @@ class QueryBuilderTest extends ElasticSearchTestCase
]
]
];
];
$query
=
new
Query
();
$query
=
new
Query
();
$query
->
from
(
'test'
,
'article'
);
$query
->
from
(
'
yii
test'
,
'article'
);
$query
->
query
=
$queryParts
;
$query
->
query
=
$queryParts
;
$result
=
$query
->
search
(
$this
->
getConnection
());
$result
=
$query
->
search
(
$this
->
getConnection
());
$this
->
assertEquals
(
3
,
$result
[
'hits'
][
'total'
]);
$this
->
assertEquals
(
3
,
$result
[
'hits'
][
'total'
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment