Merge "Bug 36785 Special:Shortpages lists only NS_MAIN pages. (pages from all $wgCont...
[lhc/web/wiklou.git] / tests / parser / parserTest.inc
index d9acf6a..deb5c5a 100644 (file)
@@ -140,7 +140,7 @@ class ParserTest {
                        $wgNamespaceAliases, $wgNamespaceProtection, $wgLocalFileRepo,
                        $parserMemc, $wgThumbnailScriptPath, $wgScriptPath,
                        $wgArticlePath, $wgStyleSheetPath, $wgScript, $wgStylePath, $wgExtensionAssetsPath,
-                       $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType;
+                       $wgMainCacheType, $wgMessageCacheType, $wgParserCacheType, $wgLockManagers;
 
                $wgScript = '/index.php';
                $wgScriptPath = '/';
@@ -149,14 +149,27 @@ class ParserTest {
                $wgStylePath = '/skins';
                $wgExtensionAssetsPath = '/extensions';
                $wgThumbnailScriptPath = false;
+               $wgLockManagers = array( array(
+                       'name'          => 'fsLockManager',
+                       'class'         => 'FSLockManager',
+                       'lockDirectory' => wfTempDir() . '/test-repo/lockdir',
+               ) );
                $wgLocalFileRepo = array(
-                       'class' => 'LocalRepo',
-                       'name' => 'local',
-                       'directory' => wfTempDir() . '/test-repo',
-                       'url' => 'http://example.com/images',
-                       'deletedDir' => wfTempDir() . '/test-repo/delete',
-                       'hashLevels' => 2,
+                       'class'           => 'LocalRepo',
+                       'name'            => 'local',
+                       'url'             => 'http://example.com/images',
+                       'hashLevels'      => 2,
                        'transformVia404' => false,
+                       'backend'         => new FSFileBackend( array(
+                               'name'        => 'local-backend',
+                               'lockManager' => 'fsLockManager',
+                               'containerPaths' => array(
+                                       'local-public'  => wfTempDir() . '/test-repo/public',
+                                       'local-thumb'   => wfTempDir() . '/test-repo/thumb',
+                                       'local-temp'    => wfTempDir() . '/test-repo/temp',
+                                       'local-deleted' => wfTempDir() . '/test-repo/deleted',
+                               )
+                       ) )
                );
                $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
                $wgNamespaceAliases['Image'] = NS_FILE;
@@ -619,13 +632,27 @@ class ParserTest {
                        'wgScriptPath' => '/',
                        'wgArticlePath' => '/wiki/$1',
                        'wgActionPaths' => array(),
+                       'wgLockManagers' => array(
+                               'name'          => 'fsLockManager',
+                               'class'         => 'FSLockManager',
+                               'lockDirectory' => $this->uploadDir . '/lockdir',
+                       ),
                        'wgLocalFileRepo' => array(
                                'class' => 'LocalRepo',
                                'name' => 'local',
-                               'directory' => $this->uploadDir,
                                'url' => 'http://example.com/images',
                                'hashLevels' => 2,
                                'transformVia404' => false,
+                               'backend'         => new FSFileBackend( array(
+                                       'name'        => 'local-backend',
+                                       'lockManager' => 'fsLockManager',
+                                       'containerPaths' => array(
+                                               'local-public'  => $this->uploadDir,
+                                               'local-thumb'   => $this->uploadDir . '/thumb',
+                                               'local-temp'    => $this->uploadDir . '/temp',
+                                               'local-deleted' => $this->uploadDir . '/delete',
+                                       )
+                               ) )
                        ),
                        'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ),
                        'wgStylePath' => '/skins',
@@ -715,7 +742,7 @@ class ParserTest {
         * Some of these probably aren't necessary.
         */
        private function listTables() {
-               $tables = array( 'user', 'user_properties', 'page', 'page_restrictions',
+               $tables = array( 'user', 'user_properties', 'user_former_groups', 'page', 'page_restrictions',
                        'protected_titles', 'revision', 'text', 'pagelinks', 'imagelinks',
                        'categorylinks', 'templatelinks', 'externallinks', 'langlinks', 'iwlinks',
                        'site_stats', 'hitcounter',     'ipblocks', 'image', 'oldimage',
@@ -820,7 +847,6 @@ class ParserTest {
                                   'iw_local'  => 1 ),
                        ) );
 
-
                # Update certain things in site_stats
                $this->db->insert( 'site_stats', array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ) );
 
@@ -935,6 +961,8 @@ class ParserTest {
         */
        private function teardownGlobals() {
                RepoGroup::destroySingleton();
+               FileBackendGroup::destroySingleton();
+               LockManagerGroup::destroySingleton();
                LinkCache::singleton()->clear();
 
                foreach ( $this->savedGlobals as $var => $val ) {
@@ -1145,30 +1173,35 @@ class ParserTest {
         * @param $name String: the title, including any prefix
         * @param $text String: the article text
         * @param $line Integer: the input line number, for reporting errors
+        * @param $ignoreDuplicate Boolean: whether to silently ignore duplicate pages
         */
-       static public function addArticle( $name, $text, $line = 'unknown' ) {
+       static public function addArticle( $name, $text, $line = 'unknown', $ignoreDuplicate = '' ) {
                global $wgCapitalLinks;
 
-               $text = self::chomp($text);
-
                $oldCapitalLinks = $wgCapitalLinks;
                $wgCapitalLinks = true; // We only need this from SetupGlobals() See r70917#c8637
 
+               $text = self::chomp( $text );
                $name = self::chomp( $name );
+
                $title = Title::newFromText( $name );
 
                if ( is_null( $title ) ) {
-                       throw new MWException( "invalid title ('$name' => '$title') at line $line\n" );
+                       throw new MWException( "invalid title '$name' at line $line\n" );
                }
 
-               $aid = $title->getArticleID( Title::GAID_FOR_UPDATE );
+               $page = WikiPage::factory( $title );
+               $page->loadPageData( 'fromdbmaster' );
 
-               if ( $aid != 0 ) {
-                       throw new MWException( "duplicate article '$name' at line $line\n" );
+               if ( $page->exists() ) {
+                       if ( $ignoreDuplicate == 'ignoreduplicate' ) {
+                               return;
+                       } else {
+                               throw new MWException( "duplicate article '$name' at line $line\n" );
+                       }
                }
 
-               $art = new Article( $title );
-               $art->doEdit( $text, '', EDIT_NEW );
+               $page->doEdit( $text, '', EDIT_NEW );
 
                $wgCapitalLinks = $oldCapitalLinks;
        }