public function testConstructor() { $oMongo = new \Lampcms\Mongo\DB($this->Registry->Ini); $this->assertEquals('LAMPCMS_TEST', $oMongo->getDbName()); $this->assertTrue($oMongo->getMongo() instanceof \Mongo); $this->assertTrue($oMongo->getDb() instanceof \MongoDB); }
public function __destruct() { if (!$this->persistDB) { $Registry = new Registry(); try { $Ini = $Registry->Ini; $aConfig = $Ini->getSection('MONGO'); $realDbname = $aConfig['db']; $oMongo = new \Lampcms\Mongo\DB($Ini); } catch (\Exception $e) { return; } /** * Being Careful - if for some reason * the dbname used for this MongoInstance * is our actual database then don't do anything * */ if ($realDbname !== $oMongo->getDbName()) { echo ' Test complete. You can remove the test mongo database: ' . $oMongo->getDbName(); //$oMongo->getDb()->drop(); } else { echo 'Not going to drop db. This is the actual DB!'; } } }