Merge "Fix setting hooks in ApiQueryTest"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 23 Oct 2014 17:56:57 +0000 (17:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 23 Oct 2014 17:56:57 +0000 (17:56 +0000)
tests/phpunit/includes/api/query/ApiQueryTest.php

index bba22c7..200027d 100644 (file)
@@ -7,32 +7,21 @@
  * @covers ApiQuery
  */
 class ApiQueryTest extends ApiTestCase {
-       /**
-        * @var array Storage for $wgHooks
-        */
-       protected $hooks;
-
        protected function setUp() {
-               global $wgHooks;
-
                parent::setUp();
                $this->doLogin();
 
-               // Setup en: as interwiki prefix
-               $this->hooks = $wgHooks;
-               $wgHooks['InterwikiLoadPrefix'][] = function ( $prefix, &$data ) {
-                       if ( $prefix == 'apiquerytestiw' ) {
-                               $data = array( 'iw_url' => 'wikipedia' );
-                       }
-                       return false;
-               };
-       }
-
-       protected function tearDown() {
-               global $wgHooks;
-               $wgHooks = $this->hooks;
-
-               parent::tearDown();
+               // Setup apiquerytestiw: as interwiki prefix
+               $this->setMwGlobals( 'wgHooks', array(
+                       'InterwikiLoadPrefix' => array(
+                               function ( $prefix, &$data ) {
+                                       if ( $prefix == 'apiquerytestiw' ) {
+                                               $data = array( 'iw_url' => 'wikipedia' );
+                                       }
+                                       return false;
+                               }
+                       )
+               ) );
        }
 
        public function testTitlesGetNormalized() {