X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flogging%2FProtectLogFormatterTest.php;h=1c076cab04fcb2ae3a571b7795b56a3876cbbbc4;hb=1c65dd29a3c77173625b9a0f8b59ea1c1c12fc2c;hp=8010b77383f877977887cf1ba138d74e5acde7a9;hpb=23299ca8790bcf1aebcf54e0932b94338e630474;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/logging/ProtectLogFormatterTest.php b/tests/phpunit/includes/logging/ProtectLogFormatterTest.php index 8010b77383..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( + '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( + '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( + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -173,159 +176,159 @@ 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( + '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( + '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( + '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( + 'api' => [ 'description' => '[edit=sysop] (indefinite)[move=sysop] (indefinite)', 'cascade' => true, - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -341,23 +344,23 @@ 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' => [], + ], + ], + ]; } /** @@ -373,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', - ), - ), - ), - ); + ], + ], + ], + ]; } /**