Skip to content

Commit c7be739

Browse files
committed
PHPLIB-581: Check error labels for retryable writes spec tests
1 parent 160d40d commit c7be739

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/SpecTests/ErrorExpectation.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ public static function fromRetryableWrites(stdClass $outcome)
116116
$o->isExpected = $outcome->error;
117117
}
118118

119+
/* outcome.result will only contain error label assertions if an error
120+
* is expected (i.e. outcome.error is true). */
121+
if ($o->isExpected && isset($outcome->result->errorLabelsContain)) {
122+
if (! self::isArrayOfStrings($outcome->result->errorLabelsContain)) {
123+
throw InvalidArgumentException::invalidType('errorLabelsContain', $outcome->result->errorLabelsContain, 'string[]');
124+
}
125+
$o->includedLabels = $outcome->result->errorLabelsContain;
126+
}
127+
128+
if ($o->isExpected && isset($outcome->result->errorLabelsOmit)) {
129+
if (! self::isArrayOfStrings($outcome->result->errorLabelsOmit)) {
130+
throw InvalidArgumentException::invalidType('errorLabelsOmit', $outcome->result->errorLabelsOmit, 'string[]');
131+
}
132+
$o->excludedLabels = $outcome->result->errorLabelsOmit;
133+
}
134+
119135
return $o;
120136
}
121137

0 commit comments

Comments
 (0)