From: Daniel Werner Date: Mon, 13 Aug 2012 22:18:50 +0000 (+0200) Subject: New hook 'ParserTestGlobals' X-Git-Tag: 1.31.0-rc.0~22740^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=aaf45a0b7556109db17ce9edeb10a3e67e5f842d;p=lhc%2Fweb%2Fwiklou.git New hook 'ParserTestGlobals' Allows to set globals before running parser tests. Change-Id: Iea057b992b260611bca7f3adade2c8214b0dcea2 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index aecc2a4a26..a53d8ee6cf 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -121,6 +121,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. * A new message, "api-error-filetype-banned-type", is available for formatting API upload errors due to the file extension blacklist. * jsMessage: Redesigned in Vector/Monobook as floating bubble with auto-hide. +* New hook 'ParserTestGlobals' allows to set globals before running parser tests. === Bug fixes in 1.20 === * (bug 30245) Use the correct way to construct a log page title. diff --git a/docs/hooks.txt b/docs/hooks.txt index cce152ddab..2862d1ba87 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1561,6 +1561,10 @@ $showEditLinks: boolean describing whether this section has an edit link maintenance/parserTests.inc $parser: Parser object created +'ParserTestGlobals': Allows to define globals for parser tests. +&$globals: Array with all the globals which should be set for parser tests. + The arrays keys serve as the globals names, its values are the globals values. + 'ParserTestTables': alter the list of tables to duplicate when parser tests are run. Use when page save hooks require the presence of custom tables to ensure that tests continue to run properly. diff --git a/tests/parser/parserTest.inc b/tests/parser/parserTest.inc index deb5c5ad5a..cd5983379c 100644 --- a/tests/parser/parserTest.inc +++ b/tests/parser/parserTest.inc @@ -710,6 +710,9 @@ class ParserTest { $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]; diff --git a/tests/phpunit/includes/parser/NewParserTest.php b/tests/phpunit/includes/parser/NewParserTest.php index 11f9471d32..0380152af3 100644 --- a/tests/phpunit/includes/parser/NewParserTest.php +++ b/tests/phpunit/includes/parser/NewParserTest.php @@ -345,6 +345,9 @@ class NewParserTest extends MediaWikiTestCase { $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];