unlink( $readOnlyFile );
$this->setMwGlobals( [
+ 'wgReadOnly' => null,
'wgReadOnlyFile' => $readOnlyFile,
'wgUrlProtocols' => [
'http://',
$this->assertFalse(
wfRandomString() == wfRandomString()
);
- $this->assertEquals(
- strlen( wfRandomString( 10 ) ), 10
- );
- $this->assertTrue(
- preg_match( '/^[0-9a-f]+$/i', wfRandomString() ) === 1
- );
+ $this->assertSame( 10, strlen( wfRandomString( 10 ) ), 'length' );
+ $this->assertSame( 1, preg_match( '/^[0-9a-f]+$/i', wfRandomString() ), 'pattern' );
}
/**
* @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() );
}