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
702cf513
Commit
702cf513
authored
Dec 18, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make elasticsearch tests only work on yiitext index
parent
b4612637
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
QueryTest.php
tests/unit/extensions/elasticsearch/QueryTest.php
+15
-12
No files found.
tests/unit/extensions/elasticsearch/QueryTest.php
View file @
702cf513
...
@@ -15,12 +15,15 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -15,12 +15,15 @@ class QueryTest extends ElasticSearchTestCase
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
=
$this
->
getConnection
()
->
createCommand
();
$command
->
deleteAllIndexes
();
// delete index
if
(
$command
->
indexExists
(
'yiitest'
))
{
$command
->
deleteIndex
(
'yiitest'
);
}
$command
->
insert
(
'test'
,
'user'
,
[
'name'
=>
'user1'
,
'email'
=>
'user1@example.com'
,
'status'
=>
1
],
1
);
$command
->
insert
(
'
yii
test'
,
'user'
,
[
'name'
=>
'user1'
,
'email'
=>
'user1@example.com'
,
'status'
=>
1
],
1
);
$command
->
insert
(
'test'
,
'user'
,
[
'name'
=>
'user2'
,
'email'
=>
'user2@example.com'
,
'status'
=>
1
],
2
);
$command
->
insert
(
'
yii
test'
,
'user'
,
[
'name'
=>
'user2'
,
'email'
=>
'user2@example.com'
,
'status'
=>
1
],
2
);
$command
->
insert
(
'test'
,
'user'
,
[
'name'
=>
'user3'
,
'email'
=>
'user3@example.com'
,
'status'
=>
2
],
3
);
$command
->
insert
(
'
yii
test'
,
'user'
,
[
'name'
=>
'user3'
,
'email'
=>
'user3@example.com'
,
'status'
=>
2
],
3
);
$command
->
insert
(
'test'
,
'user'
,
[
'name'
=>
'user4'
,
'email'
=>
'user4@example.com'
,
'status'
=>
1
],
4
);
$command
->
insert
(
'
yii
test'
,
'user'
,
[
'name'
=>
'user4'
,
'email'
=>
'user4@example.com'
,
'status'
=>
1
],
4
);
$command
->
flushIndex
();
$command
->
flushIndex
();
}
}
...
@@ -28,7 +31,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -28,7 +31,7 @@ class QueryTest extends ElasticSearchTestCase
public
function
testFields
()
public
function
testFields
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$query
->
fields
([
'name'
,
'status'
]);
$query
->
fields
([
'name'
,
'status'
]);
$this
->
assertEquals
([
'name'
,
'status'
],
$query
->
fields
);
$this
->
assertEquals
([
'name'
,
'status'
],
$query
->
fields
);
...
@@ -63,7 +66,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -63,7 +66,7 @@ class QueryTest extends ElasticSearchTestCase
public
function
testOne
()
public
function
testOne
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$result
=
$query
->
one
(
$this
->
getConnection
());
$result
=
$query
->
one
(
$this
->
getConnection
());
$this
->
assertEquals
(
3
,
count
(
$result
[
'_source'
]));
$this
->
assertEquals
(
3
,
count
(
$result
[
'_source'
]));
...
@@ -87,7 +90,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -87,7 +90,7 @@ class QueryTest extends ElasticSearchTestCase
public
function
testAll
()
public
function
testAll
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$results
=
$query
->
all
(
$this
->
getConnection
());
$results
=
$query
->
all
(
$this
->
getConnection
());
$this
->
assertEquals
(
4
,
count
(
$results
));
$this
->
assertEquals
(
4
,
count
(
$results
));
...
@@ -99,7 +102,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -99,7 +102,7 @@ class QueryTest extends ElasticSearchTestCase
$this
->
assertArrayHasKey
(
'_id'
,
$result
);
$this
->
assertArrayHasKey
(
'_id'
,
$result
);
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$results
=
$query
->
where
([
'name'
=>
'user1'
])
->
all
(
$this
->
getConnection
());
$results
=
$query
->
where
([
'name'
=>
'user1'
])
->
all
(
$this
->
getConnection
());
$this
->
assertEquals
(
1
,
count
(
$results
));
$this
->
assertEquals
(
1
,
count
(
$results
));
...
@@ -113,7 +116,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -113,7 +116,7 @@ class QueryTest extends ElasticSearchTestCase
// indexBy
// indexBy
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$results
=
$query
->
indexBy
(
'name'
)
->
all
(
$this
->
getConnection
());
$results
=
$query
->
indexBy
(
'name'
)
->
all
(
$this
->
getConnection
());
$this
->
assertEquals
(
4
,
count
(
$results
));
$this
->
assertEquals
(
4
,
count
(
$results
));
...
@@ -124,7 +127,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -124,7 +127,7 @@ class QueryTest extends ElasticSearchTestCase
public
function
testScalar
()
public
function
testScalar
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$result
=
$query
->
where
([
'name'
=>
'user1'
])
->
scalar
(
'name'
,
$this
->
getConnection
());
$result
=
$query
->
where
([
'name'
=>
'user1'
])
->
scalar
(
'name'
,
$this
->
getConnection
());
$this
->
assertEquals
(
'user1'
,
$result
);
$this
->
assertEquals
(
'user1'
,
$result
);
...
@@ -137,7 +140,7 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -137,7 +140,7 @@ class QueryTest extends ElasticSearchTestCase
public
function
testColumn
()
public
function
testColumn
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
$query
->
from
(
'test'
,
'user'
);
$query
->
from
(
'
yii
test'
,
'user'
);
$result
=
$query
->
orderBy
([
'name'
=>
SORT_ASC
])
->
column
(
'name'
,
$this
->
getConnection
());
$result
=
$query
->
orderBy
([
'name'
=>
SORT_ASC
])
->
column
(
'name'
,
$this
->
getConnection
());
$this
->
assertEquals
([
'user1'
,
'user2'
,
'user3'
,
'user4'
],
$result
);
$this
->
assertEquals
([
'user1'
,
'user2'
,
'user3'
,
'user4'
],
$result
);
...
...
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