12 'None of anything' => [
13 'confMessage' =>
null,
14 'hasFileName' =>
false,
15 'fileContents' =>
false,
17 'expectedState' =>
false,
18 'expectedMessage' =>
false,
19 'expectedConfState' =>
false,
20 'expectedConfMessage' =>
false
23 'confMessage' =>
null,
24 'hasFileName' =>
true,
25 'fileContents' =>
false,
27 'expectedState' =>
false,
28 'expectedMessage' =>
false,
29 'expectedConfState' =>
false,
30 'expectedConfMessage' =>
false
33 'confMessage' =>
null,
34 'hasFileName' =>
true,
37 'expectedState' =>
false,
38 'expectedMessage' =>
false,
39 'expectedConfState' =>
false,
40 'expectedConfMessage' =>
false
42 'File has message' => [
43 'confMessage' =>
null,
44 'hasFileName' =>
true,
45 'fileContents' =>
'Message',
47 'expectedState' =>
true,
48 'expectedMessage' =>
'Message',
49 'expectedConfState' =>
true,
50 'expectedConfMessage' =>
'Message',
52 'Conf has message' => [
53 'confMessage' =>
'Message',
54 'hasFileName' =>
false,
55 'fileContents' =>
false,
57 'expectedState' =>
true,
58 'expectedMessage' =>
'Message',
59 'expectedConfState' =>
true,
60 'expectedConfMessage' =>
'Message'
62 "Conf=false means don't check the file" => [
63 'confMessage' =>
false,
64 'hasFileName' =>
true,
65 'fileContents' =>
'Message',
67 'expectedState' =>
false,
68 'expectedMessage' =>
false,
69 'expectedConfState' =>
false,
70 'expectedConfMessage' =>
false,
73 'confMessage' =>
null,
74 'hasFileName' =>
false,
75 'fileContents' =>
false,
76 'lbMessage' =>
'Message',
77 'expectedState' =>
true,
78 'expectedMessage' =>
'Message',
79 'expectedConfState' =>
false,
80 'expectedConfMessage' =>
false
82 'All three have a message: conf wins' => [
83 'confMessage' =>
'conf',
84 'hasFileName' =>
true,
85 'fileContents' =>
'file',
87 'expectedState' =>
true,
88 'expectedMessage' =>
'conf',
89 'expectedConfState' =>
true,
90 'expectedConfMessage' =>
'conf'
94 foreach ( $rawTests as $desc => $test ) {
95 $cookedTests[$desc] = [ $test ];
102 'ReadOnly' =>
$params[
'confMessage'],
117 $lb = $this->getMockBuilder( \Wikimedia\Rdbms\LoadBalancer::class )
118 ->disableOriginalConstructor()
120 $lb->expects( $this->
any() )->method(
'getReadOnlyReason' )
121 ->willReturn(
$params[
'lbMessage'] );
126 if (
$params[
'hasFileName'] ) {
129 if (
$params[
'fileContents'] ===
false ) {
132 file_put_contents( $fileName,
$params[
'fileContents'] );
145 $this->assertSame(
$params[
'expectedMessage'], $rom->getReason() );
146 $this->assertSame(
$params[
'expectedState'], $rom->isReadOnly() );
154 $this->assertSame(
$params[
'expectedConfMessage'], $cro->getReason() );
155 $this->assertSame(
$params[
'expectedConfState'], $cro->isReadOnly() );
161 'confMessage' =>
'conf',
162 'hasFileName' =>
false,
163 'fileContents' =>
false,
167 $rom->setReason(
'override' );
168 $this->assertSame(
'override', $rom->getReason() );
180 'ReadOnlyFile' => $fileName,
183 $lb = $this->
createLB( [
'lbMessage' =>
false ] );
186 $this->assertSame(
false, $rom->getReason(),
'initial' );
188 file_put_contents( $fileName,
'file' );
189 $this->assertSame(
false, $rom->getReason(),
'stale' );
192 $this->assertSame(
'file', $rom->getReason(),
'fresh' );
they could even be mouse clicks or menu items whatever suits your program You should also get your if any
A Config instance which stores all settings as a member variable.
testWithLB( $params)
provider
createMode( $params, $makeLB)
testWithoutLB( $params)
provider
testClearCache()
ReadOnlyMode::clearCache ConfiguredReadOnlyMode::clearCache.
A service class for fetching the wiki's current read-only mode.
processing should stop and the error should be shown to the user * false