diff --git a/tests/KeyValueBinaryOperationsTest.php b/tests/KeyValueBinaryOperationsTest.php index 7113e409..4d5ba36c 100644 --- a/tests/KeyValueBinaryOperationsTest.php +++ b/tests/KeyValueBinaryOperationsTest.php @@ -55,10 +55,15 @@ public function testAppendCasMismatch() $id = $this->uniqueId(); $res = $collection->upsert($id, "foo", UpsertOptions::build()->transcoder(RawBinaryTranscoder::getInstance())); - $cas = (string)((int)$res->cas() + 1); + + // Replaces the last hex digit of the CAS to ensure CAS mismatch + $cas = $res->cas(); + $last = substr($cas, -1); + $newLast = $last === '0' ? '1' : '0'; + $invalidCas = substr_replace($cas, $newLast, -1); $this->expectException(CasMismatchException::class); - $collection->binary()->append($id, "bar", AppendOptions::build()->cas($cas)); + $collection->binary()->append($id, "bar", AppendOptions::build()->cas($invalidCas)); } public function testPrependAddsBytesToTheBeginningOfTheDocument() @@ -85,10 +90,15 @@ public function testPrependCasMismatch() $id = $this->uniqueId(); $res = $collection->upsert($id, "foo", UpsertOptions::build()->transcoder(RawBinaryTranscoder::getInstance())); - $cas = (string)((int)((int)$res->cas() + 1)); + + // Replaces the last hex digit of the CAS to ensure CAS mismatch + $cas = $res->cas(); + $last = substr($cas, -1); + $newLast = $last === '0' ? '1' : '0'; + $invalidCas = substr_replace($cas, $newLast, -1); $this->expectException(CasMismatchException::class); - $collection->binary()->prepend($id, "bar", PrependOptions::build()->cas($cas)); + $collection->binary()->prepend($id, "bar", PrependOptions::build()->cas($invalidCas)); } public function testAppendThrowsExceptionIfDocumentDoesNotExist()