Skip to content

Commit d41c3f2

Browse files
committed
PHPLIB-96: Fix replacement/upsert test failures for 2.4
1 parent 362a27f commit d41c3f2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/Collection/CrudSpec/FindOneAndReplaceFunctionalTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentBefore
128128
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentBeforeModification()
129129
{
130130
$filter = array('_id' => 4);
131-
$replacement = array('x' => 44);
131+
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
132+
$replacement = array('_id' => 4, 'x' => 44);
132133
$options = array(
133134
'projection' => array('x' => 1, '_id' => 0),
134135
'sort' => array('x' => 1),
@@ -173,7 +174,8 @@ public function testFindOneAndReplaceWhenNoDocumentsMatchReturningDocumentAfterM
173174
public function testFindOneAndReplaceWithUpsertWhenNoDocumentsMatchReturningDocumentAfterModification()
174175
{
175176
$filter = array('_id' => 4);
176-
$replacement = array('x' => 44);
177+
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
178+
$replacement = array('_id' => 4, 'x' => 44);
177179
$options = array(
178180
'projection' => array('x' => 1, '_id' => 0),
179181
'sort' => array('x' => 1),

tests/Collection/CrudSpec/ReplaceOneFunctionalTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithAnIdSpecified()
9494
public function testReplaceOneWithUpsertWhenNoDocumentsMatchWithoutAnIdSpecified()
9595
{
9696
$filter = array('_id' => 4);
97-
$replacement = array('x' => 1);
97+
// Server 2.4 and earlier requires any custom ID to also be in the replacement document
98+
$replacement = array('_id' => 4, 'x' => 1);
9899
$options = array('upsert' => true);
99100

100101
$result = $this->collection->replaceOne($filter, $replacement, $options);

0 commit comments

Comments
 (0)