/** * Move selected documents to another collection. * Dociuments will be removed from source collection only after * copying them to target collection. * * @param type $targetCollectionName * @param type $targetDatabaseName Target database name. If not specified - use current */ public function moveToCollection($targetCollectionName, $targetDatabaseName = null) { // copy to target $this->copyToCollection($targetCollectionName, $targetDatabaseName); // remove from source $this->collection->deleteDocuments($this->expression); }
/** * @expectedException \Sokil\Mongo\Exception * @expectedExceptionMessage Error removing documents from collection: Some strange error */ public function testDeleteDocuments_ErrorDeletingDocuments() { $this->collectionMock = $this->getMock('\\MongoCollection', array('remove'), array($this->database->getMongoDB(), 'phpmongo_test_collection')); $this->collectionMock->expects($this->once())->method('remove')->will($this->returnValue(array('ok' => (double) 0, 'err' => 'Some strange error'))); $this->collection = new Collection($this->database, $this->collectionMock); $this->collection->createDocument(array('param' => 'value'))->save(); $this->collection->deleteDocuments($this->collection->expression()->where('param', 'value')); }