Add @covers tags to logging tests
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / RightsLogFormatterTest.php
index e9577f1..d081c61 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @covers RightsLogFormatter
+ */
 class RightsLogFormatterTest extends LogFormatterTestCase {
 
        /**
@@ -8,10 +11,10 @@ class RightsLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideRightsLogDatabaseRows() {
-               return array(
+               return [
                        // Current format
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => '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(
-                                       'text' => 'Sysop changed group membership for User:User from (none) to '
+                                       '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:User from (none) to '
+                                       '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:User',
-                                       'api' => array(),
-                               ),
-                       ),
-               );
+                                       'text' => 'Sysop changed group membership for User',
+                                       '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' ],
+                                               ],
+                                       ],
+                               ],
+                       ],
+               ];
        }
 
        /**