X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FGlobalFunctions%2FGlobalTest.php;h=5e54b8d4366ef68098906a0e5ce13d20acc07750;hb=b5cddfb27b0d50bd396b1ff92d022b2dec766754;hp=2206fbdfeed3553ad798140765331ea9147d5ada;hpb=162a7a306c20db2693e842070393676159f653e9;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php index 2206fbdfee..5e54b8d436 100644 --- a/tests/phpunit/includes/GlobalFunctions/GlobalTest.php +++ b/tests/phpunit/includes/GlobalFunctions/GlobalTest.php @@ -102,22 +102,28 @@ class GlobalTest extends MediaWikiTestCase { } /** + * Intended to cover the relevant bits of ServiceWiring.php, as well as GlobalFunctions.php * @covers ::wfReadOnly */ public function testReadOnlyEmpty() { global $wgReadOnly; $wgReadOnly = null; + MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()->clearCache(); $this->assertFalse( wfReadOnly() ); $this->assertFalse( wfReadOnly() ); } /** + * Intended to cover the relevant bits of ServiceWiring.php, as well as GlobalFunctions.php * @covers ::wfReadOnly */ public function testReadOnlySet() { global $wgReadOnly, $wgReadOnlyFile; + $readOnlyMode = MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode(); + $readOnlyMode->clearCache(); + $f = fopen( $wgReadOnlyFile, "wt" ); fwrite( $f, 'Message' ); fclose( $f ); @@ -127,12 +133,23 @@ class GlobalTest extends MediaWikiTestCase { $this->assertTrue( wfReadOnly() ); # Check cached unlink( $wgReadOnlyFile ); - $wgReadOnly = null; # Clean cache - + $readOnlyMode->clearCache(); $this->assertFalse( wfReadOnly() ); $this->assertFalse( wfReadOnly() ); } + /** + * This behaviour could probably be deprecated. Several extensions rely on it as of 1.29. + * @covers ::wfReadOnlyReason + */ + public function testReadOnlyGlobalChange() { + $this->assertFalse( wfReadOnlyReason() ); + $this->setMwGlobals( [ + 'wgReadOnly' => 'reason' + ] ); + $this->assertSame( 'reason', wfReadOnlyReason() ); + } + public static function provideArrayToCGI() { return [ [ [], '' ], // empty @@ -345,7 +362,6 @@ class GlobalTest extends MediaWikiTestCase { * @covers ::wfClientAcceptsGzip */ public function testClientAcceptsGzipTest() { - $settings = [ 'gzip' => true, 'bzip' => false, @@ -379,7 +395,6 @@ class GlobalTest extends MediaWikiTestCase { * @covers ::wfPercent */ public function testWfPercentTest() { - $pcts = [ [ 6 / 7, '0.86%', 2, false ], [ 3 / 3, '1%' ],