getMongoDB() public method

public getMongoDB ( ) : MongoDB
return MongoDB
Example #1
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Error setting write concern
  */
 public function testSetWriteConcern_Error()
 {
     $mongoCollectionMock = $this->getMock('\\MongoCollection', array('setWriteConcern'), array($this->database->getMongoDB(), 'test'));
     $mongoCollectionMock->expects($this->once())->method('setWriteConcern')->will($this->returnValue(false));
     $collection = new Collection($this->database, $mongoCollectionMock);
     $collection->setWriteConcern(1);
 }
Example #2
0
 /**
  * Get native collection instance of mongo driver
  * 
  * @return \MongoCollection
  */
 public function getMongoCollection()
 {
     if (empty($this->collection)) {
         $mongoCollectionClassName = $this->mongoCollectionClassName;
         $this->collection = new $mongoCollectionClassName($this->database->getMongoDB(), $this->collectionName);
     }
     return $this->collection;
 }
Example #3
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Error deleting file: some_error: Some error message
  */
 public function testDeleteFileById_WithAcknowledgedWriteConcern()
 {
     $mongoGridFsMock = $this->getMock('\\MongoGridFS', array('delete'), array($this->database->getMongoDB(), 'images'));
     $mongoGridFsMock->expects($this->once())->method('delete')->will($this->returnValue(array('ok' => (double) 0, 'err' => 'some_error', 'errmsg' => 'Some error message')));
     $gridFS = new GridFS($this->database, $mongoGridFsMock);
     $id = $gridFS->storeBytes('data');
     $gridFS->deleteFileById($id);
 }
Example #4
0
 protected function initCollection($collection)
 {
     // init mongo collection
     if ($collection instanceof \MongoCollection) {
         $this->_mongoCollection = $collection;
     } else {
         $this->_mongoCollection = $this->_database->getMongoDB()->selectCollection($collection);
     }
 }