Merge "Tests: Use more setMwGlobals"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 22 Mar 2013 19:15:03 +0000 (19:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 22 Mar 2013 19:15:03 +0000 (19:15 +0000)
1  2 
tests/phpunit/includes/HtmlTest.php
tests/phpunit/includes/jobqueue/JobQueueTest.php
tests/phpunit/includes/media/ExifRotationTest.php

@@@ -43,8 -43,6 +43,6 @@@ class HtmlTest extends MediaWikiTestCas
        }
  
        public function testElementBasics() {
-               global $wgWellFormedXml;
                $this->assertEquals(
                        '<img>',
                        Html::element( 'img', null, '' ),
@@@ -63,7 -61,7 +61,7 @@@
                        'Close tag for empty element (array, string)'
                );
  
-               $wgWellFormedXml = true;
+               $this->setMwGlobals( 'wgWellFormedXml', true );
  
                $this->assertEquals(
                        '<img />',
@@@ -90,8 -88,6 +88,6 @@@
        }
  
        public function testExpandAttributesForBooleans() {
-               global $wgHtml5, $wgWellFormedXml;
                $this->assertEquals(
                        '',
                        Html::expandAttributes( array( 'selected' => false ) ),
                        'Boolean attributes have no value when value is true (passed as numerical array)'
                );
  
-               $wgWellFormedXml = true;
+               $this->setMwGlobals( 'wgWellFormedXml', true );
  
                $this->assertEquals(
                        ' selected=""',
                        'Boolean attributes have empty string value when value is true (wgWellFormedXml)'
                );
  
-               $wgHtml5 = false;
+               $this->setMwGlobals( 'wgHtml5', false );
  
                $this->assertEquals(
                        ' selected="selected"',
         * Please note it output a string prefixed with a space!
         */
        public function testExpandAttributesVariousExpansions() {
-               global $wgWellFormedXml;
                ### NOT EMPTY ####
                $this->assertEquals(
                        ' empty_string=""',
                        'Number 0 value needs no quotes'
                );
  
-               $wgWellFormedXml = true;
+               $this->setMwGlobals( 'wgWellFormedXml', true );
  
                $this->assertEquals(
                        ' empty_string=""',
         * List of input element types values introduced by HTML5
         * Full list at http://www.w3.org/TR/html-markup/input.html
         */
 -      function provideHtml5InputTypes() {
 +      public static function provideHtml5InputTypes() {
                $types = array(
                        'datetime',
                        'datetime-local',
@@@ -8,7 -8,6 +8,6 @@@
  class JobQueueTest extends MediaWikiTestCase {
        protected $key;
        protected $queueRand, $queueRandTTL, $queueFifo, $queueFifoTTL;
-       protected $old = array();
  
        function __construct( $name = null, array $data = array(), $dataName = '' ) {
                parent::__construct( $name, $data, $dataName );
        }
  
        protected function setUp() {
-               global $wgMemc, $wgJobTypeConf;
+               global $wgJobTypeConf;
                parent::setUp();
-               $this->old['wgMemc'] = $wgMemc;
-               $wgMemc = new HashBagOStuff();
+               $this->setMwGlobals( 'wgMemc', new HashBagOStuff() );
                if ( $this->getCliArg( 'use-jobqueue=' ) ) {
                        $name = $this->getCliArg( 'use-jobqueue=' );
                        if ( !isset( $wgJobTypeConf[$name] ) ) {
@@@ -51,7 -51,6 +51,6 @@@
        }
  
        protected function tearDown() {
-               global $wgMemc;
                parent::tearDown();
                foreach ( array(
                        'queueRand', 'queueRandTTL', 'queueTimestamp', 'queueTimestampTTL',
@@@ -67,7 -66,6 +66,6 @@@
                        }
                        $this->$q = null;
                }
-               $wgMemc = $this->old['wgMemc'];
        }
  
        /**
                $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
        }
  
 -      function provider_queueLists() {
 +      public static function provider_queueLists() {
                return array(
                        array( 'queueRand', false, 'Random queue without ack()' ),
                        array( 'queueRandTTL', true, 'Random queue with ack()' ),
                );
        }
  
 -      function provider_fifoQueueLists() {
 +      public static function provider_fifoQueueLists() {
                return array(
                        array( 'queueFifo', false, 'Ordered queue without ack()' ),
                        array( 'queueFifoTTL', true, 'Ordered queue with ack()' )
@@@ -25,21 -25,11 +25,11 @@@ class ExifRotationTest extends MediaWik
                if ( !wfDl( 'exif' ) ) {
                        $this->markTestSkipped( "This test needs the exif extension." );
                }
-               global $wgShowEXIF;
-               $this->show = $wgShowEXIF;
-               $wgShowEXIF = true;
  
-               global $wgEnableAutoRotation;
-               $this->oldAuto = $wgEnableAutoRotation;
-               $wgEnableAutoRotation = true;
-       }
-       protected function tearDown() {
-               global $wgShowEXIF, $wgEnableAutoRotation;
-               $wgShowEXIF = $this->show;
-               $wgEnableAutoRotation = $this->oldAuto;
-               parent::tearDown();
+               $this->setMwGlobals( array(
+                       'wgShowEXIF' => true,
+                       'wgEnableAutoRotation' => true,
+               ) );
        }
  
        /**
         * @dataProvider provideFilesNoAutoRotate
         */
        function testMetadataNoAutoRotate( $name, $type, $info ) {
-               global $wgEnableAutoRotation;
-               $wgEnableAutoRotation = false;
+               $this->setMwGlobals( 'wgEnableAutoRotation', false );
  
                $file = $this->dataFile( $name, $type );
                $this->assertEquals( $info['width'], $file->getWidth(), "$name: width check" );
                $this->assertEquals( $info['height'], $file->getHeight(), "$name: height check" );
-               $wgEnableAutoRotation = true;
        }
  
        /**
         * @dataProvider provideFilesNoAutoRotate
         */
        function testRotationRenderingNoAutoRotate( $name, $type, $info, $thumbs ) {
-               global $wgEnableAutoRotation;
-               $wgEnableAutoRotation = false;
+               $this->setMwGlobals( 'wgEnableAutoRotation', false );
  
                foreach ( $thumbs as $size => $out ) {
                        if ( preg_match( '/^(\d+)px$/', $size, $matches ) ) {
                                $this->assertEquals( $out[1], $gis[1], "$name: thumb actual height check for $size" );
                        }
                }
-               $wgEnableAutoRotation = true;
        }
  
        public static function provideFilesNoAutoRotate() {
                $this->assertEquals( $expected, $result );
        }
  
 -      function provideBitmapExtractPreRotationDimensions() {
 +      public static function provideBitmapExtractPreRotationDimensions() {
                return array(
                        array(
                                0,