當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MediaWikiTestCase::dbSetup方法代碼示例

本文整理匯總了PHP中MediaWikiTestCase::dbSetup方法的典型用法代碼示例。如果您正苦於以下問題:PHP MediaWikiTestCase::dbSetup方法的具體用法?PHP MediaWikiTestCase::dbSetup怎麽用?PHP MediaWikiTestCase::dbSetup使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MediaWikiTestCase的用法示例。


在下文中一共展示了MediaWikiTestCase::dbSetup方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 function run(PHPUnit_Framework_TestResult $result = NULL)
 {
     /* Some functions require some kind of caching, and will end up using the db,
      * which we can't allow, as that would open a new connection for mysql.
      * Replace with a HashBag. They would not be going to persist anyway.
      */
     ObjectCache::$instances[CACHE_DB] = new HashBagOStuff();
     if ($this->needsDB()) {
         global $wgDBprefix;
         $this->useTemporaryTables = !$this->getCliArg('use-normal-tables');
         $this->reuseDB = $this->getCliArg('reuse-db');
         $this->db = wfGetDB(DB_MASTER);
         $this->checkDbIsSupported();
         $this->oldTablePrefix = $wgDBprefix;
         if (!self::$dbSetup) {
             $this->initDB();
             self::$dbSetup = true;
         }
         $this->addCoreDBData();
         $this->addDBData();
         parent::run($result);
         $this->resetDB();
     } else {
         parent::run($result);
     }
 }
開發者ID:nischayn22,項目名稱:mediawiki-core,代碼行數:26,代碼來源:MediaWikiTestCase.php

示例2: setupTestDB

 /**
  * Creates an empty skeleton of the wiki database by cloning its structure
  * to equivalent tables using the given $prefix. Then sets MediaWiki to
  * use the new set of tables (aka schema) instead of the original set.
  *
  * This is used to generate a dummy table set, typically consisting of temporary
  * tables, that will be used by tests instead of the original wiki database tables.
  *
  * @since 1.21
  *
  * @note the original table prefix is stored in self::$oldTablePrefix. This is used
  * by teardownTestDB() to return the wiki to using the original table set.
  *
  * @note this method only works when first called. Subsequent calls have no effect,
  * even if using different parameters.
  *
  * @param DatabaseBase $db The database connection
  * @param string $prefix The prefix to use for the new table set (aka schema).
  *
  * @throws MWException If the database table prefix is already $prefix
  */
 public static function setupTestDB(DatabaseBase $db, $prefix)
 {
     global $wgDBprefix;
     if ($wgDBprefix === $prefix) {
         throw new MWException('Cannot run unit tests, the database prefix is already "' . $prefix . '"');
     }
     if (self::$dbSetup) {
         return;
     }
     $tablesCloned = self::listTables($db);
     $dbClone = new CloneDatabase($db, $tablesCloned, $prefix);
     $dbClone->useTemporaryTables(self::$useTemporaryTables);
     self::$dbSetup = true;
     self::$oldTablePrefix = $wgDBprefix;
     if (($db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) {
         CloneDatabase::changePrefix($prefix);
         return;
     } else {
         $dbClone->cloneTableStructure();
     }
     if ($db->getType() == 'oracle') {
         $db->query('BEGIN FILL_WIKI_INFO; END;');
     }
 }
開發者ID:admonkey,項目名稱:mediawiki,代碼行數:45,代碼來源:MediaWikiTestCase.php

示例3: setupTestDB

 /**
  * Creates an empty skeleton of the wiki database by cloning its structure
  * to equivalent tables using the given $prefix. Then sets MediaWiki to
  * use the new set of tables (aka schema) instead of the original set.
  *
  * This is used to generate a dummy table set, typically consisting of temporary
  * tables, that will be used by tests instead of the original wiki database tables.
  *
  * @since 1.21
  *
  * @note the original table prefix is stored in self::$oldTablePrefix. This is used
  * by teardownTestDB() to return the wiki to using the original table set.
  *
  * @note this method only works when first called. Subsequent calls have no effect,
  * even if using different parameters.
  *
  * @param Database $db The database connection
  * @param string $prefix The prefix to use for the new table set (aka schema).
  *
  * @throws MWException If the database table prefix is already $prefix
  */
 public static function setupTestDB(Database $db, $prefix)
 {
     if (self::$dbSetup) {
         return;
     }
     if ($db->tablePrefix() === $prefix) {
         throw new MWException('Cannot run unit tests, the database prefix is already "' . $prefix . '"');
     }
     // TODO: the below should be re-written as soon as LBFactory, LoadBalancer,
     // and Database no longer use global state.
     self::$dbSetup = true;
     if (!self::setupDatabaseWithTestPrefix($db, $prefix)) {
         return;
     }
     // Assuming this isn't needed for External Store database, and not sure if the procedure
     // would be available there.
     if ($db->getType() == 'oracle') {
         $db->query('BEGIN FILL_WIKI_INFO; END;');
     }
 }
開發者ID:paladox,項目名稱:mediawiki,代碼行數:41,代碼來源:MediaWikiTestCase.php


注:本文中的MediaWikiTestCase::dbSetup方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。