2015-04-09 09:09:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
class RightsLogFormatterTest extends LogFormatterTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provide different rows from the logging table to test
|
|
|
|
|
* for backward compatibility.
|
|
|
|
|
* Do not change the existing data, just add a new database row
|
|
|
|
|
*/
|
|
|
|
|
public static function provideRightsLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'rights',
|
|
|
|
|
'action' => 'rights',
|
|
|
|
|
'comment' => 'rights comment',
|
|
|
|
|
'user' => 0,
|
|
|
|
|
'user_text' => 'Sysop',
|
|
|
|
|
'namespace' => NS_USER,
|
|
|
|
|
'title' => 'User',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
|
|
|
|
'4::oldgroups' => [],
|
|
|
|
|
'5::newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-10-09 20:36:47 +00:00
|
|
|
'text' => 'Sysop changed group membership for User from (none) to '
|
2015-04-09 09:09:36 +00:00
|
|
|
. 'administrator and bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
|
|
|
|
'oldgroups' => [],
|
|
|
|
|
'newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Legacy format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'rights',
|
|
|
|
|
'action' => 'rights',
|
|
|
|
|
'comment' => 'rights comment',
|
|
|
|
|
'user' => 0,
|
|
|
|
|
'user_text' => 'Sysop',
|
|
|
|
|
'namespace' => NS_USER,
|
|
|
|
|
'title' => 'User',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'',
|
|
|
|
|
'sysop, bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'legacy' => true,
|
2015-10-09 20:36:47 +00:00
|
|
|
'text' => 'Sysop changed group membership for User from (none) to '
|
2015-04-09 09:09:36 +00:00
|
|
|
. 'administrator and bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
|
|
|
|
'oldgroups' => [],
|
|
|
|
|
'newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Really old entry
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'rights',
|
|
|
|
|
'action' => 'rights',
|
|
|
|
|
'comment' => 'rights comment',
|
|
|
|
|
'user' => 0,
|
|
|
|
|
'user_text' => 'Sysop',
|
|
|
|
|
'namespace' => NS_USER,
|
|
|
|
|
'title' => 'User',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'legacy' => true,
|
2015-10-09 20:36:47 +00:00
|
|
|
'text' => 'Sysop changed group membership for User',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideRightsLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testRightsLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Provide different rows from the logging table to test
|
|
|
|
|
* for backward compatibility.
|
|
|
|
|
* Do not change the existing data, just add a new database row
|
|
|
|
|
*/
|
|
|
|
|
public static function provideAutopromoteLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-04-09 09:09:36 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'rights',
|
|
|
|
|
'action' => 'autopromote',
|
|
|
|
|
'comment' => 'rights comment',
|
|
|
|
|
'user' => 0,
|
|
|
|
|
'user_text' => 'Sysop',
|
|
|
|
|
'namespace' => NS_USER,
|
|
|
|
|
'title' => 'Sysop',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
|
|
|
|
'4::oldgroups' => [ 'sysop' ],
|
|
|
|
|
'5::newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'text' => 'Sysop was automatically promoted from administrator to '
|
|
|
|
|
. 'administrator and bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
|
|
|
|
'oldgroups' => [ 'sysop' ],
|
|
|
|
|
'newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-04-09 09:09:36 +00:00
|
|
|
|
|
|
|
|
// Legacy format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'type' => 'rights',
|
|
|
|
|
'action' => 'autopromote',
|
|
|
|
|
'comment' => 'rights comment',
|
|
|
|
|
'user' => 0,
|
|
|
|
|
'user_text' => 'Sysop',
|
|
|
|
|
'namespace' => NS_USER,
|
|
|
|
|
'title' => 'Sysop',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-04-09 09:09:36 +00:00
|
|
|
'sysop',
|
|
|
|
|
'sysop, bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-04-09 09:09:36 +00:00
|
|
|
'legacy' => true,
|
|
|
|
|
'text' => 'Sysop was automatically promoted from administrator to '
|
|
|
|
|
. 'administrator and bureaucrat',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
|
|
|
|
'oldgroups' => [ 'sysop' ],
|
|
|
|
|
'newgroups' => [ 'sysop', 'bureaucrat' ],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-04-09 09:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideAutopromoteLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testAutopromoteLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
}
|