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
9f457142
Commit
9f457142
authored
Jun 21, 2019
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #623
parents
a1852b20
db844127
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 @
9f457142
...
@@ -954,11 +954,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
...
@@ -954,11 +954,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
$changeStream
->
next
();
$changeStream
->
next
();
$
next
Change
=
$changeStream
->
current
();
$
second
Change
=
$changeStream
->
current
();
// End Changestream Example 2
// End Changestream Example 2
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$
next
Change
);
$this
->
assertNull
(
$
second
Change
);
$insertManyResult
=
$db
->
inventory
->
insertMany
([
$insertManyResult
=
$db
->
inventory
->
insertMany
([
[
'_id'
=>
1
,
'x'
=>
'foo'
],
[
'_id'
=>
1
,
'x'
=>
'foo'
],
...
@@ -984,27 +984,30 @@ class DocumentationExamplesTest extends FunctionalTestCase
...
@@ -984,27 +984,30 @@ class DocumentationExamplesTest extends FunctionalTestCase
$resumeToken
=
(
$lastChange
!==
null
)
?
$lastChange
->
_id
:
null
;
$resumeToken
=
(
$lastChange
!==
null
)
?
$lastChange
->
_id
:
null
;
if
(
$resumeToken
===
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
=
$db
->
inventory
->
watch
([],
[
'resumeAfter'
=>
$resumeToken
]);
$changeStream
->
rewind
();
$changeStream
->
rewind
();
$
nex
tChange
=
$changeStream
->
current
();
$
firs
tChange
=
$changeStream
->
current
();
// End Changestream Example 3
// End Changestream Example 3
$expectedChange
=
[
$expectedChange
=
[
'_id'
=>
$
nex
tChange
->
_id
,
'_id'
=>
$
firs
tChange
->
_id
,
'operationType'
=>
'insert'
,
'operationType'
=>
'insert'
,
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar'
],
'fullDocument'
=>
[
'_id'
=>
2
,
'x'
=>
'bar'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
'inventory'
],
'ns'
=>
[
'db'
=>
$this
->
getDatabaseName
(),
'coll'
=>
'inventory'
],
'documentKey'
=>
[
'_id'
=>
2
],
'documentKey'
=>
[
'_id'
=>
2
],
];
];
$this
->
assertMatchesDocument
(
$expectedChange
,
$
nex
tChange
);
$this
->
assertMatchesDocument
(
$expectedChange
,
$
firs
tChange
);
// Start Changestream Example 4
// 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
=
$db
->
inventory
->
watch
(
$pipeline
);
$changeStream
->
rewind
();
$changeStream
->
rewind
();
...
@@ -1012,11 +1015,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
...
@@ -1012,11 +1015,11 @@ class DocumentationExamplesTest extends FunctionalTestCase
$changeStream
->
next
();
$changeStream
->
next
();
$
next
Change
=
$changeStream
->
current
();
$
second
Change
=
$changeStream
->
current
();
// End Changestream Example 4
// End Changestream Example 4
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$firstChange
);
$this
->
assertNull
(
$
next
Change
);
$this
->
assertNull
(
$
second
Change
);
}
}
public
function
testAggregation_example_1
()
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