]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - tests/phpunit/includes/logging/PatrolLogFormatterTest.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / tests / phpunit / includes / logging / PatrolLogFormatterTest.php
1 <?php
2
3 class PatrolLogFormatterTest extends LogFormatterTestCase {
4
5         /**
6          * Provide different rows from the logging table to test
7          * for backward compatibility.
8          * Do not change the existing data, just add a new database row
9          */
10         public static function providePatrolLogDatabaseRows() {
11                 return [
12                         // Current format
13                         [
14                                 [
15                                         'type' => 'patrol',
16                                         'action' => 'patrol',
17                                         'comment' => 'patrol comment',
18                                         'namespace' => NS_MAIN,
19                                         'title' => 'Page',
20                                         'params' => [
21                                                 '4::curid' => 2,
22                                                 '5::previd' => 1,
23                                                 '6::auto' => 0,
24                                         ],
25                                 ],
26                                 [
27                                         'text' => 'User marked revision 2 of page Page patrolled',
28                                         'api' => [
29                                                 'curid' => 2,
30                                                 'previd' => 1,
31                                                 'auto' => false,
32                                         ],
33                                 ],
34                         ],
35
36                         // Current format - autopatrol
37                         [
38                                 [
39                                         'type' => 'patrol',
40                                         'action' => 'patrol',
41                                         'comment' => 'patrol comment',
42                                         'namespace' => NS_MAIN,
43                                         'title' => 'Page',
44                                         'params' => [
45                                                 '4::curid' => 2,
46                                                 '5::previd' => 1,
47                                                 '6::auto' => 1,
48                                         ],
49                                 ],
50                                 [
51                                         'text' => 'User automatically marked revision 2 of page Page patrolled',
52                                         'api' => [
53                                                 'curid' => 2,
54                                                 'previd' => 1,
55                                                 'auto' => true,
56                                         ],
57                                 ],
58                         ],
59
60                         // Legacy format
61                         [
62                                 [
63                                         'type' => 'patrol',
64                                         'action' => 'patrol',
65                                         'comment' => 'patrol comment',
66                                         'namespace' => NS_MAIN,
67                                         'title' => 'Page',
68                                         'params' => [
69                                                 '2',
70                                                 '1',
71                                                 '0',
72                                         ],
73                                 ],
74                                 [
75                                         'legacy' => true,
76                                         'text' => 'User marked revision 2 of page Page patrolled',
77                                         'api' => [
78                                                 'curid' => 2,
79                                                 'previd' => 1,
80                                                 'auto' => false,
81                                         ],
82                                 ],
83                         ],
84
85                         // Legacy format - autopatrol
86                         [
87                                 [
88                                         'type' => 'patrol',
89                                         'action' => 'patrol',
90                                         'comment' => 'patrol comment',
91                                         'namespace' => NS_MAIN,
92                                         'title' => 'Page',
93                                         'params' => [
94                                                 '2',
95                                                 '1',
96                                                 '1',
97                                         ],
98                                 ],
99                                 [
100                                         'legacy' => true,
101                                         'text' => 'User automatically marked revision 2 of page Page patrolled',
102                                         'api' => [
103                                                 'curid' => 2,
104                                                 'previd' => 1,
105                                                 'auto' => true,
106                                         ],
107                                 ],
108                         ],
109                 ];
110         }
111
112         /**
113          * @dataProvider providePatrolLogDatabaseRows
114          */
115         public function testPatrolLogDatabaseRows( $row, $extra ) {
116                 $this->doTestLogFormatter( $row, $extra );
117         }
118 }