Merge "Caching documentation tweaks and doxygen cleanups"
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / RightsLogFormatterTest.php
1 <?php
2
3 class RightsLogFormatterTest 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 provideRightsLogDatabaseRows() {
11 return array(
12 // Current format
13 array(
14 array(
15 'type' => 'rights',
16 'action' => 'rights',
17 'comment' => 'rights comment',
18 'user' => 0,
19 'user_text' => 'Sysop',
20 'namespace' => NS_USER,
21 'title' => 'User',
22 'params' => array(
23 '4::oldgroups' => array(),
24 '5::newgroups' => array( 'sysop', 'bureaucrat' ),
25 ),
26 ),
27 array(
28 'text' => 'Sysop changed group membership for User from (none) to '
29 . 'administrator and bureaucrat',
30 'api' => array(
31 'oldgroups' => array(),
32 'newgroups' => array( 'sysop', 'bureaucrat' ),
33 ),
34 ),
35 ),
36
37 // Legacy format
38 array(
39 array(
40 'type' => 'rights',
41 'action' => 'rights',
42 'comment' => 'rights comment',
43 'user' => 0,
44 'user_text' => 'Sysop',
45 'namespace' => NS_USER,
46 'title' => 'User',
47 'params' => array(
48 '',
49 'sysop, bureaucrat',
50 ),
51 ),
52 array(
53 'legacy' => true,
54 'text' => 'Sysop changed group membership for User from (none) to '
55 . 'administrator and bureaucrat',
56 'api' => array(
57 'oldgroups' => array(),
58 'newgroups' => array( 'sysop', 'bureaucrat' ),
59 ),
60 ),
61 ),
62
63 // Really old entry
64 array(
65 array(
66 'type' => 'rights',
67 'action' => 'rights',
68 'comment' => 'rights comment',
69 'user' => 0,
70 'user_text' => 'Sysop',
71 'namespace' => NS_USER,
72 'title' => 'User',
73 'params' => array(),
74 ),
75 array(
76 'legacy' => true,
77 'text' => 'Sysop changed group membership for User',
78 'api' => array(),
79 ),
80 ),
81 );
82 }
83
84 /**
85 * @dataProvider provideRightsLogDatabaseRows
86 */
87 public function testRightsLogDatabaseRows( $row, $extra ) {
88 $this->doTestLogFormatter( $row, $extra );
89 }
90
91 /**
92 * Provide different rows from the logging table to test
93 * for backward compatibility.
94 * Do not change the existing data, just add a new database row
95 */
96 public static function provideAutopromoteLogDatabaseRows() {
97 return array(
98 // Current format
99 array(
100 array(
101 'type' => 'rights',
102 'action' => 'autopromote',
103 'comment' => 'rights comment',
104 'user' => 0,
105 'user_text' => 'Sysop',
106 'namespace' => NS_USER,
107 'title' => 'Sysop',
108 'params' => array(
109 '4::oldgroups' => array( 'sysop' ),
110 '5::newgroups' => array( 'sysop', 'bureaucrat' ),
111 ),
112 ),
113 array(
114 'text' => 'Sysop was automatically promoted from administrator to '
115 . 'administrator and bureaucrat',
116 'api' => array(
117 'oldgroups' => array( 'sysop' ),
118 'newgroups' => array( 'sysop', 'bureaucrat' ),
119 ),
120 ),
121 ),
122
123 // Legacy format
124 array(
125 array(
126 'type' => 'rights',
127 'action' => 'autopromote',
128 'comment' => 'rights comment',
129 'user' => 0,
130 'user_text' => 'Sysop',
131 'namespace' => NS_USER,
132 'title' => 'Sysop',
133 'params' => array(
134 'sysop',
135 'sysop, bureaucrat',
136 ),
137 ),
138 array(
139 'legacy' => true,
140 'text' => 'Sysop was automatically promoted from administrator to '
141 . 'administrator and bureaucrat',
142 'api' => array(
143 'oldgroups' => array( 'sysop' ),
144 'newgroups' => array( 'sysop', 'bureaucrat' ),
145 ),
146 ),
147 ),
148 );
149 }
150
151 /**
152 * @dataProvider provideAutopromoteLogDatabaseRows
153 */
154 public function testAutopromoteLogDatabaseRows( $row, $extra ) {
155 $this->doTestLogFormatter( $row, $extra );
156 }
157 }