Skip to content

PHPLIB-909: Add more error response tests #1012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 6, 2022

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Dec 6, 2022

This is a follow-up to PHPLIB-909 that removes the 4 previously skipped tests now that WriteResult exposes the errors as sent from the server. Since there may be multiple replies, I decided to only check the first one - another option would be to pass the test if any error response matches, but I'm not sure if that's feasible.

@alcaeus alcaeus requested a review from jmikola December 6, 2022 07:57
Copy link
Member

@jmikola jmikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CI is green.

} elseif ($e instanceof WriteException) {
$writeErrors = $e->getWriteResult()->getErrorReplies();
assertCount(1, $writeErrors);
assertThat($writeErrors[0], $this->matchesResultDocument, 'WriteException result document matches');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't addressed in the spec (see: expectedError) but this is the correct approach. I intentionally only issued to single commands in the corresponding write command tests for this reason.

@alcaeus alcaeus merged commit 4c090a8 into mongodb:master Dec 6, 2022
@alcaeus alcaeus deleted the error-response-tests branch December 6, 2022 08:58
@jmikola
Copy link
Member

jmikola commented Mar 18, 2023

Since there may be multiple replies, I decided to only check the first one - another option would be to pass the test if any error response matches, but I'm not sure if that's feasible.

I was just reminded of this PR. This assumption is consistent with what was done in libmongoc. See: mongodb/mongo-c-driver#1144 (comment) and my comment in DRIVERS-1547.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants