Don't break core's parserTests if VisualEditor is installed

VisualEditor's hook changes the edit section link, which changes the
output of certain parser tests so that they no longer match the
expected text.  Use the `ParserTestsGlobal` hook (which cleans up
after itself when the parserTests ends) to disable the
`onDoEditSectionLink` hook when we're running parserTests to avoid
the spurious failures.

Change-Id: Ic958d88f443ac37ba304d3256e2bb5ea2fde820d
This commit is contained in:
C. Scott Ananian 2013-09-16 17:12:50 -04:00
parent 4c12f1841a
commit 21cd7bad53
2 changed files with 10 additions and 0 deletions

View file

@ -170,7 +170,9 @@ class VisualEditorHooks {
*/
public static function onDoEditSectionLink( $skin, $title, $section, $tooltip, &$result, $lang ) {
// Only do this if the user has VE enabled
// (and we're not in parserTests)
if (
isset( $GLOBALS[ 'wgVisualEditorInParserTests' ] ) ||
!$skin->getUser()->getOption( 'visualeditor-enable' ) ||
$skin->getUser()->getOption( 'visualeditor-betatempdisable' )
) {
@ -384,4 +386,11 @@ class VisualEditorHooks {
return true;
}
/**
* Ensures that we know whether we're running inside a parser test.
*/
public static function onParserTestGlobals( array &$settings ) {
$settings['wgVisualEditorInParserTests'] = true;
}
}

View file

@ -57,6 +57,7 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'VisualEditorHooks::onMakeGlobalVariab
$wgHooks['ResourceLoaderGetConfigVars'][] = 'VisualEditorHooks::onResourceLoaderGetConfigVars';
$wgHooks['ResourceLoaderTestModules'][] = 'VisualEditorHooks::onResourceLoaderTestModules';
$wgHooks['SkinTemplateNavigation'][] = 'VisualEditorHooks::onSkinTemplateNavigation';
$wgHooks['ParserTestGlobals'][] = 'VisualEditorHooks::onParserTestGlobals';
$wgExtensionFunctions[] = 'VisualEditorHooks::onSetup';
// Set default values for new preferences