public function testDropDB() { $m = new Mongo(); $mem = memory_get_usage(true); for ($i = 0; $i < 10000; $i++) { $m->dropDB("phpunit"); } $this->assertEquals($mem, memory_get_usage(true)); $db = $m->selectDB("phpunit"); for ($i = 0; $i < 10000; $i++) { $m->dropDB($db); } }
protected function tearDown() { if (!empty($this->_connectionString) && extension_loaded('mongo')) { $this->_model = null; $connection = new \Mongo($this->_connectionString); $connection->dropDB($this->_dbName); } }
/** * Drops a database */ public function dropDb() { $this->mongo->drop(); return; if (!isset($this->_db)) { $this->_db = $this->_mongo(); } $this->_db->dropDB($this->mongo); }
/** @proxy */ public function dropDatabase($database) { if ($this->eventManager->hasListeners(Events::preDropDatabase)) { $this->eventManager->dispatchEvent(Events::preDropDatabase, new EventArgs($this, $database)); } $this->initialize(); $result = $this->mongo->dropDB($database); if ($this->eventManager->hasListeners(Events::postDropDatabase)) { $this->eventManager->dispatchEvent(Events::postDropDatabase, new EventArgs($this, $result)); } return $result; }
public function testDropDB() { $this->object->connect(); $c = $this->object->selectCollection("temp", "foo"); $c->insert(array('x' => 1)); $this->object->dropDB("temp"); $this->assertEquals($c->findOne(), NULL); $db = $this->object->selectDB("temp"); $c->insert(array('x' => 1)); $this->object->dropDB($db); $this->assertEquals($c->findOne(), NULL); }
public function testDropDB() { $this->object->connect(); $c = $this->object->selectCollection("temp", "foo"); $result = $c->db->command(array("ismaster" => 1)); if (!$result['ismaster']) { $this->markTestSkipped("can't test writes on slave"); return; } $c->insert(array('x' => 1)); $this->object->dropDB("temp"); $this->assertEquals($c->findOne(), NULL); $db = $this->object->selectDB("temp"); $c->insert(array('x' => 1)); $this->object->dropDB($db); $this->assertEquals($c->findOne(), NULL); }
/** * Clean some cache records (protected method used for recursive stuff) * * Available modes are : * \Zend_Cache::CLEANING_MODE_ALL (default) => remove all cache entries ($tags is not used) * \Zend_Cache::CLEANING_MODE_OLD => remove too old cache entries ($tags is not used) * \Zend_Cache::CLEANING_MODE_MATCHING_TAG => remove cache entries matching all given tags * ($tags can be an array of strings or a single string) * \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG => remove cache entries not {matching one of the given tags} * ($tags can be an array of strings or a single string) * \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG => remove cache entries matching any given tags * ($tags can be an array of strings or a single string) * * @param string $dir Directory to clean * @param string $mode Clean mode * @param array $tags Array of tags * @throws \Zend_Cache_Exception * @return boolean True if no problem */ public function clean($mode = \Zend_Cache::CLEANING_MODE_ALL, $tags = []) { switch ($mode) { case \Zend_Cache::CLEANING_MODE_ALL: return $this->_conn->dropDB($this->_options['dbname']); break; case \Zend_Cache::CLEANING_MODE_OLD: return $this->_collection->remove(['expire' => ['$lt' => time()]]); break; case \Zend_Cache::CLEANING_MODE_MATCHING_TAG: return $this->_collection->remove(['t' => ['$all' => $tags]]); break; case \Zend_Cache::CLEANING_MODE_NOT_MATCHING_TAG: return $this->_collection->remove(['t' => ['$nin' => $tags]]); break; case \Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG: return $this->_collection->remove(['t' => ['$in' => $tags]]); break; default: \Zend_Cache::throwException('Invalid mode for clean() method'); break; } }