unlink( $readOnlyFile );
$this->setMwGlobals( [
+ 'wgReadOnly' => null,
'wgReadOnlyFile' => $readOnlyFile,
'wgUrlProtocols' => [
'http://',
* @covers ::wfReadOnly
*/
public function testReadOnlyEmpty() {
- global $wgReadOnly;
- $wgReadOnly = null;
-
- MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode()->clearCache();
$this->assertFalse( wfReadOnly() );
$this->assertFalse( wfReadOnly() );
}
* @covers ::wfReadOnly
*/
public function testReadOnlySet() {
- global $wgReadOnly, $wgReadOnlyFile;
-
- $readOnlyMode = MediaWiki\MediaWikiServices::getInstance()->getReadOnlyMode();
- $readOnlyMode->clearCache();
+ global $wgReadOnlyFile;
$f = fopen( $wgReadOnlyFile, "wt" );
fwrite( $f, 'Message' );
fclose( $f );
- $wgReadOnly = null; # Check on $wgReadOnlyFile
+
+ // Reset the service to avoid cached results
+ $this->overrideMwServices();
$this->assertTrue( wfReadOnly() );
$this->assertTrue( wfReadOnly() ); # Check cached
-
- unlink( $wgReadOnlyFile );
- $readOnlyMode->clearCache();
- $this->assertFalse( wfReadOnly() );
- $this->assertFalse( wfReadOnly() );
}
/**
*/
public function testReadOnlyGlobalChange() {
$this->assertFalse( wfReadOnlyReason() );
+
$this->setMwGlobals( [
'wgReadOnly' => 'reason'
] );
+ $this->overrideMwServices();
+
$this->assertSame( 'reason', wfReadOnlyReason() );
}