Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
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
mongo-php-library
Commits
60895448
Commit
60895448
authored
Jun 21, 2019
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v1.4'
parents
d63c3fad
9f457142
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
9 deletions
+12
-9
DocumentationExamplesTest.php
tests/DocumentationExamplesTest.php
+12
-9
No files found.
tests/DocumentationExamplesTest.php
View file @
60895448
...
...
@@ -951,11 +951,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
$changeStream
->
next
();
$
next
Change
=
$changeStream
->
current
();
$
second
Change
=
$changeStream
->
current
();
// End Changestream Example 2
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$
next
Change
);
$this
->
assertNull
(
$
second
Change
);
$insertManyResult
=
$db
->
inventory
->
insertMany
([
[
'_id'
=>
1
,
'x'
=>
'foo'
],
...
...
@@ -981,27 +981,30 @@ class DocumentationExamplesTest extends FunctionalTestCase
$resumeToken
=
(
$lastChange
!==
null
)
?
$lastChange
->
_id
:
null
;
if
(
$resumeToken
===
null
)
{
throw
new
\Exception
(
'
resumeT
oken was not found'
);
throw
new
\Exception
(
'
Resume t
oken was not found'
);
}
$changeStream
=
$db
->
inventory
->
watch
([],
[
'resumeAfter'
=>
$resumeToken
]);
$changeStream
->
rewind
();
$
nex
tChange
=
$changeStream
->
current
();
$
firs
tChange
=
$changeStream
->
current
();
// End Changestream Example 3
$expectedChange
=
[
'_id'
=>
$
nex
tChange
->
_id
,
'_id'
=>
$
firs
tChange
->
_id
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
'inventory'
],
'documentKey'
=>
[
'_id'
=>
2
],
];
$this
->
assertMatchesDocument
(
$expectedChange
,
$
nex
tChange
);
$this
->
assertMatchesDocument
(
$expectedChange
,
$
firs
tChange
);
// Start Changestream Example 4
$pipeline
=
[[
'$match'
=>
[
'$or'
=>
[[
'fullDocument.username'
=>
'alice'
],
[
'operationType'
=>
'delete'
]]]]];
$pipeline
=
[
[
'$match'
=>
[
'fullDocument.username'
=>
'alice'
]],
[
'$addFields'
=>
[
'newField'
=>
'this is an added field!'
]],
];
$changeStream
=
$db
->
inventory
->
watch
(
$pipeline
);
$changeStream
->
rewind
();
...
...
@@ -1009,11 +1012,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
$changeStream
->
next
();
$
next
Change
=
$changeStream
->
current
();
$
second
Change
=
$changeStream
->
current
();
// End Changestream Example 4
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$
next
Change
);
$this
->
assertNull
(
$
second
Change
);
}
public
function
testAggregation_example_1
()
...
...
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