当前位置: 首页>>代码示例>>PHP>>正文


PHP DbHelper::disconnectDatabase方法代码示例

本文整理汇总了PHP中Piwik\DbHelper::disconnectDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP DbHelper::disconnectDatabase方法的具体用法?PHP DbHelper::disconnectDatabase怎么用?PHP DbHelper::disconnectDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\DbHelper的用法示例。


在下文中一共展示了DbHelper::disconnectDatabase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: performSetUp

 public function performSetUp($setupEnvironmentOnly = false)
 {
     // TODO: don't use static var, use test env var for this
     TestingEnvironmentManipulator::$extraPluginsToLoad = $this->extraPluginsToLoad;
     $this->dbName = $this->getDbName();
     if ($this->persistFixtureData) {
         $this->dropDatabaseInSetUp = false;
         $this->dropDatabaseInTearDown = false;
         $this->overwriteExisting = false;
         $this->removeExistingSuperUser = false;
     }
     $testEnv = $this->getTestEnvironment();
     $testEnv->testCaseClass = $this->testCaseClass;
     $testEnv->fixtureClass = get_class($this);
     $testEnv->dbName = $this->dbName;
     $testEnv->extraDiEnvironments = $this->extraDiEnvironments;
     foreach ($this->extraTestEnvVars as $name => $value) {
         $testEnv->{$name} = $value;
     }
     $testEnv->save();
     $this->createEnvironmentInstance();
     if ($this->dbName === false) {
         // must be after test config is created
         $this->dbName = self::getConfig()->database['dbname'];
     }
     try {
         static::connectWithoutDatabase();
         if ($this->dropDatabaseInSetUp || $this->resetPersistedFixture) {
             $this->dropDatabase();
         }
         DbHelper::createDatabase($this->dbName);
         DbHelper::disconnectDatabase();
         Tracker::disconnectCachedDbConnection();
         // reconnect once we're sure the database exists
         self::getConfig()->database['dbname'] = $this->dbName;
         Db::createDatabaseObject();
         Db::get()->query("SET wait_timeout=28800;");
         DbHelper::createTables();
         self::getPluginManager()->unloadPlugins();
     } catch (Exception $e) {
         static::fail("TEST INITIALIZATION FAILED: " . $e->getMessage() . "\n" . $e->getTraceAsString());
     }
     include "DataFiles/Providers.php";
     if (!$this->isFixtureSetUp()) {
         DbHelper::truncateAllTables();
     }
     // We need to be SU to create websites for tests
     Access::getInstance()->setSuperUserAccess();
     Cache::deleteTrackerCache();
     self::resetPluginsInstalledConfig();
     $testEnvironment = $this->getTestEnvironment();
     static::loadAllPlugins($testEnvironment, $this->testCaseClass, $this->extraPluginsToLoad);
     self::updateDatabase();
     self::installAndActivatePlugins($testEnvironment);
     $_GET = $_REQUEST = array();
     $_SERVER['HTTP_REFERER'] = '';
     FakeAccess::$superUserLogin = 'superUserLogin';
     File::$invalidateOpCacheBeforeRead = true;
     if ($this->configureComponents) {
         IPAnonymizer::deactivate();
         $dntChecker = new DoNotTrackHeaderChecker();
         $dntChecker->deactivate();
     }
     if ($this->createSuperUser) {
         self::createSuperUser($this->removeExistingSuperUser);
         if (!Access::getInstance() instanceof FakeAccess) {
             $this->loginAsSuperUser();
         }
         APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en');
     }
     SettingsPiwik::overwritePiwikUrl(self::getTestRootUrl());
     if ($setupEnvironmentOnly) {
         return;
     }
     PiwikCache::getTransientCache()->flushAll();
     if ($this->overwriteExisting || !$this->isFixtureSetUp()) {
         $this->setUp();
         $this->markFixtureSetUp();
         $this->log("Database {$this->dbName} marked as successfully set up.");
     } else {
         $this->log("Using existing database {$this->dbName}.");
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:83,代码来源:Fixture.php

示例2: performSetUp

 public function performSetUp($setupEnvironmentOnly = false)
 {
     try {
         if ($this->createConfig) {
             Config::getInstance()->setTestEnvironment();
         }
         $this->dbName = $this->getDbName();
         if ($this->persistFixtureData) {
             $this->dropDatabaseInSetUp = false;
             $this->dropDatabaseInTearDown = false;
             $this->overwriteExisting = false;
             $this->removeExistingSuperUser = false;
             Config::getInstance()->database_tests['dbname'] = Config::getInstance()->database['dbname'] = $this->dbName;
             $this->getTestEnvironment()->dbName = $this->dbName;
         }
         if ($this->dbName === false) {
             // must be after test config is created
             $this->dbName = Config::getInstance()->database['dbname'];
         }
         static::connectWithoutDatabase();
         if ($this->dropDatabaseInSetUp || $this->resetPersistedFixture) {
             $this->dropDatabase();
         }
         DbHelper::createDatabase($this->dbName);
         DbHelper::disconnectDatabase();
         // reconnect once we're sure the database exists
         Config::getInstance()->database['dbname'] = $this->dbName;
         Db::createDatabaseObject();
         Db::get()->query("SET wait_timeout=28800;");
         DbHelper::createTables();
         \Piwik\Plugin\Manager::getInstance()->unloadPlugins();
     } catch (Exception $e) {
         static::fail("TEST INITIALIZATION FAILED: " . $e->getMessage() . "\n" . $e->getTraceAsString());
     }
     include "DataFiles/SearchEngines.php";
     include "DataFiles/Socials.php";
     include "DataFiles/Languages.php";
     include "DataFiles/Countries.php";
     include "DataFiles/Currencies.php";
     include "DataFiles/LanguageToCountry.php";
     include "DataFiles/Providers.php";
     if (!$this->isFixtureSetUp()) {
         DbHelper::truncateAllTables();
     }
     static::createAccessInstance();
     // We need to be SU to create websites for tests
     Piwik::setUserHasSuperUserAccess();
     Cache::deleteTrackerCache();
     static::loadAllPlugins($this->getTestEnvironment(), $this->testCaseClass, $this->extraPluginsToLoad);
     self::updateDatabase();
     self::installAndActivatePlugins();
     $_GET = $_REQUEST = array();
     $_SERVER['HTTP_REFERER'] = '';
     // Make sure translations are loaded to check messages in English
     if ($this->loadTranslations) {
         Translate::reloadLanguage('en');
         APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en');
     }
     FakeAccess::$superUserLogin = 'superUserLogin';
     \Piwik\SettingsPiwik::$cachedKnownSegmentsToArchive = null;
     \Piwik\CacheFile::$invalidateOpCacheBeforeRead = true;
     if ($this->configureComponents) {
         \Piwik\Plugins\PrivacyManager\IPAnonymizer::deactivate();
         \Piwik\Plugins\PrivacyManager\DoNotTrackHeaderChecker::deactivate();
     }
     if ($this->createSuperUser) {
         self::createSuperUser($this->removeExistingSuperUser);
     }
     if ($setupEnvironmentOnly) {
         return;
     }
     $this->getTestEnvironment()->save();
     $this->getTestEnvironment()->executeSetupTestEnvHook();
     Piwik_TestingEnvironment::addSendMailHook();
     if ($this->overwriteExisting || !$this->isFixtureSetUp()) {
         $this->setUp();
         $this->markFixtureSetUp();
         $this->log("Database {$this->dbName} marked as successfully set up.");
     } else {
         $this->log("Using existing database {$this->dbName}.");
     }
 }
开发者ID:igorclark,项目名称:piwik,代码行数:82,代码来源:Fixture.php

示例3: destroyDatabaseObject

 /**
  * Disconnects and destroys the database connection.
  *
  * For tests.
  */
 public static function destroyDatabaseObject()
 {
     DbHelper::disconnectDatabase();
     self::$connection = null;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:10,代码来源:Db.php


注:本文中的Piwik\DbHelper::disconnectDatabase方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。