public static function setUpBeforeClass()
 {
     if (!class_exists('\\Mongo')) {
         return;
     }
     parent::setUpBeforeClass();
     self::$conn = self::createConnection();
     self::$conn->task_queue->drop();
     self::$conn->createCollection('task_queue');
 }
Exemple #2
0
 protected function setUp()
 {
     if (!class_exists('Mongo')) {
         $this->markTestSkipped('Mongo is not installed');
     }
     $mongo = new \MongoClient();
     $this->module = new MongoDb(make_container());
     $this->module->_setConfig($this->mongoConfig);
     $this->module->_initialize();
     $this->db = $mongo->selectDB('test');
     $this->userCollection = $this->db->createCollection('users');
     $this->userCollection->insert(array('id' => 1, 'email' => '*****@*****.**'));
 }
 protected function setUp()
 {
     if (!class_exists('Mongo')) {
         $this->markTestSkipped('Mongo is not installed');
     }
     $mongo = new \Mongo();
     $this->module = new MongoDb();
     $this->module->_setConfig($this->mongoConfig);
     $this->module->_initialize();
     $this->db = $mongo->selectDB('test');
     $this->userCollection = $this->db->createCollection('users');
     $user_id = $this->userCollection->insert(array('id' => 1, 'email' => '*****@*****.**'));
     $this->assertInternalType('string', $user_id);
 }
 /**
  * getCollection get a handle to the collection object
  *
  * @access private
  * @return MongoCollection the mongo collection class reffering to the
  *                         appropriate dataset
  */
 private function getCollection()
 {
     // if the collection is not already cached
     if (empty($this->collection)) {
         // selects the collection if it exists
         $this->collection = $this->db->selectCollection(self::COLLECTION);
         // or creates a new one if it doesn't
         if (empty($this->collection)) {
             $this->collection = $this->db->createCollection(self::COLLECTION);
         }
     }
     return $this->collection;
 }