X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Flogging%2FRightsLogFormatterTest.php;h=d081c61bb766056fe5937841863a7e21008dc6c6;hp=6e4c589504eae56838c0d65c5e97fccc2be42762;hb=c368a4313b4183af56b0d566e1f7529ba997a110;hpb=376879ee06871beb31ca540bbcc87843aa2fb744 diff --git a/tests/phpunit/includes/logging/RightsLogFormatterTest.php b/tests/phpunit/includes/logging/RightsLogFormatterTest.php index 6e4c589504..d081c61bb7 100644 --- a/tests/phpunit/includes/logging/RightsLogFormatterTest.php +++ b/tests/phpunit/includes/logging/RightsLogFormatterTest.php @@ -1,5 +1,8 @@ 'rights', 'action' => 'rights', 'comment' => 'rights comment', @@ -19,24 +22,64 @@ class RightsLogFormatterTest extends LogFormatterTestCase { 'user_text' => 'Sysop', 'namespace' => NS_USER, 'title' => 'User', - 'params' => array( - '4::oldgroups' => array(), - '5::newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - array( + 'params' => [ + '4::oldgroups' => [], + '5::newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [], + 'newmetadata' => [ + [ 'expiry' => null ], + [ 'expiry' => '20160101123456' ] + ], + ], + ], + [ + 'text' => 'Sysop changed group membership for User from (none) to ' + . 'bureaucrat (temporary, until 12:34, 1 January 2016) and administrator', + 'api' => [ + 'oldgroups' => [], + 'newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [], + 'newmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + [ 'group' => 'bureaucrat', 'expiry' => '2016-01-01T12:34:56Z' ], + ], + ], + ], + ], + + // Previous format (oldgroups and newgroups as arrays, no metadata) + [ + [ + 'type' => 'rights', + 'action' => 'rights', + 'comment' => 'rights comment', + 'user' => 0, + 'user_text' => 'Sysop', + 'namespace' => NS_USER, + 'title' => 'User', + 'params' => [ + '4::oldgroups' => [], + '5::newgroups' => [ 'sysop', 'bureaucrat' ], + ], + ], + [ 'text' => 'Sysop changed group membership for User from (none) to ' . 'administrator and bureaucrat', - 'api' => array( - 'oldgroups' => array(), - 'newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - ), + 'api' => [ + 'oldgroups' => [], + 'newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [], + 'newmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ], + ], + ], + ], + ], - // Legacy format - array( - array( + // Legacy format (oldgroups and newgroups as numeric-keyed strings) + [ + [ 'type' => 'rights', 'action' => 'rights', 'comment' => 'rights comment', @@ -44,25 +87,30 @@ class RightsLogFormatterTest extends LogFormatterTestCase { 'user_text' => 'Sysop', 'namespace' => NS_USER, 'title' => 'User', - 'params' => array( + 'params' => [ '', 'sysop, bureaucrat', - ), - ), - array( + ], + ], + [ 'legacy' => true, 'text' => 'Sysop changed group membership for User from (none) to ' . 'administrator and bureaucrat', - 'api' => array( - 'oldgroups' => array(), - 'newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - ), + 'api' => [ + 'oldgroups' => [], + 'newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [], + 'newmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ], + ], + ], + ], + ], // Really old entry - array( - array( + [ + [ 'type' => 'rights', 'action' => 'rights', 'comment' => 'rights comment', @@ -70,15 +118,15 @@ class RightsLogFormatterTest extends LogFormatterTestCase { 'user_text' => 'Sysop', 'namespace' => NS_USER, 'title' => 'User', - 'params' => array(), - ), - array( + 'params' => [], + ], + [ 'legacy' => true, 'text' => 'Sysop changed group membership for User', - 'api' => array(), - ), - ), - ); + 'api' => [], + ], + ], + ]; } /** @@ -94,10 +142,10 @@ class RightsLogFormatterTest extends LogFormatterTestCase { * Do not change the existing data, just add a new database row */ public static function provideAutopromoteLogDatabaseRows() { - return array( + return [ // Current format - array( - array( + [ + [ 'type' => 'rights', 'action' => 'autopromote', 'comment' => 'rights comment', @@ -105,24 +153,31 @@ class RightsLogFormatterTest extends LogFormatterTestCase { 'user_text' => 'Sysop', 'namespace' => NS_USER, 'title' => 'Sysop', - 'params' => array( - '4::oldgroups' => array( 'sysop' ), - '5::newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - array( + 'params' => [ + '4::oldgroups' => [ 'sysop' ], + '5::newgroups' => [ 'sysop', 'bureaucrat' ], + ], + ], + [ 'text' => 'Sysop was automatically promoted from administrator to ' . 'administrator and bureaucrat', - 'api' => array( - 'oldgroups' => array( 'sysop' ), - 'newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - ), + 'api' => [ + 'oldgroups' => [ 'sysop' ], + 'newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + ], + 'newmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ], + ], + ], + ], + ], // Legacy format - array( - array( + [ + [ 'type' => 'rights', 'action' => 'autopromote', 'comment' => 'rights comment', @@ -130,22 +185,29 @@ class RightsLogFormatterTest extends LogFormatterTestCase { 'user_text' => 'Sysop', 'namespace' => NS_USER, 'title' => 'Sysop', - 'params' => array( + 'params' => [ 'sysop', 'sysop, bureaucrat', - ), - ), - array( + ], + ], + [ 'legacy' => true, 'text' => 'Sysop was automatically promoted from administrator to ' . 'administrator and bureaucrat', - 'api' => array( - 'oldgroups' => array( 'sysop' ), - 'newgroups' => array( 'sysop', 'bureaucrat' ), - ), - ), - ), - ); + 'api' => [ + 'oldgroups' => [ 'sysop' ], + 'newgroups' => [ 'sysop', 'bureaucrat' ], + 'oldmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + ], + 'newmetadata' => [ + [ 'group' => 'sysop', 'expiry' => 'infinity' ], + [ 'group' => 'bureaucrat', 'expiry' => 'infinity' ], + ], + ], + ], + ], + ]; } /**