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
19327ebd
Commit
19327ebd
authored
Mar 26, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for Query::filter()
parent
0d3e85ca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
130 additions
and
0 deletions
+130
-0
QueryTest.php
tests/unit/extensions/elasticsearch/QueryTest.php
+29
-0
QueryTest.php
tests/unit/extensions/mongodb/QueryTest.php
+42
-0
QueryTest.php
tests/unit/extensions/sphinx/QueryTest.php
+29
-0
QueryTest.php
tests/unit/framework/db/QueryTest.php
+30
-0
No files found.
tests/unit/extensions/elasticsearch/QueryTest.php
View file @
19327ebd
...
@@ -151,6 +151,35 @@ class QueryTest extends ElasticSearchTestCase
...
@@ -151,6 +151,35 @@ class QueryTest extends ElasticSearchTestCase
}
}
public
function
testFilter
()
{
$query
=
new
Query
;
$query
->
filter
(
'id = :id'
,
[
':id'
=>
1
]);
$this
->
assertEquals
(
'id = :id'
,
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
'something'
]);
$this
->
assertEquals
([
'and'
,
'id = :id'
,
'name = :name'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
'30'
]);
$this
->
assertEquals
([
'or'
,
[
'and'
,
'id = :id'
,
'name = :name'
],
'age = :age'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
$query
=
new
Query
;
$query
->
filter
(
'id = :id'
,
[
':id'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
}
// TODO test facets
// TODO test facets
// TODO test complex where() every edge of QueryBuilder
// TODO test complex where() every edge of QueryBuilder
...
...
tests/unit/extensions/mongodb/QueryTest.php
View file @
19327ebd
...
@@ -68,6 +68,48 @@ class QueryTest extends MongoDbTestCase
...
@@ -68,6 +68,48 @@ class QueryTest extends MongoDbTestCase
);
);
}
}
public
function
testFilter
()
{
$query
=
new
Query
;
$query
->
filter
([
'name'
=>
'name1'
]);
$this
->
assertEquals
([
'name'
=>
'name1'
],
$query
->
where
);
$query
->
andFilter
([
'address'
=>
'address1'
]);
$this
->
assertEquals
(
[
'and'
,
[
'name'
=>
'name1'
],
[
'address'
=>
'address1'
]
],
$query
->
where
);
$query
->
orFilter
([
'name'
=>
'name2'
]);
$this
->
assertEquals
(
[
'or'
,
[
'and'
,
[
'name'
=>
'name1'
],
[
'address'
=>
'address1'
]
],
[
'name'
=>
'name2'
]
],
$query
->
where
);
$query
=
new
Query
;
$query
->
filter
([
'name'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$query
->
andFilter
([
'address'
=>
''
]);
$this
->
assertEquals
([],
$query
->
where
);
$query
->
orFilter
([
'name'
=>
''
]);
$this
->
assertEquals
([],
$query
->
where
);
}
public
function
testOrder
()
public
function
testOrder
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
...
...
tests/unit/extensions/sphinx/QueryTest.php
View file @
19327ebd
...
@@ -60,6 +60,35 @@ class QueryTest extends SphinxTestCase
...
@@ -60,6 +60,35 @@ class QueryTest extends SphinxTestCase
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
}
}
public
function
testFilter
()
{
$query
=
new
Query
;
$query
->
filter
(
'id = :id'
,
[
':id'
=>
1
]);
$this
->
assertEquals
(
'id = :id'
,
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
'something'
]);
$this
->
assertEquals
([
'and'
,
'id = :id'
,
'name = :name'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
'30'
]);
$this
->
assertEquals
([
'or'
,
[
'and'
,
'id = :id'
,
'name = :name'
],
'age = :age'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
$query
=
new
Query
;
$query
->
filter
(
'id = :id'
,
[
':id'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
}
public
function
testGroup
()
public
function
testGroup
()
{
{
$query
=
new
Query
;
$query
=
new
Query
;
...
...
tests/unit/framework/db/QueryTest.php
View file @
19327ebd
...
@@ -49,6 +49,36 @@ class QueryTest extends DatabaseTestCase
...
@@ -49,6 +49,36 @@ class QueryTest extends DatabaseTestCase
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
}
}
public
function
testFilter
()
{
$query
=
new
Query
;
$query
->
filter
(
'id = :id'
,
[
':id'
=>
1
]);
$this
->
assertEquals
(
'id = :id'
,
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
'something'
]);
$this
->
assertEquals
([
'and'
,
'id = :id'
,
'name = :name'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
'30'
]);
$this
->
assertEquals
([
'or'
,
[
'and'
,
'id = :id'
,
'name = :name'
],
'age = :age'
],
$query
->
where
);
$this
->
assertEquals
([
':id'
=>
1
,
':name'
=>
'something'
,
':age'
=>
'30'
],
$query
->
params
);
$query
=
new
Query
();
$query
->
filter
(
'id = :id'
,
[
':id'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
andFilter
(
'name = :name'
,
[
':name'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
$query
->
orFilter
(
'age = :age'
,
[
':age'
=>
''
]);
$this
->
assertEquals
(
''
,
$query
->
where
);
$this
->
assertEquals
([],
$query
->
params
);
}
public
function
testJoin
()
public
function
testJoin
()
{
{
}
}
...
...
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