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
c457ecec
Unverified
Commit
c457ecec
authored
Apr 02, 2020
by
Andreas Braun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-540: Ensure that the WriteConcernError "errInfo" object is propagated
parent
90ad22ab
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
CrudSpecTest.php
tests/SpecTests/CrudSpecTest.php
+42
-0
No files found.
tests/SpecTests/CrudSpecTest.php
View file @
c457ecec
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
namespace
MongoDB\Tests\SpecTests
;
namespace
MongoDB\Tests\SpecTests
;
use
MongoDB\Client
;
use
MongoDB\Driver\Exception\BulkWriteException
;
use
stdClass
;
use
stdClass
;
use
function
basename
;
use
function
basename
;
use
function
file_get_contents
;
use
function
file_get_contents
;
...
@@ -111,4 +113,44 @@ class CrudSpecTest extends FunctionalTestCase
...
@@ -111,4 +113,44 @@ class CrudSpecTest extends FunctionalTestCase
return
$testArgs
;
return
$testArgs
;
}
}
/**
* Prose test 1: "errInfo" is propagated
*/
public
function
testErrInfoIsPropagated
()
{
$runOn
=
[(
object
)
[
'minServerVersion'
=>
'4.0.0'
]];
$this
->
checkServerRequirements
(
$runOn
);
$errInfo
=
(
object
)
[
'writeConcern'
=>
(
object
)
[
'w'
=>
2
,
'wtimeout'
=>
0
,
'provenance'
=>
'clientSupplied'
,
],
];
$this
->
configureFailPoint
([
'configureFailPoint'
=>
'failCommand'
,
'mode'
=>
[
'times'
=>
1
],
'data'
=>
[
'failCommands'
=>
[
'insert'
],
'writeConcernError'
=>
[
'code'
=>
100
,
'codeName'
=>
'UnsatisfiableWriteConcern'
,
'errmsg'
=>
'Not enough data-bearing nodes'
,
'errInfo'
=>
$errInfo
,
],
],
]);
$client
=
new
Client
(
static
::
getUri
());
try
{
$client
->
selectCollection
(
$this
->
getDatabaseName
(),
$this
->
getCollectionName
())
->
insertOne
([
'fail'
=>
1
]);
$this
->
fail
(
'Expected insert command to fail'
);
}
catch
(
BulkWriteException
$e
)
{
self
::
assertEquals
(
$errInfo
,
$e
->
getWriteResult
()
->
getWriteConcernError
()
->
getInfo
());
}
}
}
}
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