@@ -22,103 +22,25 @@ public function contextProvider() {
22
22
'2020-05-30 02:00 UTC ' , // "now" time
23
23
[ 'enabled ' => false ], // value for Announcement in app_config.php
24
24
false , // should be displayed or not
25
- null , // shutdown warning message
25
+ null , // maintenance message
26
26
],
27
27
'announcement enabled ' => [
28
28
'2020-05-30 02:00 UTC ' ,
29
29
[ 'enabled ' => true ],
30
30
true ,
31
- null
32
- ],
33
- 'announcement disabled, hide in 1 minute ' => [
34
- '2020-05-30 01:59 UTC ' ,
35
- [ 'enabled ' => false , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
36
- false ,
37
- null ,
38
- ],
39
- 'announcement enabled, 11 minutes to go, without warning ' => [
40
- '2020-05-30 01:49:00 UTC ' ,
41
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
42
- true ,
43
- null ,
44
- ],
45
- 'announcement enabled, 11 minutes to go, with warning ' => [
46
- '2020-05-30 01:49:00 UTC ' ,
47
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
48
- true ,
49
- null ,
31
+ null , // no maintenance message since no maintenance is scheduled
50
32
],
51
33
'announcement enabled, 10 minutes 59 seconds to go, with warning ' => [
52
34
'2020-05-30 01:49:01 UTC ' ,
53
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
54
- true ,
55
- 'in 10 minutes ' ,
56
- ],
57
- 'announcement enabled, 10 minutes to go, with warning ' => [
58
- '2020-05-30 01:50 UTC ' ,
59
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
35
+ [ 'enabled ' => true , 'maintenance ' => ['start ' => '2020-05-30 02:00 UTC ' ] ],
60
36
true ,
61
- 'in 10 minutes ' ,
37
+ 'Tatoeba will temporarily shut down for maintenance in 10 minutes. ' ,
62
38
],
63
39
'announcement enabled, 1 minute to go, with warning ' => [
64
40
'2020-05-30 01:59 UTC ' ,
65
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
66
- true ,
67
- 'in 1 minute ' ,
68
- ],
69
- 'announcement enabled, 59 seconds to go, with warning ' => [
70
- '2020-05-30 01:59:01 UTC ' ,
71
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
41
+ [ 'enabled ' => true , 'maintenance ' => ['start ' => '2020-05-30 02:00 UTC ' ] ],
72
42
true ,
73
- 'in 59 seconds ' ,
74
- ],
75
- 'announcement enabled, 1 second to go, with warning ' => [
76
- '2020-05-30 01:59:59 UTC ' ,
77
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' , 'shutdownWarning ' => true ],
78
- true ,
79
- 'in 1 second ' ,
80
- ],
81
- 'announcement enabled, hide exactly now, without warning ' => [
82
- '2020-05-30 02:00 UTC ' ,
83
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
84
- false ,
85
- null ,
86
- ],
87
- 'announcement enabled, hide exactly now, with warning ' => [
88
- '2020-05-30 02:00 UTC ' ,
89
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
90
- false ,
91
- null ,
92
- ],
93
- 'announcement enabled, hide 1 second ago ' => [
94
- '2020-05-30 02:00:01 UTC ' ,
95
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
96
- false ,
97
- null ,
98
- ],
99
- 'announcement enabled, hide 1 minute ago ' => [
100
- '2020-05-30 02:01 UTC ' ,
101
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
102
- false ,
103
- null ,
104
- ],
105
- 'announcement enabled, hide 10 years ago ' => [
106
- '2030-05-30 02:00 UTC ' ,
107
- [ 'enabled ' => true , 'hideAfter ' => '2020-05-30 02:00 UTC ' ],
108
- false ,
109
- null ,
110
- ],
111
- 'announcement enabled, hideAfter empty ' => [
112
- '2020-05-30 02:00 UTC ' ,
113
- [ 'enabled ' => true , 'hideAfter ' => '' ],
114
- true ,
115
- null ,
116
- ],
117
- 'announcement enabled, hideAfter invalid ' => [
118
- '2020-05-30 02:00 UTC ' ,
119
- [ 'enabled ' => true , 'hideAfter ' => 'foobar ' ],
120
- true ,
121
- null ,
43
+ 'Tatoeba will temporarily shut down for maintenance in 1 minute. ' ,
122
44
],
123
45
];
124
46
}
@@ -130,14 +52,18 @@ public function testEverything($now, $config, $shouldShow, $warning)
130
52
{
131
53
Time::setTestNow (new Time ($ now ));
132
54
$ helper = $ this ->createHelperWithConfig ($ config );
133
-
55
+
134
56
$ this ->assertEquals ($ shouldShow , $ helper ->isDisplayed ());
57
+ $ maintenanceMessage = $ helper ->getMaintenanceMessage ();
58
+
135
59
if (is_null ($ warning )) {
136
- $ this ->assertNull ($ helper ->shutdownWarning ());
60
+ $ this ->assertEmpty ($ maintenanceMessage );
61
+ } elseif (is_string ($ maintenanceMessage )) {
62
+ $ this ->assertContains ($ warning , $ maintenanceMessage );
137
63
} else {
138
- $ this ->assertContains ( $ warning , $ helper -> shutdownWarning ( ));
64
+ $ this ->fail ( ' getMaintenanceMessage returned an unexpected value: ' . var_export ( $ maintenanceMessage , true ));
139
65
}
140
-
66
+
141
67
Time::setTestNow ();
142
68
}
143
69
}
0 commit comments