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
4f5f5bb6
Commit
4f5f5bb6
authored
Nov 27, 2013
by
Paul Klimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mongo Query implemented as draft.
parent
ec2df146
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
0 deletions
+66
-0
Query.php
extensions/mongo/Query.php
+0
-0
QueryTest.php
tests/unit/extensions/mongo/QueryTest.php
+66
-0
No files found.
extensions/mongo/Query.php
View file @
4f5f5bb6
This diff is collapsed.
Click to expand it.
tests/unit/extensions/mongo/QueryTest.php
0 → 100644
View file @
4f5f5bb6
<?php
namespace
yiiunit\extensions\mongo
;
use
yii\mongo\Query
;
/**
* @group mongo
*/
class
QueryTest
extends
MongoTestCase
{
public
function
testSelect
()
{
// default
$query
=
new
Query
;
$select
=
[];
$query
->
select
(
$select
);
$this
->
assertEquals
(
$select
,
$query
->
select
);
$query
=
new
Query
;
$select
=
[
'name'
,
'something'
];
$query
->
select
(
$select
);
$this
->
assertEquals
(
$select
,
$query
->
select
);
}
public
function
testFrom
()
{
$query
=
new
Query
;
$from
=
'customer'
;
$query
->
from
(
$from
);
$this
->
assertEquals
(
$from
,
$query
->
from
);
$query
=
new
Query
;
$from
=
[
''
,
'customer'
];
$query
->
from
(
$from
);
$this
->
assertEquals
(
$from
,
$query
->
from
);
}
public
function
testOrder
()
{
$query
=
new
Query
;
$query
->
orderBy
(
'team'
);
$this
->
assertEquals
([
'team'
=>
SORT_ASC
],
$query
->
orderBy
);
$query
->
addOrderBy
(
'company'
);
$this
->
assertEquals
([
'team'
=>
SORT_ASC
,
'company'
=>
SORT_ASC
],
$query
->
orderBy
);
$query
->
addOrderBy
(
'age'
);
$this
->
assertEquals
([
'team'
=>
SORT_ASC
,
'company'
=>
SORT_ASC
,
'age'
=>
SORT_ASC
],
$query
->
orderBy
);
$query
->
addOrderBy
([
'age'
=>
SORT_DESC
]);
$this
->
assertEquals
([
'team'
=>
SORT_ASC
,
'company'
=>
SORT_ASC
,
'age'
=>
SORT_DESC
],
$query
->
orderBy
);
$query
->
addOrderBy
(
'age ASC, company DESC'
);
$this
->
assertEquals
([
'team'
=>
SORT_ASC
,
'company'
=>
SORT_DESC
,
'age'
=>
SORT_ASC
],
$query
->
orderBy
);
}
public
function
testLimitOffset
()
{
$query
=
new
Query
;
$query
->
limit
(
10
)
->
offset
(
5
);
$this
->
assertEquals
(
10
,
$query
->
limit
);
$this
->
assertEquals
(
5
,
$query
->
offset
);
}
}
\ No newline at end of file
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