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
d44bd162
Unverified
Commit
d44bd162
authored
Oct 02, 2019
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-481: Add functional test for pipeline-style bulk updates
parent
738022df
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
BulkWriteFunctionalTest.php
tests/Operation/BulkWriteFunctionalTest.php
+30
-0
No files found.
tests/Operation/BulkWriteFunctionalTest.php
View file @
d44bd162
...
@@ -295,6 +295,36 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
...
@@ -295,6 +295,36 @@ class BulkWriteFunctionalTest extends FunctionalTestCase
);
);
}
}
public
function
testBulkWriteWithPipelineUpdates
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'4.2.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'Pipeline-style updates are not supported'
);
}
$this
->
createFixtures
(
4
);
$ops
=
[
[
'updateOne'
=>
[[
'_id'
=>
2
],
[[
'$addFields'
=>
[
'y'
=>
2
]]]]],
[
'updateMany'
=>
[[
'_id'
=>
[
'$gt'
=>
2
]],
[[
'$addFields'
=>
[
'y'
=>
'$_id'
]]]]],
];
$operation
=
new
BulkWrite
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
(),
$ops
);
$result
=
$operation
->
execute
(
$this
->
getPrimaryServer
());
$this
->
assertInstanceOf
(
BulkWriteResult
::
class
,
$result
);
$this
->
assertSame
(
3
,
$result
->
getMatchedCount
());
$this
->
assertSame
(
3
,
$result
->
getModifiedCount
());
$expected
=
[
[
'_id'
=>
1
,
'x'
=>
11
],
[
'_id'
=>
2
,
'x'
=>
22
,
'y'
=>
2
],
[
'_id'
=>
3
,
'x'
=>
33
,
'y'
=>
3
],
[
'_id'
=>
4
,
'x'
=>
44
,
'y'
=>
4
],
];
$this
->
assertSameDocuments
(
$expected
,
$this
->
collection
->
find
());
}
/**
/**
* Create data fixtures.
* Create data fixtures.
*
*
...
...
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