Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
laravel-mongodb
Project
Project
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
sinan
laravel-mongodb
Commits
bb776aa5
Commit
bb776aa5
authored
5 years ago
by
fso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cursor support
parent
84cd2418
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
QueryBuilderTest.php
tests/QueryBuilderTest.php
+21
-0
No files found.
tests/QueryBuilderTest.php
View file @
bb776aa5
...
...
@@ -3,6 +3,7 @@ declare(strict_types=1);
use
Illuminate\Support\Facades\Date
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\LazyCollection
;
use
Jenssegers\Mongodb\Collection
;
use
Jenssegers\Mongodb\Query\Builder
;
use
MongoDB\BSON\ObjectId
;
...
...
@@ -759,4 +760,24 @@ class QueryBuilderTest extends TestCase
$this
->
assertEquals
(
'spork'
,
$results
[
1
][
'name'
]);
$this
->
assertEquals
(
'fork'
,
$results
[
0
][
'name'
]);
}
public
function
testCursor
()
{
$data
=
[
[
'name'
=>
'fork'
,
'tags'
=>
[
'sharp'
,
'pointy'
]],
[
'name'
=>
'spork'
,
'tags'
=>
[
'sharp'
,
'pointy'
,
'round'
,
'bowl'
]],
[
'name'
=>
'spoon'
,
'tags'
=>
[
'round'
,
'bowl'
]],
];
DB
::
collection
(
'items'
)
->
insert
(
$data
);
$results
=
DB
::
collection
(
'items'
)
->
orderBy
(
'_id'
,
'asc'
)
->
cursor
();
$this
->
assertInstanceOf
(
LazyCollection
::
class
,
$results
);
$i
=
0
;
foreach
(
$results
as
$result
)
{
$this
->
assertEquals
(
$data
[
$i
][
'name'
],
$result
[
'name'
]);
$i
++
;
}
}
}
This diff is collapsed.
Click to expand it.
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