@@ -22,103 +22,68 @@ 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
],
39
+
63
40
'announcement enabled, 1 minute to go, with warning ' => [
64
41
'2020-05-30 01:59 UTC ' ,
65
- [ 'enabled ' => true , 'hideAfter ' => ' 2020-05-30 02:00 UTC ', ' shutdownWarning ' => true ],
42
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
66
43
true ,
67
- 'in 1 minute ' ,
44
+ 'Tatoeba will temporarily shut down for maintenance in 1 minute. ' ,
68
45
],
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 ],
46
+ 'announcement enabled, 1 hour to go, with warning ' => [
47
+ '2020-05-30 01:00 UTC ' ,
48
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
72
49
true ,
73
- 'in 59 seconds ' ,
50
+ 'Tatoeba will temporarily shut down for maintenance in 1 hour. ' ,
74
51
],
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 ],
52
+ 'announcement enabled, 2 hours to go, with warning ' => [
53
+ '2020-05-30 00:00 UTC ' ,
54
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
78
55
true ,
79
- 'in 1 second ' ,
56
+ 'Tatoeba will temporarily shut down for maintenance in 2 hours. ' ,
80
57
],
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 ,
58
+ 'announcement enabled, 1 day to go, with warning ' => [
59
+ '2020-05-29 02:00 UTC ' ,
60
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
61
+ true ,
62
+ ' Tatoeba will temporarily shut down for maintenance in 1 day. ' ,
86
63
],
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 ,
64
+ 'announcement enabled, 3 days to go , with warning ' => [
65
+ '2020-05-27 02:00 UTC ' ,
66
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
67
+ true ,
68
+ ' Tatoeba will temporarily shut down for maintenance in 3 days. ' ,
92
69
],
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 ,
70
+ 'announcement enabled, 1 week to go, with warning ' => [
71
+ '2020-05-23 02:00 UTC ' ,
72
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC '] ],
73
+ true ,
74
+ ' Tatoeba will temporarily shut down for maintenance on 30 May 2020 at 02:00 UTC, which is in 7 days. ' ,
98
75
],
99
- 'announcement enabled, hide 1 minute ago ' => [
76
+ 'announcement enabled, 1 minute ago, with warning ' => [
100
77
'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 ' => '' ],
78
+ [ 'enabled ' => true , 'maintenance ' => ['start ' => '2020-05-30 02:00 UTC ' ] ],
114
79
true ,
115
- null ,
80
+ ' Tatoeba will temporarily shut down for maintenance on 30 May 2020 at 02:00 UTC, which is in -1 minute. ' ,
116
81
],
117
- 'announcement enabled, hideAfter invalid ' => [
118
- '2020-05 -30 02:00 UTC ' ,
119
- [ 'enabled ' => true , 'hideAfter ' => ' foobar ' ],
82
+ 'announcement enabled, 1 month to go, with warning ' => [
83
+ '2020-04 -30 02:00 UTC ' ,
84
+ [ 'enabled ' => true , 'maintenance ' => [ ' start ' => ' 2020-05-30 02:00 UTC ' ] ],
120
85
true ,
121
- null ,
86
+ ' Tatoeba will temporarily shut down for maintenance on 30 May 2020 at 02:00 UTC, which is in 30 days. ' ,
122
87
],
123
88
];
124
89
}
@@ -130,14 +95,18 @@ public function testEverything($now, $config, $shouldShow, $warning)
130
95
{
131
96
Time::setTestNow (new Time ($ now ));
132
97
$ helper = $ this ->createHelperWithConfig ($ config );
133
-
98
+
134
99
$ this ->assertEquals ($ shouldShow , $ helper ->isDisplayed ());
100
+ $ maintenanceMessage = $ helper ->getMaintenanceMessage ();
101
+
135
102
if (is_null ($ warning )) {
136
- $ this ->assertNull ($ helper ->shutdownWarning ());
103
+ $ this ->assertEmpty ($ maintenanceMessage );
104
+ } elseif (is_string ($ maintenanceMessage )) {
105
+ $ this ->assertContains ($ warning , $ maintenanceMessage );
137
106
} else {
138
- $ this ->assertContains ( $ warning , $ helper -> shutdownWarning ( ));
107
+ $ this ->fail ( ' getMaintenanceMessage returned an unexpected value: ' . var_export ( $ maintenanceMessage , true ));
139
108
}
140
-
109
+
141
110
Time::setTestNow ();
142
111
}
143
112
}
0 commit comments