}
/**
+ * 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 );
$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
* @covers ::wfClientAcceptsGzip
*/
public function testClientAcceptsGzipTest() {
-
$settings = [
'gzip' => true,
'bzip' => false,
* @covers ::wfPercent
*/
public function testWfPercentTest() {
-
$pcts = [
[ 6 / 7, '0.86%', 2, false ],
[ 3 / 3, '1%' ],