2015-07-07 20:36:41 +00:00
|
|
|
<?php
|
|
|
|
|
|
2017-12-25 07:26:01 +00:00
|
|
|
/**
|
|
|
|
|
* @covers ProtectLogFormatter
|
|
|
|
|
*/
|
2015-07-07 20:36:41 +00:00
|
|
|
class ProtectLogFormatterTest extends LogFormatterTestCase {
|
|
|
|
|
|
2015-08-22 18:29:00 +00:00
|
|
|
/**
|
|
|
|
|
* 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 provideProtectLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-08-22 18:29:00 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'protect',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'5:bool:cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-10-03 13:04:51 +00:00
|
|
|
'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
|
|
|
|
|
'(indefinite) [Move=Allow only administrators] (indefinite)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Current format with cascade
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'protect',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'5:bool:cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-10-03 13:04:51 +00:00
|
|
|
'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' .
|
|
|
|
|
'(indefinite) [Move=Allow only administrators] (indefinite) [cascading]',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Legacy format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'protect',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'legacy' => true,
|
|
|
|
|
'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Legacy format with cascade
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'protect',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'legacy' => true,
|
2015-10-03 13:04:51 +00:00
|
|
|
'text' => 'User protected ProtectPage [edit=sysop] ' .
|
|
|
|
|
'(indefinite)[move=sysop] (indefinite) [cascading]',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-08-22 18:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideProtectLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testProtectLogDatabaseRows( $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 provideModifyLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-08-22 18:29:00 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'modify',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'5:bool:cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2021-04-21 10:41:09 +00:00
|
|
|
'text' => 'User changed protection settings for ProtectPage ' .
|
2015-10-03 13:04:51 +00:00
|
|
|
'[Edit=Allow only administrators] ' .
|
|
|
|
|
'(indefinite) [Move=Allow only administrators] (indefinite)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Current format with cascade
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'modify',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'5:bool:cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinity',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2021-04-21 10:41:09 +00:00
|
|
|
'text' => 'User changed protection settings for ProtectPage ' .
|
2015-10-03 13:44:47 +00:00
|
|
|
'[Edit=Allow only administrators] (indefinite) ' .
|
|
|
|
|
'[Move=Allow only administrators] (indefinite) [cascading]',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
'details' => [
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'edit',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'move',
|
|
|
|
|
'level' => 'sysop',
|
|
|
|
|
'expiry' => 'infinite',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Legacy format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'modify',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'legacy' => true,
|
2021-04-21 10:41:09 +00:00
|
|
|
'text' => 'User changed protection settings for ProtectPage ' .
|
2015-10-03 13:04:51 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => false,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-08-22 18:29:00 +00:00
|
|
|
|
|
|
|
|
// Legacy format with cascade
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'modify',
|
|
|
|
|
'comment' => 'protect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'legacy' => true,
|
2021-04-21 10:41:09 +00:00
|
|
|
'text' => 'User changed protection settings for ProtectPage ' .
|
2015-10-03 13:04:51 +00:00
|
|
|
'[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-08-22 18:29:00 +00:00
|
|
|
'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)',
|
|
|
|
|
'cascade' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-08-22 18:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideModifyLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testModifyLogDatabaseRows( $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 provideUnprotectLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-08-22 18:29:00 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'unprotect',
|
|
|
|
|
'comment' => 'unprotect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-08-22 18:29:00 +00:00
|
|
|
'text' => 'User removed protection from ProtectPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-08-22 18:29:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideUnprotectLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testUnprotectLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-07 20:36:41 +00:00
|
|
|
/**
|
|
|
|
|
* 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 provideMoveProtLogDatabaseRows() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2015-07-07 20:36:41 +00:00
|
|
|
// Current format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-07-07 20:36:41 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'move_prot',
|
|
|
|
|
'comment' => 'Move comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'NewPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-07-07 20:36:41 +00:00
|
|
|
'4::oldtitle' => 'OldPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-07-07 20:36:41 +00:00
|
|
|
'text' => 'User moved protection settings from OldPage to NewPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-07-07 20:36:41 +00:00
|
|
|
'oldtitle_ns' => 0,
|
|
|
|
|
'oldtitle_title' => 'OldPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
2015-07-07 20:36:41 +00:00
|
|
|
|
|
|
|
|
// Legacy format
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[
|
2015-07-07 20:36:41 +00:00
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'move_prot',
|
|
|
|
|
'comment' => 'Move comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'NewPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'params' => [
|
2015-07-07 20:36:41 +00:00
|
|
|
'OldPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2015-07-07 20:36:41 +00:00
|
|
|
'legacy' => true,
|
|
|
|
|
'text' => 'User moved protection settings from OldPage to NewPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
'api' => [
|
2015-07-07 20:36:41 +00:00
|
|
|
'oldtitle_ns' => 0,
|
|
|
|
|
'oldtitle_title' => 'OldPage',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
];
|
2015-07-07 20:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @dataProvider provideMoveProtLogDatabaseRows
|
|
|
|
|
*/
|
|
|
|
|
public function testMoveProtLogDatabaseRows( $row, $extra ) {
|
|
|
|
|
$this->doTestLogFormatter( $row, $extra );
|
|
|
|
|
}
|
2019-09-27 13:39:15 +00:00
|
|
|
|
|
|
|
|
public function provideGetActionLinks() {
|
|
|
|
|
yield [
|
|
|
|
|
[ 'protect' ],
|
|
|
|
|
true
|
|
|
|
|
];
|
|
|
|
|
yield [
|
|
|
|
|
[],
|
|
|
|
|
false
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string[] $permissions
|
|
|
|
|
* @param bool $shouldMatch
|
|
|
|
|
* @dataProvider provideGetActionLinks
|
|
|
|
|
* @covers ProtectLogFormatter::getActionLinks
|
|
|
|
|
*/
|
|
|
|
|
public function testGetActionLinks( array $permissions, $shouldMatch ) {
|
|
|
|
|
RequestContext::resetMain();
|
|
|
|
|
$user = $this->getTestUser()->getUser();
|
|
|
|
|
$this->overrideUserPermissions( $user, $permissions );
|
|
|
|
|
$row = $this->expandDatabaseRow( [
|
|
|
|
|
'type' => 'protect',
|
|
|
|
|
'action' => 'unprotect',
|
|
|
|
|
'comment' => 'unprotect comment',
|
|
|
|
|
'namespace' => NS_MAIN,
|
|
|
|
|
'title' => 'ProtectPage',
|
|
|
|
|
'params' => [],
|
|
|
|
|
], false );
|
|
|
|
|
$context = new RequestContext();
|
|
|
|
|
$context->setUser( $user );
|
|
|
|
|
$formatter = LogFormatter::newFromRow( $row );
|
|
|
|
|
$formatter->setContext( $context );
|
|
|
|
|
if ( $shouldMatch ) {
|
|
|
|
|
$this->assertStringMatchesFormat(
|
|
|
|
|
'%Aaction=protect%A', $formatter->getActionLinks() );
|
|
|
|
|
} else {
|
|
|
|
|
$this->assertStringNotMatchesFormat(
|
|
|
|
|
'%Aaction=protect%A', $formatter->getActionLinks() );
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-07 20:36:41 +00:00
|
|
|
}
|