|
|
@@ -1106,6 +1106,32 @@ class MongoCollectionTest extends TestCase
|
|
|
$this->assertAttributeSame('foo', 'foo', $object);
|
|
|
}
|
|
|
|
|
|
+ public function testFindAndModifyUpdateWithUpdateOptions()
|
|
|
+ {
|
|
|
+ $id = '54203e08d51d4a1f868b456e';
|
|
|
+ $collection = $this->getCollection();
|
|
|
+
|
|
|
+ $document = ['_id' => new \MongoId($id), 'foo' => 'bar'];
|
|
|
+ $collection->insert($document);
|
|
|
+ $document = $collection->findAndModify(
|
|
|
+ ['_id' => new \MongoId($id)],
|
|
|
+ [],
|
|
|
+ [],
|
|
|
+ [
|
|
|
+ 'update' => ['bar' => 'foo']
|
|
|
+ ]
|
|
|
+ );
|
|
|
+ $this->assertSame('bar', $document['foo']);
|
|
|
+
|
|
|
+ $newCollection = $this->getCheckDatabase()->selectCollection('test');
|
|
|
+ $this->assertSame(1, $newCollection->count());
|
|
|
+ $object = $newCollection->findOne();
|
|
|
+
|
|
|
+ $this->assertNotNull($object);
|
|
|
+ $this->assertAttributeSame('foo', 'bar', $object);
|
|
|
+ $this->assertObjectNotHasAttribute('foo', $object);
|
|
|
+ }
|
|
|
+
|
|
|
public function testFindAndModifyUpdateReplace()
|
|
|
{
|
|
|
$id = '54203e08d51d4a1f868b456e';
|