From 08aa4418c30cfc18ccc69a0f0f9cb9e17be6c196 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 12 Aug 2013 09:28:15 +0200 Subject: Update to MediaWiki 1.21.1 --- .../phpunit/includes/parser/MagicVariableTest.php | 201 ----- .../includes/parser/MediaWikiParserTest.php | 36 - tests/phpunit/includes/parser/NewParserTest.php | 895 --------------------- .../phpunit/includes/parser/ParserMethodsTest.php | 33 - .../phpunit/includes/parser/ParserPreloadTest.php | 67 -- tests/phpunit/includes/parser/PreprocessorTest.php | 233 ------ tests/phpunit/includes/parser/TagHooksTest.php | 77 -- 7 files changed, 1542 deletions(-) delete mode 100644 tests/phpunit/includes/parser/MagicVariableTest.php delete mode 100644 tests/phpunit/includes/parser/MediaWikiParserTest.php delete mode 100644 tests/phpunit/includes/parser/NewParserTest.php delete mode 100644 tests/phpunit/includes/parser/ParserMethodsTest.php delete mode 100644 tests/phpunit/includes/parser/ParserPreloadTest.php delete mode 100644 tests/phpunit/includes/parser/PreprocessorTest.php delete mode 100644 tests/phpunit/includes/parser/TagHooksTest.php (limited to 'tests/phpunit/includes/parser') diff --git a/tests/phpunit/includes/parser/MagicVariableTest.php b/tests/phpunit/includes/parser/MagicVariableTest.php deleted file mode 100644 index 31645313..00000000 --- a/tests/phpunit/includes/parser/MagicVariableTest.php +++ /dev/null @@ -1,201 +0,0 @@ -testParser = new Parser(); - $this->testParser->Options( new ParserOptions() ); - - # initialize parser output - $this->testParser->clearState(); - - # Needs a title to do magic word stuff - $title = Title::newFromText( 'Tests' ); - $title->mRedirect = false; # Else it needs a db connection just to check if it's a redirect (when deciding the page language) - - $this->testParser->setTitle( $title ); - } - - /** destroy parser (TODO: is it really neded?)*/ - function tearDown() { - unset( $this->testParser ); - } - - ############### TESTS ############################################# - # @todo FIXME: - # - those got copy pasted, we can probably make them cleaner - # - tests are lacking useful messages - - # day - - /** @dataProvider MediaWikiProvide::Days */ - function testCurrentdayIsUnPadded( $day ) { - $this->assertUnPadded( 'currentday', $day ); - } - /** @dataProvider MediaWikiProvide::Days */ - function testCurrentdaytwoIsZeroPadded( $day ) { - $this->assertZeroPadded( 'currentday2', $day ); - } - /** @dataProvider MediaWikiProvide::Days */ - function testLocaldayIsUnPadded( $day ) { - $this->assertUnPadded( 'localday', $day ); - } - /** @dataProvider MediaWikiProvide::Days */ - function testLocaldaytwoIsZeroPadded( $day ) { - $this->assertZeroPadded( 'localday2', $day ); - } - - # month - - /** @dataProvider MediaWikiProvide::Months */ - function testCurrentmonthIsZeroPadded( $month ) { - $this->assertZeroPadded( 'currentmonth', $month ); - } - /** @dataProvider MediaWikiProvide::Months */ - function testCurrentmonthoneIsUnPadded( $month ) { - $this->assertUnPadded( 'currentmonth1', $month ); - } - /** @dataProvider MediaWikiProvide::Months */ - function testLocalmonthIsZeroPadded( $month ) { - $this->assertZeroPadded( 'localmonth', $month ); - } - /** @dataProvider MediaWikiProvide::Months */ - function testLocalmonthoneIsUnPadded( $month ) { - $this->assertUnPadded( 'localmonth1', $month ); - } - - - # revision day - - /** @dataProvider MediaWikiProvide::Days */ - function testRevisiondayIsUnPadded( $day ) { - $this->assertUnPadded( 'revisionday', $day ); - } - /** @dataProvider MediaWikiProvide::Days */ - function testRevisiondaytwoIsZeroPadded( $day ) { - $this->assertZeroPadded( 'revisionday2', $day ); - } - - # revision month - - /** @dataProvider MediaWikiProvide::Months */ - function testRevisionmonthIsZeroPadded( $month ) { - $this->assertZeroPadded( 'revisionmonth', $month ); - } - /** @dataProvider MediaWikiProvide::Months */ - function testRevisionmonthoneIsUnPadded( $month ) { - $this->assertUnPadded( 'revisionmonth1', $month ); - } - - /** - * Rough tests for {{SERVERNAME}} magic word - * Bug 31176 - */ - function testServernameFromDifferentProtocols() { - global $wgServer; - $saved_wgServer= $wgServer; - - $wgServer = 'http://localhost/'; - $this->assertMagic( 'localhost', 'servername' ); - $wgServer = 'https://localhost/'; - $this->assertMagic( 'localhost', 'servername' ); - $wgServer = '//localhost/'; # bug 31176 - $this->assertMagic( 'localhost', 'servername' ); - - $wgServer = $saved_wgServer; - } - - ############### HELPERS ############################################ - - /** assertion helper expecting a magic output which is zero padded */ - PUBLIC function assertZeroPadded( $magic, $value ) { - $this->assertMagicPadding( $magic, $value, '%02d' ); - } - - /** assertion helper expecting a magic output which is unpadded */ - PUBLIC function assertUnPadded( $magic, $value ) { - $this->assertMagicPadding( $magic, $value, '%d' ); - } - - /** - * Main assertion helper for magic variables padding - * @param $magic string Magic variable name - * @param $value mixed Month or day - * @param $format string sprintf format for $value - */ - private function assertMagicPadding( $magic, $value, $format ) { - # Initialize parser timestamp as year 2010 at 12h34 56s. - # month and day are given by the caller ($value). Month < 12! - if( $value > 12 ) { $month = $value % 12; } - else { $month = $value; } - - $this->setParserTS( - sprintf( '2010%02d%02d123456', $month, $value ) - ); - - # please keep the following commented line of code. It helps debugging. - //print "\nDEBUG (value $value):" . sprintf( '2010%02d%02d123456', $value, $value ) . "\n"; - - # format expectation and test it - $expected = sprintf( $format, $value ); - $this->assertMagic( $expected, $magic ); - } - - /** helper to set the parser timestamp and revision timestamp */ - private function setParserTS( $ts ) { - $this->testParser->Options()->setTimestamp( $ts ); - $this->testParser->mRevisionTimestamp = $ts; - } - - /** - * Assertion helper to test a magic variable output - */ - private function assertMagic( $expected, $magic ) { - if( in_array( $magic, $this->expectedAsInteger ) ) { - $expected = (int) $expected; - } - - # Generate a message for the assertion - $msg = sprintf( "Magic %s should be <%s:%s>", - $magic, - $expected, - gettype( $expected ) - ); - - $this->assertSame( - $expected, - $this->testParser->getVariableValue( $magic ), - $msg - ); - } -} diff --git a/tests/phpunit/includes/parser/MediaWikiParserTest.php b/tests/phpunit/includes/parser/MediaWikiParserTest.php deleted file mode 100644 index 6a6fded1..00000000 --- a/tests/phpunit/includes/parser/MediaWikiParserTest.php +++ /dev/null @@ -1,36 +0,0 @@ - "\\'", '\\' => '\\\\' ) ) . "'; } " ); - - $parserTester = new $className( $testsName ); - $suite->addTestSuite( new ReflectionClass ( $parserTester ) ); - } - - - return $suite; - } -} diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php deleted file mode 100644 index 69a96e66..00000000 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ /dev/null @@ -1,895 +0,0 @@ -getCliArg( 'regex=' ) ) { - $this->regex = $this->getCliArg( 'regex=' ); - } else { - # Matches anything - $this->regex = ''; - } - - $this->keepUploads = $this->getCliArg( 'keep-uploads' ); - - $tmpGlobals = array(); - - $tmpGlobals['wgScript'] = '/index.php'; - $tmpGlobals['wgScriptPath'] = '/'; - $tmpGlobals['wgArticlePath'] = '/wiki/$1'; - $tmpGlobals['wgStyleSheetPath'] = '/skins'; - $tmpGlobals['wgStylePath'] = '/skins'; - $tmpGlobals['wgThumbnailScriptPath'] = false; - $tmpGlobals['wgLocalFileRepo'] = array( - 'class' => 'LocalRepo', - 'name' => 'local', - 'url' => 'http://example.com/images', - 'hashLevels' => 2, - 'transformVia404' => false, - 'backend' => 'local-backend' - ); - $tmpGlobals['wgForeignFileRepos'] = array(); - $tmpGlobals['wgEnableParserCache'] = false; - $tmpGlobals['wgHooks'] = $wgHooks; - $tmpGlobals['wgDeferredUpdateList'] = array(); - $tmpGlobals['wgMemc'] = wfGetMainCache(); - $tmpGlobals['messageMemc'] = wfGetMessageCacheStorage(); - $tmpGlobals['parserMemc'] = wfGetParserCacheStorage(); - - // $tmpGlobals['wgContLang'] = new StubContLang; - $tmpGlobals['wgUser'] = new User; - $context = new RequestContext(); - $tmpGlobals['wgLang'] = $context->getLanguage(); - $tmpGlobals['wgOut'] = $context->getOutput(); - $tmpGlobals['wgParser'] = new StubObject( 'wgParser', $GLOBALS['wgParserConf']['class'], array( $GLOBALS['wgParserConf'] ) ); - $tmpGlobals['wgRequest'] = $context->getRequest(); - - if ( $GLOBALS['wgStyleDirectory'] === false ) { - $tmpGlobals['wgStyleDirectory'] = "$IP/skins"; - } - - - foreach ( $tmpGlobals as $var => $val ) { - if ( array_key_exists( $var, $GLOBALS ) ) { - $this->savedInitialGlobals[$var] = $GLOBALS[$var]; - } - - $GLOBALS[$var] = $val; - } - - $this->savedWeirdGlobals['mw_namespace_protection'] = $wgNamespaceProtection[NS_MEDIAWIKI]; - $this->savedWeirdGlobals['image_alias'] = $wgNamespaceAliases['Image']; - $this->savedWeirdGlobals['image_talk_alias'] = $wgNamespaceAliases['Image_talk']; - - $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface'; - $wgNamespaceAliases['Image'] = NS_FILE; - $wgNamespaceAliases['Image_talk'] = NS_FILE_TALK; - } - - public function tearDown() { - foreach ( $this->savedInitialGlobals as $var => $val ) { - $GLOBALS[$var] = $val; - } - - global $wgNamespaceProtection, $wgNamespaceAliases; - - $wgNamespaceProtection[NS_MEDIAWIKI] = $this->savedWeirdGlobals['mw_namespace_protection']; - $wgNamespaceAliases['Image'] = $this->savedWeirdGlobals['image_alias']; - $wgNamespaceAliases['Image_talk'] = $this->savedWeirdGlobals['image_talk_alias']; - - // Restore backends - RepoGroup::destroySingleton(); - FileBackendGroup::destroySingleton(); - } - - function addDBData() { - $this->tablesUsed[] = 'site_stats'; - $this->tablesUsed[] = 'interwiki'; - # disabled for performance - #$this->tablesUsed[] = 'image'; - - # Hack: insert a few Wikipedia in-project interwiki prefixes, - # for testing inter-language links - $this->db->insert( 'interwiki', array( - array( 'iw_prefix' => 'wikipedia', - 'iw_url' => 'http://en.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 0 ), - array( 'iw_prefix' => 'meatball', - 'iw_url' => 'http://www.usemod.com/cgi-bin/mb.pl?$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 0 ), - array( 'iw_prefix' => 'zh', - 'iw_url' => 'http://zh.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'es', - 'iw_url' => 'http://es.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'fr', - 'iw_url' => 'http://fr.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - array( 'iw_prefix' => 'ru', - 'iw_url' => 'http://ru.wikipedia.org/wiki/$1', - 'iw_api' => '', - 'iw_wikiid' => '', - 'iw_local' => 1 ), - /** - * @todo Fixme! Why are we inserting duplicate data here? Shouldn't - * need this IGNORE or shouldn't need the insert at all. - */ - ), __METHOD__, array( 'IGNORE' ) - ); - - - # Update certain things in site_stats - $this->db->insert( 'site_stats', - array( 'ss_row_id' => 1, 'ss_images' => 2, 'ss_good_articles' => 1 ), - __METHOD__ - ); - - # Reinitialise the LocalisationCache to match the database state - Language::getLocalisationCache()->unloadAll(); - - # Clear the message cache - MessageCache::singleton()->clear(); - - $user = User::newFromId( 0 ); - LinkCache::singleton()->clear(); # Avoids the odd failure at creating the nullRevision - - # Upload DB table entries for files. - # We will upload the actual files later. Note that if anything causes LocalFile::load() - # to be triggered before then, it will break via maybeUpgrade() setting the fileExists - # member to false and storing it in cache. - $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Foobar.jpg' ) ); - if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { - $image->recordUpload2( - '', // archive name - 'Upload of some lame file', - 'Some lame file', - array( - 'size' => 12345, - 'width' => 1941, - 'height' => 220, - 'bits' => 24, - 'media_type' => MEDIATYPE_BITMAP, - 'mime' => 'image/jpeg', - 'metadata' => serialize( array() ), - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), - 'fileExists' => true ), - $this->db->timestamp( '20010115123500' ), $user - ); - } - - # This image will be blacklisted in [[MediaWiki:Bad image list]] - $image = wfLocalFile( Title::makeTitle( NS_FILE, 'Bad.jpg' ) ); - if ( !$this->db->selectField( 'image', '1', array( 'img_name' => $image->getName() ) ) ) { - $image->recordUpload2( - '', // archive name - 'zomgnotcensored', - 'Borderline image', - array( - 'size' => 12345, - 'width' => 320, - 'height' => 240, - 'bits' => 24, - 'media_type' => MEDIATYPE_BITMAP, - 'mime' => 'image/jpeg', - 'metadata' => serialize( array() ), - 'sha1' => wfBaseConvert( '', 16, 36, 31 ), - 'fileExists' => true ), - $this->db->timestamp( '20010115123500' ), $user - ); - } - } - - - - - //ParserTest setup/teardown functions - - /** - * Set up the global variables for a consistent environment for each test. - * Ideally this should replace the global configuration entirely. - */ - protected function setupGlobals( $opts = '', $config = '' ) { - global $wgFileBackends; - # Find out values for some special options. - $lang = - self::getOptionValue( 'language', $opts, 'en' ); - $variant = - self::getOptionValue( 'variant', $opts, false ); - $maxtoclevel = - self::getOptionValue( 'wgMaxTocLevel', $opts, 999 ); - $linkHolderBatchSize = - self::getOptionValue( 'wgLinkHolderBatchSize', $opts, 1000 ); - - $uploadDir = $this->getUploadDir(); - if ( $this->getCliArg( 'use-filebackend=' ) ) { - if ( self::$backendToUse ) { - $backend = self::$backendToUse; - } else { - $name = $this->getCliArg( 'use-filebackend=' ); - $useConfig = array(); - foreach ( $wgFileBackends as $conf ) { - if ( $conf['name'] == $name ) { - $useConfig = $conf; - } - } - $useConfig['name'] = 'local-backend'; // swap name - $class = $conf['class']; - self::$backendToUse = new $class( $useConfig ); - $backend = self::$backendToUse; - } - } else { - $backend = new FSFileBackend( array( - 'name' => 'local-backend', - 'lockManager' => 'nullLockManager', - 'containerPaths' => array( - 'local-public' => "$uploadDir", - 'local-thumb' => "$uploadDir/thumb", - ) - ) ); - } - - $settings = array( - 'wgServer' => 'http://Britney-Spears', - 'wgScript' => '/index.php', - 'wgScriptPath' => '/', - 'wgArticlePath' => '/wiki/$1', - 'wgExtensionAssetsPath' => '/extensions', - 'wgActionPaths' => array(), - 'wgLocalFileRepo' => array( - 'class' => 'LocalRepo', - 'name' => 'local', - 'url' => 'http://example.com/images', - 'hashLevels' => 2, - 'transformVia404' => false, - 'backend' => $backend - ), - 'wgEnableUploads' => self::getOptionValue( 'wgEnableUploads', $opts, true ), - 'wgStylePath' => '/skins', - 'wgStyleSheetPath' => '/skins', - 'wgSitename' => 'MediaWiki', - 'wgLanguageCode' => $lang, - 'wgDBprefix' => $this->db->getType() != 'oracle' ? 'unittest_' : 'ut_', - 'wgRawHtml' => isset( $opts['rawhtml'] ), - 'wgLang' => null, - 'wgContLang' => null, - 'wgNamespacesWithSubpages' => array( 0 => isset( $opts['subpage'] ) ), - 'wgMaxTocLevel' => $maxtoclevel, - 'wgCapitalLinks' => true, - 'wgNoFollowLinks' => true, - 'wgNoFollowDomainExceptions' => array(), - 'wgThumbnailScriptPath' => false, - 'wgUseImageResize' => false, - 'wgUseTeX' => isset( $opts['math'] ), - 'wgMathDirectory' => $uploadDir . '/math', - 'wgLocaltimezone' => 'UTC', - 'wgAllowExternalImages' => true, - 'wgUseTidy' => false, - 'wgDefaultLanguageVariant' => $variant, - 'wgVariantArticlePath' => false, - 'wgGroupPermissions' => array( '*' => array( - 'createaccount' => true, - 'read' => true, - 'edit' => true, - 'createpage' => true, - 'createtalk' => true, - ) ), - 'wgNamespaceProtection' => array( NS_MEDIAWIKI => 'editinterface' ), - 'wgDefaultExternalStore' => array(), - 'wgForeignFileRepos' => array(), - 'wgLinkHolderBatchSize' => $linkHolderBatchSize, - 'wgExperimentalHtmlIds' => false, - 'wgExternalLinkTarget' => false, - 'wgAlwaysUseTidy' => false, - 'wgHtml5' => true, - 'wgWellFormedXml' => true, - 'wgAllowMicrodataAttributes' => true, - 'wgAdaptiveMessageCache' => true, - 'wgUseDatabaseMessages' => true, - ); - - if ( $config ) { - $configLines = explode( "\n", $config ); - - foreach ( $configLines as $line ) { - list( $var, $value ) = explode( '=', $line, 2 ); - - $settings[$var] = eval( "return $value;" ); //??? - } - } - - $this->savedGlobals = array(); - - /** @since 1.20 */ - wfRunHooks( 'ParserTestGlobals', array( &$settings ) ); - - foreach ( $settings as $var => $val ) { - if ( array_key_exists( $var, $GLOBALS ) ) { - $this->savedGlobals[$var] = $GLOBALS[$var]; - } - - $GLOBALS[$var] = $val; - } - - $langObj = Language::factory( $lang ); - $GLOBALS['wgContLang'] = $langObj; - $context = new RequestContext(); - $GLOBALS['wgLang'] = $context->getLanguage(); - - $GLOBALS['wgMemc'] = new EmptyBagOStuff; - $GLOBALS['wgOut'] = $context->getOutput(); - $GLOBALS['wgUser'] = $context->getUser(); - - global $wgHooks; - - $wgHooks['ParserTestParser'][] = 'ParserTestParserHook::setup'; - $wgHooks['ParserGetVariableValueTs'][] = 'ParserTest::getFakeTimestamp'; - - MagicWord::clearCache(); - RepoGroup::destroySingleton(); - FileBackendGroup::destroySingleton(); - - # Create dummy files in storage - $this->setupUploads(); - - # Publish the articles after we have the final language set - $this->publishTestArticles(); - - # The entries saved into RepoGroup cache with previous globals will be wrong. - RepoGroup::destroySingleton(); - FileBackendGroup::destroySingleton(); - MessageCache::destroyInstance(); - - return $context; - } - - /** - * Get an FS upload directory (only applies to FSFileBackend) - * - * @return String: the directory - */ - protected function getUploadDir() { - if ( $this->keepUploads ) { - $dir = wfTempDir() . '/mwParser-images'; - - if ( is_dir( $dir ) ) { - return $dir; - } - } else { - $dir = wfTempDir() . "/mwParser-" . mt_rand() . "-images"; - } - - // wfDebug( "Creating upload directory $dir\n" ); - if ( file_exists( $dir ) ) { - wfDebug( "Already exists!\n" ); - return $dir; - } - - return $dir; - } - - /** - * Create a dummy uploads directory which will contain a couple - * of files in order to pass existence tests. - * - * @return String: the directory - */ - protected function setupUploads() { - global $IP; - - $base = $this->getBaseDir(); - $backend = RepoGroup::singleton()->getLocalRepo()->getBackend(); - $backend->prepare( array( 'dir' => "$base/local-public/3/3a" ) ); - $backend->store( array( - 'src' => "$IP/skins/monobook/headbg.jpg", 'dst' => "$base/local-public/3/3a/Foobar.jpg" - ) ); - $backend->prepare( array( 'dir' => "$base/local-public/0/09" ) ); - $backend->store( array( - 'src' => "$IP/skins/monobook/headbg.jpg", 'dst' => "$base/local-public/0/09/Bad.jpg" - ) ); - } - - /** - * Restore default values and perform any necessary clean-up - * after each test runs. - */ - protected function teardownGlobals() { - $this->teardownUploads(); - - foreach ( $this->savedGlobals as $var => $val ) { - $GLOBALS[$var] = $val; - } - - RepoGroup::destroySingleton(); - LinkCache::singleton()->clear(); - } - - /** - * Remove the dummy uploads directory - */ - private function teardownUploads() { - if ( $this->keepUploads ) { - return; - } - - $base = $this->getBaseDir(); - // delete the files first, then the dirs. - self::deleteFiles( - array ( - "$base/local-public/3/3a/Foobar.jpg", - "$base/local-thumb/3/3a/Foobar.jpg/180px-Foobar.jpg", - "$base/local-thumb/3/3a/Foobar.jpg/200px-Foobar.jpg", - "$base/local-thumb/3/3a/Foobar.jpg/640px-Foobar.jpg", - "$base/local-thumb/3/3a/Foobar.jpg/120px-Foobar.jpg", - - "$base/local-public/0/09/Bad.jpg", - "$base/local-thumb/0/09/Bad.jpg", - - "$base/local-public/math/f/a/5/fa50b8b616463173474302ca3e63586b.png", - ) - ); - } - - /** - * Delete the specified files, if they exist. - * @param $files Array: full paths to files to delete. - */ - private static function deleteFiles( $files ) { - $backend = RepoGroup::singleton()->getLocalRepo()->getBackend(); - foreach ( $files as $file ) { - $backend->delete( array( 'src' => $file ), array( 'force' => 1 ) ); - } - foreach ( $files as $file ) { - $tmp = $file; - while ( $tmp = FileBackend::parentStoragePath( $tmp ) ) { - if ( !$backend->clean( array( 'dir' => $tmp ) )->isOK() ) { - break; - } - } - } - } - - protected function getBaseDir() { - return 'mwstore://local-backend'; - } - - public function parserTestProvider() { - if ( $this->file === false ) { - global $wgParserTestFiles; - $this->file = $wgParserTestFiles[0]; - } - return new TestFileIterator( $this->file, $this ); - } - - /** - * Set the file from whose tests will be run by this instance - */ - public function setParserTestFile( $filename ) { - $this->file = $filename; - } - - /** - * @group medium - * @dataProvider parserTestProvider - */ - public function testParserTest( $desc, $input, $result, $opts, $config ) { - if ( $this->regex != '' && !preg_match( '/' . $this->regex . '/', $desc ) ) { - $this->assertTrue( true ); // XXX: don't flood output with "test made no assertions" - //$this->markTestSkipped( 'Filtered out by the user' ); - return; - } - - wfDebug( "Running parser test: $desc\n" ); - - $opts = $this->parseOptions( $opts ); - $context = $this->setupGlobals( $opts, $config ); - - $user = $context->getUser(); - $options = ParserOptions::newFromContext( $context ); - - if ( isset( $opts['title'] ) ) { - $titleText = $opts['title']; - } - else { - $titleText = 'Parser test'; - } - - $local = isset( $opts['local'] ); - $preprocessor = isset( $opts['preprocessor'] ) ? $opts['preprocessor'] : null; - $parser = $this->getParser( $preprocessor ); - - $title = Title::newFromText( $titleText ); - - if ( isset( $opts['pst'] ) ) { - $out = $parser->preSaveTransform( $input, $title, $user, $options ); - } elseif ( isset( $opts['msg'] ) ) { - $out = $parser->transformMsg( $input, $options, $title ); - } elseif ( isset( $opts['section'] ) ) { - $section = $opts['section']; - $out = $parser->getSection( $input, $section ); - } elseif ( isset( $opts['replace'] ) ) { - $section = $opts['replace'][0]; - $replace = $opts['replace'][1]; - $out = $parser->replaceSection( $input, $section, $replace ); - } elseif ( isset( $opts['comment'] ) ) { - $out = Linker::formatComment( $input, $title, $local ); - } elseif ( isset( $opts['preload'] ) ) { - $out = $parser->getpreloadText( $input, $title, $options ); - } else { - $output = $parser->parse( $input, $title, $options, true, true, 1337 ); - $out = $output->getText(); - - if ( isset( $opts['showtitle'] ) ) { - if ( $output->getTitleText() ) { - $title = $output->getTitleText(); - } - - $out = "$title\n$out"; - } - - if ( isset( $opts['ill'] ) ) { - $out = $this->tidy( implode( ' ', $output->getLanguageLinks() ) ); - } elseif ( isset( $opts['cat'] ) ) { - $outputPage = $context->getOutput(); - $outputPage->addCategoryLinks( $output->getCategories() ); - $cats = $outputPage->getCategoryLinks(); - - if ( isset( $cats['normal'] ) ) { - $out = $this->tidy( implode( ' ', $cats['normal'] ) ); - } else { - $out = ''; - } - } - $parser->mPreprocessor = null; - - $result = $this->tidy( $result ); - } - - $this->teardownGlobals(); - - $this->assertEquals( $result, $out, $desc ); - } - - /** - * Run a fuzz test series - * Draw input from a set of test files - * - * @todo fixme Needs some work to not eat memory until the world explodes - * - * @group ParserFuzz - */ - function testFuzzTests() { - global $wgParserTestFiles; - - $files = $wgParserTestFiles; - - if( $this->getCliArg( 'file=' ) ) { - $files = array( $this->getCliArg( 'file=' ) ); - } - - $dict = $this->getFuzzInput( $files ); - $dictSize = strlen( $dict ); - $logMaxLength = log( $this->maxFuzzTestLength ); - - ini_set( 'memory_limit', $this->memoryLimit * 1048576 ); - - $user = new User; - $opts = ParserOptions::newFromUser( $user ); - $title = Title::makeTitle( NS_MAIN, 'Parser_test' ); - - $id = 1; - - while ( true ) { - - // Generate test input - mt_srand( ++$this->fuzzSeed ); - $totalLength = mt_rand( 1, $this->maxFuzzTestLength ); - $input = ''; - - while ( strlen( $input ) < $totalLength ) { - $logHairLength = mt_rand( 0, 1000000 ) / 1000000 * $logMaxLength; - $hairLength = min( intval( exp( $logHairLength ) ), $dictSize ); - $offset = mt_rand( 0, $dictSize - $hairLength ); - $input .= substr( $dict, $offset, $hairLength ); - } - - $this->setupGlobals(); - $parser = $this->getParser(); - - // Run the test - try { - $parser->parse( $input, $title, $opts ); - $this->assertTrue( true, "Test $id, fuzz seed {$this->fuzzSeed}" ); - } catch ( Exception $exception ) { - $input_dump = sprintf( "string(%d) \"%s\"\n", strlen( $input ), $input ); - - $this->assertTrue( false, "Test $id, fuzz seed {$this->fuzzSeed}. \n\nInput: $input_dump\n\nError: {$exception->getMessage()}\n\nBacktrace: {$exception->getTraceAsString()}" ); - } - - $this->teardownGlobals(); - $parser->__destruct(); - - if ( $id % 100 == 0 ) { - $usage = intval( memory_get_usage( true ) / $this->memoryLimit / 1048576 * 100 ); - //echo "{$this->fuzzSeed}: $numSuccess/$numTotal (mem: $usage%)\n"; - if ( $usage > 90 ) { - $ret = "Out of memory:\n"; - $memStats = $this->getMemoryBreakdown(); - - foreach ( $memStats as $name => $usage ) { - $ret .= "$name: $usage\n"; - } - - throw new MWException( $ret ); - } - } - - $id++; - - } - } - - //Various getter functions - - /** - * Get an input dictionary from a set of parser test files - */ - function getFuzzInput( $filenames ) { - $dict = ''; - - foreach ( $filenames as $filename ) { - $contents = file_get_contents( $filename ); - preg_match_all( '/!!\s*input\n(.*?)\n!!\s*result/s', $contents, $matches ); - - foreach ( $matches[1] as $match ) { - $dict .= $match . "\n"; - } - } - - return $dict; - } - - /** - * Get a memory usage breakdown - */ - function getMemoryBreakdown() { - $memStats = array(); - - foreach ( $GLOBALS as $name => $value ) { - $memStats['$' . $name] = strlen( serialize( $value ) ); - } - - $classes = get_declared_classes(); - - foreach ( $classes as $class ) { - $rc = new ReflectionClass( $class ); - $props = $rc->getStaticProperties(); - $memStats[$class] = strlen( serialize( $props ) ); - $methods = $rc->getMethods(); - - foreach ( $methods as $method ) { - $memStats[$class] += strlen( serialize( $method->getStaticVariables() ) ); - } - } - - $functions = get_defined_functions(); - - foreach ( $functions['user'] as $function ) { - $rf = new ReflectionFunction( $function ); - $memStats["$function()"] = strlen( serialize( $rf->getStaticVariables() ) ); - } - - asort( $memStats ); - - return $memStats; - } - - /** - * Get a Parser object - */ - function getParser( $preprocessor = null ) { - global $wgParserConf; - - $class = $wgParserConf['class']; - $parser = new $class( array( 'preprocessorClass' => $preprocessor ) + $wgParserConf ); - - wfRunHooks( 'ParserTestParser', array( &$parser ) ); - - return $parser; - } - - //Various action functions - - public function addArticle( $name, $text, $line ) { - self::$articles[$name] = array( $text, $line ); - } - - public function publishTestArticles() { - if ( empty( self::$articles ) ) { - return; - } - - foreach ( self::$articles as $name => $info ) { - list( $text, $line ) = $info; - ParserTest::addArticle( $name, $text, $line, 'ignoreduplicate' ); - } - } - - /** - * Steal a callback function from the primary parser, save it for - * application to our scary parser. If the hook is not installed, - * abort processing of this file. - * - * @param $name String - * @return Bool true if tag hook is present - */ - public function requireHook( $name ) { - global $wgParser; - $wgParser->firstCallInit( ); // make sure hooks are loaded. - return isset( $wgParser->mTagHooks[$name] ); - } - - public function requireFunctionHook( $name ) { - global $wgParser; - $wgParser->firstCallInit( ); // make sure hooks are loaded. - return isset( $wgParser->mFunctionHooks[$name] ); - } - //Various "cleanup" functions - - /** - * Run the "tidy" command on text if the $wgUseTidy - * global is true - * - * @param $text String: the text to tidy - * @return String - */ - protected function tidy( $text ) { - global $wgUseTidy; - - if ( $wgUseTidy ) { - $text = MWTidy::tidy( $text ); - } - - return $text; - } - - /** - * Remove last character if it is a newline - */ - public function removeEndingNewline( $s ) { - if ( substr( $s, -1 ) === "\n" ) { - return substr( $s, 0, -1 ); - } - else { - return $s; - } - } - - //Test options parser functions - - protected function parseOptions( $instring ) { - $opts = array(); - // foo - // foo=bar - // foo="bar baz" - // foo=[[bar baz]] - // foo=bar,"baz quux" - $regex = '/\b - ([\w-]+) # Key - \b - (?:\s* - = # First sub-value - \s* - ( - " - [^"]* # Quoted val - " - | - \[\[ - [^]]* # Link target - \]\] - | - [\w-]+ # Plain word - ) - (?:\s* - , # Sub-vals 1..N - \s* - ( - "[^"]*" # Quoted val - | - \[\[[^]]*\]\] # Link target - | - [\w-]+ # Plain word - ) - )* - )? - /x'; - - if ( preg_match_all( $regex, $instring, $matches, PREG_SET_ORDER ) ) { - foreach ( $matches as $bits ) { - array_shift( $bits ); - $key = strtolower( array_shift( $bits ) ); - if ( count( $bits ) == 0 ) { - $opts[$key] = true; - } elseif ( count( $bits ) == 1 ) { - $opts[$key] = $this->cleanupOption( array_shift( $bits ) ); - } else { - // Array! - $opts[$key] = array_map( array( $this, 'cleanupOption' ), $bits ); - } - } - } - return $opts; - } - - protected function cleanupOption( $opt ) { - if ( substr( $opt, 0, 1 ) == '"' ) { - return substr( $opt, 1, -1 ); - } - - if ( substr( $opt, 0, 2 ) == '[[' ) { - return substr( $opt, 2, -2 ); - } - return $opt; - } - - /** - * Use a regex to find out the value of an option - * @param $key String: name of option val to retrieve - * @param $opts Options array to look in - * @param $default Mixed: default value returned if not found - */ - protected static function getOptionValue( $key, $opts, $default ) { - $key = strtolower( $key ); - - if ( isset( $opts[$key] ) ) { - return $opts[$key]; - } else { - return $default; - } - } -} diff --git a/tests/phpunit/includes/parser/ParserMethodsTest.php b/tests/phpunit/includes/parser/ParserMethodsTest.php deleted file mode 100644 index dea406c3..00000000 --- a/tests/phpunit/includes/parser/ParserMethodsTest.php +++ /dev/null @@ -1,33 +0,0 @@ -~~~', - 'hello \'\'this\'\' is ~~~', - ), - ); - } - - /** - * @dataProvider dataPreSaveTransform - */ - public function testPreSaveTransform( $text, $expected ) { - global $wgParser; - - $title = Title::newFromText( str_replace( '::', '__', __METHOD__ ) ); - $user = new User(); - $user->setName( "127.0.0.1" ); - $popts = ParserOptions::newFromUser( $user ); - $text = $wgParser->preSaveTransform( $text, $title, $user, $popts ); - - $this->assertEquals( $expected, $text ); - } - - // TODO: Add tests for cleanSig() / cleanSigInSig(), getSection(), replaceSection(), getPreloadText() -} - diff --git a/tests/phpunit/includes/parser/ParserPreloadTest.php b/tests/phpunit/includes/parser/ParserPreloadTest.php deleted file mode 100644 index 0e8ef530..00000000 --- a/tests/phpunit/includes/parser/ParserPreloadTest.php +++ /dev/null @@ -1,67 +0,0 @@ -testParserOptions = new ParserOptions(); - - $this->testParser = new Parser(); - $this->testParser->Options( $this->testParserOptions ); - $this->testParser->clearState(); - - $this->title = Title::newFromText( 'Preload Test' ); - } - - function tearDown() { - unset( $this->testParser ); - unset( $this->title ); - } - - /** - * @covers Parser::getPreloadText - */ - function testPreloadSimpleText() { - $this->assertPreloaded( 'simple', 'simple' ); - } - - /** - * @covers Parser::getPreloadText - */ - function testPreloadedPreIsUnstripped() { - $this->assertPreloaded( - '
monospaced
', - '
monospaced
', - '
 in preloaded text must be unstripped (bug 27467)'
-		);
-	}
-
-	/**
-	 * @covers Parser::getPreloadText
-	 */
-	function testPreloadedNowikiIsUnstripped() {
-		$this->assertPreloaded(
-			'[[Dummy title]]',
-			'[[Dummy title]]',
-			' in preloaded text must be unstripped (bug 27467)'
-		);
-	}
-
-	function assertPreloaded( $expected, $text, $msg='') {
-		$this->assertEquals(
-			$expected,
-			$this->testParser->getPreloadText(
-				$text,
-				$this->title,
-				$this->testParserOptions
-			),
-			$msg
-		);
-	}
-
-}
diff --git a/tests/phpunit/includes/parser/PreprocessorTest.php b/tests/phpunit/includes/parser/PreprocessorTest.php
deleted file mode 100644
index fee56748..00000000
--- a/tests/phpunit/includes/parser/PreprocessorTest.php
+++ /dev/null
@@ -1,233 +0,0 @@
-mOptions = new ParserOptions();
-		$name = isset( $wgParserConf['preprocessorClass'] ) ? $wgParserConf['preprocessorClass'] : 'Preprocessor_DOM';
-
-		$this->mPreprocessor = new $name( $this );
-	}
-
-	function getStripList() {
-		return array( 'gallery', 'display map' /* Used by Maps, see r80025 CR */, '/foo' );
-	}
-
-	function provideCases() {
-		return array(
-			array( "Foo", "Foo" ),
-			array( "", "<!-- Foo -->" ),
-			array( "", "<!-- Foo --><!-- Bar -->" ),
-			array( "  ", "<!-- Foo -->  <!-- Bar -->" ),
-			array( " \n ", "<!-- Foo --> \n <!-- Bar -->" ),
-			array( " \n \n", "<!-- Foo --> \n <!-- Bar -->\n" ),
-			array( "  \n", "<!-- Foo -->  <!-- Bar -->\n" ),
-			array( "Bar", "<!-->Bar" ),
-			array( "\n== Baz ==\n", "== Foo ==\n  <!-- Bar -->\n== Baz ==\n" ),
-			array( "", "gallery" ),
-			array( "Foo  Bar", "Foo gallery Bar" ),
-			array( "", "gallery</gallery>" ),
-			array( " ", "<foo> gallery</gallery>" ),
-			array( " ", "<foo> gallery<gallery></gallery>" ),
-			array( " Foo bar ", "<noinclude> Foo bar </noinclude>" ),
-			array( "\n{{Foo}}\n", "<noinclude>\n\n</noinclude>" ),
-			array( "\n{{Foo}}\n\n", "<noinclude>\n\n</noinclude>\n" ),
-			array( "foo bar", "galleryfoo bar" ),
-			array( "<{{foo}}>", "<>" ),
-			array( "<{{{foo}}}>", "<foo>" ),
-			array( "", "gallery</gallery</gallery>" ),
-			array( "=== Foo === ", "=== Foo === " ),
-			array( "=== Foo === ", "==<!-- -->= Foo === " ),
-			array( "=== Foo === ", "=== Foo ==<!-- -->= " ),
-			array( "=== Foo ===\n", "=== Foo ===<!-- -->\n" ),
-			array( "=== Foo === \n", "=== Foo ===<!-- --> <!-- -->\n" ),
-			array( "== Foo ==\n== Bar == \n", "== Foo ==\n== Bar == \n" ),
-			array( "===========", "===========" ),
-			array( "Foo\n=\n==\n=\n", "Foo\n=\n==\n=\n" ),
-			array( "{{Foo}}", "" ),
-			array( "\n{{Foo}}", "\n" ),
-			array( "{{Foo|bar}}", "" ),  
-			array( "{{Foo|bar}}a", "a" ),  
-			array( "{{Foo|bar|baz}}", "" ),  
-			array( "{{Foo|1=bar}}", "" ),
-			array( "{{Foo|=bar}}", "" ),
-			array( "{{Foo|bar=baz}}", "" ), 
-			array( "{{Foo|{{bar}}=baz}}", "" ),
-			array( "{{Foo|1=bar|baz}}", "" ), 
-			array( "{{Foo|1=bar|2=baz}}", "" ),
-			array( "{{Foo|bar|foo=baz}}", "" ), 
-			array( "{{{1}}}", "1" ),
-			array( "{{{1|}}}", "1" ),
-			array( "{{{Foo}}}", "Foo" ),
-			array( "{{{Foo|}}}", "Foo" ),
-			array( "{{{Foo|bar|baz}}}", "Foobarbaz" ),
-			array( "{{Foo}}", "{<!-- -->{Foo}}" ),
-			array( "{{{{Foobar}}}}", "{Foobar}" ),
-			array( "{{{ {{Foo}} }}}", " <template><title>Foo " ),
-			array( "{{ {{{Foo}}} }}", "" ),
-			array( "{{{{{Foo}}}}}", "" ),
-			array( "{{{{{Foo}} }}}", "<template><title>Foo " ),
-			array( "{{{{{{Foo}}}}}}", "<tplarg><title>Foo" ),
-			array( "{{{{{{Foo}}}}}", "{" ),
-			array( "[[[Foo]]", "[[[Foo]]" ),
-			array( "{{Foo|[[[[bar]]|baz]]}}", "" ), // This test is important, since it means the difference between having the [[ rule stacked or not
-			array( "{{Foo|[[[[bar]|baz]]}}", "{{Foo|[[[[bar]|baz]]}}" ),
-			array( "{{Foo|Foo [[[[bar]|baz]]}}", "{{Foo|Foo [[[[bar]|baz]]}}" ),
-			array( "Foo BarBaz", "Foo display mapBar</display map             >Baz" ),
-			array( "Foo BarBaz", "Foo display map fooBar</display map             >Baz" ),
-			array( "Foo ", "Foo gallery bar="baz" " ),
-			array( "Foo ", "Foo gallery bar="1" baz=2 " ),
-			array( "Foo", "/fooFoo<//foo>" ), # Worth blacklisting IMHO
-			array( "{{#ifexpr: ({{{1|1}}} = 2) | Foo | Bar }}", ""),
-			array( "{{#if: {{{1|}}} | Foo | {{Bar}} }}", ""),
-			array( "{{#if: {{{1|}}} | Foo | [[Bar]] }}", ""),
-			array( "{{#if: {{{1|}}} | [[Foo]] | Bar }}", ""),
-			array( "{{#if: {{{1|}}} | 1 | {{#if: {{{1|}}} | 2 | 3 }} }}", ""),
-			array( "{{ {{Foo}}", "{{ "),
-			array( "{{Foobar {{Foo}} {{Bar}} {{Baz}} ", "{{Foobar    "),
-			array( "[[Foo]] |", "[[Foo]] |"),
-			array( "{{Foo|Bar|", "{{Foo|Bar|"),
-			array( "[[Foo]", "[[Foo]"),
-			array( "[[Foo|Bar]", "[[Foo|Bar]"),
-			array( "{{Foo| [[Bar] }}", "{{Foo| [[Bar] }}"),
-			array( "{{Foo| [[Bar|Baz] }}", "{{Foo| [[Bar|Baz] }}"),
-			array( "{{Foo|bar=[[baz]}}", "{{Foo|bar=[[baz]}}"),
-			array( "{{foo|", "{{foo|"),
-			array( "{{foo|}", "{{foo|}"),
-			array( "{{foo|} }}", ""),
-			array( "{{foo|bar=|}", "{{foo|bar=|}"),
-			array( "{{Foo|} Bar=", "{{Foo|} Bar="),
-			array( "{{Foo|} Bar=}}", ""),
-			/* array( file_get_contents( __DIR__ . '/QuoteQuran.txt' ), file_get_contents( __DIR__ . '/QuoteQuranExpanded.txt' ) ), */
-		);
-	}
-
-	/**
-	 * Get XML preprocessor tree from the preprocessor (which may not be the
-	 * native XML-based one).
-	 *
-	 * @param string $wikiText
-	 * @return string
-	 */
-	function preprocessToXml( $wikiText ) {
-		if ( method_exists( $this->mPreprocessor, 'preprocessToXml' ) ) {
-			return $this->normalizeXml( $this->mPreprocessor->preprocessToXml( $wikiText ) );
-		}
-		
-		$dom = $this->mPreprocessor->preprocessToObj( $wikiText );
-		if ( is_callable( array( $dom, 'saveXML' ) ) ) {
-			return $dom->saveXML();
-		} else {
-			return $this->normalizeXml( $dom->__toString() );
-		}
-	}
-
-	/**
-	 * Normalize XML string to the form that a DOMDocument saves out.
-	 *
-	 * @param string $xml
-	 * @return string
-	 */
-	function normalizeXml( $xml ) {
-		return preg_replace( '!<([a-z]+)/>!', '<$1>', str_replace( ' />', '/>', $xml ) );
-		
-		$dom = new DOMDocument();
-		// 1 << 19 == XML_PARSE_HUGE, needed so newer versions of libxml2 don't barf when the XML is >256 levels deep
-		$dom->loadXML( $xml, 1 << 19 );
-		return $dom->saveXML();
-	}
-
-	/**
-	 * @dataProvider provideCases
-	 */
-	function testPreprocessorOutput( $wikiText, $expectedXml ) {
-		$this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
-	}
-
-	/**
-	 * These are more complex test cases taken out of wiki articles.
-	 */
-	function provideFiles() {
-		return array(
-			array( "QuoteQuran" ), # http://en.wikipedia.org/w/index.php?title=Template:QuoteQuran/sandbox&oldid=237348988 GFDL + CC-BY-SA by Striver
-			array( "Factorial" ), # http://en.wikipedia.org/w/index.php?title=Template:Factorial&oldid=98548758 GFDL + CC-BY-SA by Polonium
-			array( "All_system_messages" ), # http://tl.wiktionary.org/w/index.php?title=Suleras:All_system_messages&oldid=2765 GPL text generated by MediaWiki
-			array( "Fundraising" ), # http://tl.wiktionary.org/w/index.php?title=MediaWiki:Sitenotice&oldid=5716 GFDL + CC-BY-SA, copied there by Sky Harbor.
-		);
-	}
-
-	/**
-	 * @dataProvider provideFiles
-	 */
-	function testPreprocessorOutputFiles( $filename ) {
-		$folder = __DIR__ . "/../../../parser/preprocess";
-		$wikiText = file_get_contents( "$folder/$filename.txt" );
-		$output = $this->preprocessToXml( $wikiText );
-
-		$expectedFilename = "$folder/$filename.expected";
-		if ( file_exists( $expectedFilename ) ) {
-			$expectedXml = $this->normalizeXml( file_get_contents( $expectedFilename ) );
-			$this->assertEquals( $expectedXml, $output );
-		} else {
-			$tempFilename = tempnam( $folder, "$filename." );
-			file_put_contents( $tempFilename, $output );
-			$this->markTestIncomplete( "File $expectedFilename missing. Output stored as $tempFilename" );
-		}
-	}
-
-	/**
-	 * Tests from Bug 28642 · https://bugzilla.wikimedia.org/28642
-	 */
-	function provideHeadings() {
-		return array(	/* These should become headings: */
-			array( "== h ==", "== h ==<!--c1-->" ),
-			array( "== h == 	", "== h == 	<!--c1-->" ),
-			array( "== h == 	", "== h ==<!--c1--> 	" ),
-			array( "== h == 	 	", "== h == 	<!--c1--> 	" ),
-			array( "== h ==", "== h ==<!--c1--><!--c2-->" ),
-			array( "== h == 	", "== h == 	<!--c1--><!--c2-->" ),
-			array( "== h == 	", "== h ==<!--c1--><!--c2--> 	" ),
-			array( "== h == 	 	", "== h == 	<!--c1--><!--c2--> 	" ),
-			array( "== h == 	  ", "== h == 	<!--c1-->  <!--c2-->" ),
-			array( "== h ==   	", "== h ==<!--c1-->  <!--c2--> 	" ),
-			array( "== h == 	   	", "== h == 	<!--c1-->  <!--c2--> 	" ),
-			array( "== h ==", "== h ==<!--c1--><!--c2--><!--c3-->" ),
-			array( "== h ==  ", "== h ==<!--c1-->  <!--c2--><!--c3-->" ),
-			array( "== h ==  ", "== h ==<!--c1--><!--c2-->  <!--c3-->" ),
-			array( "== h ==    ", "== h ==<!--c1-->  <!--c2-->  <!--c3-->" ),
-			array( "== h ==  ", "== h ==  <!--c1--><!--c2--><!--c3-->" ),
-			array( "== h ==    ", "== h ==  <!--c1-->  <!--c2--><!--c3-->" ),
-			array( "== h ==    ", "== h ==  <!--c1--><!--c2-->  <!--c3-->" ),
-			array( "== h ==      ", "== h ==  <!--c1-->  <!--c2-->  <!--c3-->" ),
-			array( "== h ==  ", "== h ==<!--c1--><!--c2--><!--c3-->  " ),
-			array( "== h ==    ", "== h ==<!--c1-->  <!--c2--><!--c3-->  " ),
-			array( "== h ==    ", "== h ==<!--c1--><!--c2-->  <!--c3-->  " ),
-			array( "== h ==      ", "== h ==<!--c1-->  <!--c2-->  <!--c3-->  " ),
-			array( "== h ==    ", "== h ==  <!--c1--><!--c2--><!--c3-->  " ),
-			array( "== h ==      ", "== h ==  <!--c1-->  <!--c2--><!--c3-->  " ),
-			array( "== h ==      ", "== h ==  <!--c1--><!--c2-->  <!--c3-->  " ),
-			array( "== h ==        ", "== h ==  <!--c1-->  <!--c2-->  <!--c3-->  " ),
-
-			/* These are not working: */
-			array( "== h == 	", "== h ==<!--c1--> 	<!--c2-->" ),
-			array( "== h == 	 	", "== h == 	<!--c1--> 	<!--c2-->" ),
-			array( "== h == 	 	", "== h ==<!--c1--> 	<!--c2--> 	" ),
-			array( "== h == x   ", "== h == x <!--c1--><!--c2--><!--c3-->  " ),
-			array( "== h == x   ", "== h ==<!--c1--> x <!--c2--><!--c3-->  " ),
-			array( "== h == x ", "== h ==<!--c1--><!--c2--><!--c3--> x " ),
-		);
-	}
-
-	/**
-	 * @dataProvider provideHeadings
-	 */
-	function testHeadings( $wikiText, $expectedXml ) {
-		$this->assertEquals( $this->normalizeXml( $expectedXml ), $this->preprocessToXml( $wikiText ) );
-	}
-}
-
diff --git a/tests/phpunit/includes/parser/TagHooksTest.php b/tests/phpunit/includes/parser/TagHooksTest.php
deleted file mode 100644
index 713ce846..00000000
--- a/tests/phpunit/includes/parser/TagHooksTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-bar" ), array( "foo\nbar" ),  array( "foo\rbar" ) );
-	}
-		
-	/**
-	 * @dataProvider provideValidNames
-	 */
-	function testTagHooks( $tag ) {
-		global $wgParserConf;
-		$parser = new Parser( $wgParserConf );
-		
-		$parser->setHook( $tag, array( $this, 'tagCallback' ) );
-		$parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), new ParserOptions );
-		$this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); - - $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle - } - - /** - * @dataProvider provideBadNames - * @expectedException MWException - */ - function testBadTagHooks( $tag ) { - global $wgParserConf; - $parser = new Parser( $wgParserConf ); - - $parser->setHook( $tag, array( $this, 'tagCallback' ) ); - $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), new ParserOptions ); - $this->fail('Exception not thrown.'); - } - - /** - * @dataProvider provideValidNames - */ - function testFunctionTagHooks( $tag ) { - global $wgParserConf; - $parser = new Parser( $wgParserConf ); - - $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), 0 ); - $parserOutput = $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), new ParserOptions ); - $this->assertEquals( "

FooOneBaz\n

", $parserOutput->getText() ); - - $parser->mPreprocessor = null; # Break the Parser <-> Preprocessor cycle - } - - /** - * @dataProvider provideBadNames - * @expectedException MWException - */ - function testBadFunctionTagHooks( $tag ) { - global $wgParserConf; - $parser = new Parser( $wgParserConf ); - - $parser->setFunctionTagHook( $tag, array( $this, 'functionTagCallback' ), SFH_OBJECT_ARGS ); - $parser->parse( "Foo<$tag>BarBaz", Title::newFromText( 'Test' ), new ParserOptions ); - $this->fail('Exception not thrown.'); - } - - function tagCallback( $text, $params, $parser ) { - return str_rot13( $text ); - } - - function functionTagCallback( &$parser, $frame, $code, $attribs ) { - return str_rot13( $code ); - } -} -- cgit v1.2.2