diff --git a/src/MockCollection.php b/src/MockCollection.php index f823c8a..2ca8e8c 100644 --- a/src/MockCollection.php +++ b/src/MockCollection.php @@ -482,7 +482,11 @@ public function listIndexes(array $options = []) public function replaceOne($filter, $replacement, array $options = []) { - // TODO: Implement this function + $shouldReplace = $this->findOne($filter) || ($options['upsert'] ?? false); + if ($shouldReplace) { + $this->deleteOne($filter); + $this->insertOne($replacement); + } } public function withOptions(array $options = [])