X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flogging%2FProtectLogFormatterTest.php;h=1c076cab04fcb2ae3a571b7795b56a3876cbbbc4;hp=718c08c43a8bd21d759f43aeff8b839f16adab81;hb=c368a4313b4183af56b0d566e1f7529ba997a110;hpb=9e6032545bfb638963ac999420942b60ef82e240 diff --git a/tests/phpunit/includes/logging/ProtectLogFormatterTest.php b/tests/phpunit/includes/logging/ProtectLogFormatterTest.php index 718c08c43a..1c076cab04 100644 --- a/tests/phpunit/includes/logging/ProtectLogFormatterTest.php +++ b/tests/phpunit/includes/logging/ProtectLogFormatterTest.php @@ -1,5 +1,8 @@ 'protect', 'action' => 'protect', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '5:bool:cascade' => false, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - ), - ), - ), - array( - 'text' => 'User protected ProtectPage [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)', - 'api' => array( + ], + ], + ], + ], + [ + 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' . + '(indefinite) [Move=Allow only administrators] (indefinite)', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => false, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], // Current format with cascade - array( - array( + [ + [ 'type' => 'protect', 'action' => 'protect', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '5:bool:cascade' => true, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => true, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - ), - ), - ), - array( - 'text' => 'User protected ProtectPage [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) [cascading]', - 'api' => array( + ], + ], + ], + ], + [ + 'text' => 'User protected ProtectPage [Edit=Allow only administrators] ' . + '(indefinite) [Move=Allow only administrators] (indefinite) [cascading]', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => true, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], // Legacy format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'protect', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '', - ), - ), - array( + ], + ], + [ 'legacy' => true, 'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)', - 'api' => array( + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => false, - ), - ), - ), + ], + ], + ], // Legacy format with cascade - array( - array( + [ + [ 'type' => 'protect', 'action' => 'protect', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade', - ), - ), - array( + ], + ], + [ 'legacy' => true, - 'text' => 'User protected ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]', - 'api' => array( + 'text' => 'User protected ProtectPage [edit=sysop] ' . + '(indefinite)[move=sysop] (indefinite) [cascading]', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - ), - ), - ), - ); + ], + ], + ], + ]; } - /** * @dataProvider provideProtectLogDatabaseRows */ @@ -171,156 +176,161 @@ class ProtectLogFormatterTest extends LogFormatterTestCase { * Do not change the existing data, just add a new database row */ public static function provideModifyLogDatabaseRows() { - return array( + return [ // Current format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'modify', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '5:bool:cascade' => false, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - ), - ), - ), - array( - 'text' => 'User changed protection level for ProtectPage [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)', - 'api' => array( + ], + ], + ], + ], + [ + 'text' => 'User changed protection level for ProtectPage ' . + '[Edit=Allow only administrators] ' . + '(indefinite) [Move=Allow only administrators] (indefinite)', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => false, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], // Current format with cascade - array( - array( + [ + [ 'type' => 'protect', 'action' => 'modify', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '4::description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '5:bool:cascade' => true, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => true, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinity', 'cascade' => false, - ), - ), - ), - ), - array( - 'text' => 'User changed protection level for ProtectPage [Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite) [cascading]', - 'api' => array( + ], + ], + ], + ], + [ + 'text' => 'User changed protection level for ProtectPage ' . + '[Edit=Allow only administrators] (indefinite) ' . + '[Move=Allow only administrators] (indefinite) [cascading]', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - 'details' => array( - array( + 'details' => [ + [ 'type' => 'edit', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => true, - ), - array( + ], + [ 'type' => 'move', 'level' => 'sysop', 'expiry' => 'infinite', 'cascade' => false, - ), - ), - ), - ), - ), + ], + ], + ], + ], + ], // Legacy format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'modify', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '[edit=sysop] (indefinite)[move=sysop] (indefinite)', '', - ), - ), - array( + ], + ], + [ 'legacy' => true, - 'text' => 'User changed protection level for ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite)', - 'api' => array( + 'text' => 'User changed protection level for ProtectPage ' . + '[edit=sysop] (indefinite)[move=sysop] (indefinite)', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => false, - ), - ), - ), + ], + ], + ], // Legacy format with cascade - array( - array( + [ + [ 'type' => 'protect', 'action' => 'modify', 'comment' => 'protect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array( + 'params' => [ '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade', - ), - ), - array( + ], + ], + [ 'legacy' => true, - 'text' => 'User changed protection level for ProtectPage [edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]', - 'api' => array( + 'text' => 'User changed protection level for ProtectPage ' . + '[edit=sysop] (indefinite)[move=sysop] (indefinite) [cascading]', + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - ), - ), - ), - ); + ], + ], + ], + ]; } - /** * @dataProvider provideModifyLogDatabaseRows */ @@ -334,26 +344,25 @@ class ProtectLogFormatterTest extends LogFormatterTestCase { * Do not change the existing data, just add a new database row */ public static function provideUnprotectLogDatabaseRows() { - return array( + return [ // Current format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'unprotect', 'comment' => 'unprotect comment', 'namespace' => NS_MAIN, 'title' => 'ProtectPage', - 'params' => array(), - ), - array( + 'params' => [], + ], + [ 'text' => 'User removed protection from ProtectPage', - 'api' => array(), - ), - ), - ); + 'api' => [], + ], + ], + ]; } - /** * @dataProvider provideUnprotectLogDatabaseRows */ @@ -367,50 +376,50 @@ class ProtectLogFormatterTest extends LogFormatterTestCase { * Do not change the existing data, just add a new database row */ public static function provideMoveProtLogDatabaseRows() { - return array( + return [ // Current format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'move_prot', 'comment' => 'Move comment', 'namespace' => NS_MAIN, 'title' => 'NewPage', - 'params' => array( + 'params' => [ '4::oldtitle' => 'OldPage', - ), - ), - array( + ], + ], + [ 'text' => 'User moved protection settings from OldPage to NewPage', - 'api' => array( + 'api' => [ 'oldtitle_ns' => 0, 'oldtitle_title' => 'OldPage', - ), - ), - ), + ], + ], + ], // Legacy format - array( - array( + [ + [ 'type' => 'protect', 'action' => 'move_prot', 'comment' => 'Move comment', 'namespace' => NS_MAIN, 'title' => 'NewPage', - 'params' => array( + 'params' => [ 'OldPage', - ), - ), - array( + ], + ], + [ 'legacy' => true, 'text' => 'User moved protection settings from OldPage to NewPage', - 'api' => array( + 'api' => [ 'oldtitle_ns' => 0, 'oldtitle_title' => 'OldPage', - ), - ), - ), - ); + ], + ], + ], + ]; } /**