Permalink
Browse files

Regression test so that upserts never replace document data

  • Loading branch information...
1 parent 374efd4 commit 67fa0c526f0a21bb57680ebb8e49699d44b3fcc2 @jmikola jmikola committed Jan 9, 2014
Showing with 15 additions and 0 deletions.
  1. +15 −0 tests/Doctrine/ODM/MongoDB/Tests/Functional/DocumentPersisterTest.php
@@ -26,6 +26,21 @@ public function setUp()
$this->documentPersister = $this->uow->getDocumentPersister($this->class);
}
+ public function testExecuteUpsertShouldNeverReplaceDocuments()
+ {
+ $originalData = $this->dm->getDocumentCollection($this->class)->findOne();
+
+ $document = new DocumentPersisterTestDocument();
+ $document->id = $originalData['_id'];
+
+ $this->dm->persist($document);
+ $this->dm->flush();
+
+ $updatedData = $this->dm->getDocumentCollection($this->class)->findOne(array('_id' => $originalData['_id']));
+
+ $this->assertEquals($originalData, $updatedData);
+ }
+
public function testLoadPreparesCriteriaAndSort()
{
$criteria = array('name' => array('$in' => array('a', 'b')));

0 comments on commit 67fa0c5

Please sign in to comment.