New hook 'ParserTestGlobals'
authorDaniel Werner <daniel.werner@wikimedia.de>
Mon, 13 Aug 2012 22:18:50 +0000 (00:18 +0200)
committerDaniel Werner <daniel.werner@wikimedia.de>
Mon, 13 Aug 2012 22:18:50 +0000 (00:18 +0200)
Allows to set globals before running parser tests.

Change-Id: Iea057b992b260611bca7f3adade2c8214b0dcea2

RELEASE-NOTES-1.20
docs/hooks.txt
tests/parser/parserTest.inc
tests/phpunit/includes/parser/NewParserTest.php

index aecc2a4..a53d8ee 100644 (file)
@@ -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.
index cce152d..2862d1b 100644 (file)
@@ -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.
index deb5c5a..cd59833 100644 (file)
@@ -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];
index 11f9471..0380152 100644 (file)
@@ -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];