Add @covers tags to logging tests
[lhc/web/wiklou.git] / tests / phpunit / includes / logging / NewUsersLogFormatterTest.php
index 5b03370..8317e91 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 
 /**
+ * @covers NewUsersLogFormatter
  * @group Database
  */
 class NewUsersLogFormatterTest extends LogFormatterTestCase {
@@ -9,13 +10,13 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                parent::setUp();
 
                // Register LogHandler, see $wgNewUserLog in Setup.php
-               $this->mergeMwGlobalArrayValue( 'wgLogActionsHandlers', array(
+               $this->mergeMwGlobalArrayValue( 'wgLogActionsHandlers', [
                        'newusers/newusers' => 'NewUsersLogFormatter',
                        'newusers/create' => 'NewUsersLogFormatter',
                        'newusers/create2' => 'NewUsersLogFormatter',
                        'newusers/byemail' => 'NewUsersLogFormatter',
                        'newusers/autocreate' => 'NewUsersLogFormatter',
-               ) );
+               ] );
        }
 
        /**
@@ -24,10 +25,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideNewUsersLogDatabaseRows() {
-               return array(
+               return [
                        // Only old logs
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => 'newusers',
                                        'action' => 'newusers',
                                        'comment' => 'newusers comment',
@@ -35,15 +36,15 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'user_text' => 'New user',
                                        'namespace' => NS_USER,
                                        'title' => 'New user',
-                                       'params' => array(),
-                               ),
-                               array(
+                                       'params' => [],
+                               ],
+                               [
                                        'legacy' => true,
                                        'text' => 'User account New user was created',
-                                       'api' => array(),
-                               ),
-                       ),
-               );
+                                       'api' => [],
+                               ],
+                       ],
+               ];
        }
 
        /**
@@ -59,10 +60,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideCreateLogDatabaseRows() {
-               return array(
+               return [
                        // Current format
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => 'newusers',
                                        'action' => 'create',
                                        'comment' => 'newusers comment',
@@ -70,18 +71,18 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'user_text' => 'New user',
                                        'namespace' => NS_USER,
                                        'title' => 'New user',
-                                       'params' => array(
+                                       'params' => [
                                                '4::userid' => 1,
-                                       ),
-                               ),
-                               array(
+                                       ],
+                               ],
+                               [
                                        'text' => 'User account New user was created',
-                                       'api' => array(
+                                       'api' => [
                                                'userid' => 1,
-                                       ),
-                               ),
-                       ),
-               );
+                                       ],
+                               ],
+                       ],
+               ];
        }
 
        /**
@@ -97,35 +98,33 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideCreate2LogDatabaseRows() {
-               return array(
+               return [
                        // Current format
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => 'newusers',
                                        'action' => 'create2',
                                        'comment' => 'newusers comment',
                                        'user' => 0,
                                        'user_text' => 'User',
                                        'namespace' => NS_USER,
-                                       'title' => 'UTSysop',
-                                       'params' => array(
-                                               '4::userid' => 1,
-                                       ),
-                               ),
-                               array(
-                                       'text' => 'User account UTSysop was created by User',
-                                       'api' => array(
-                                               'userid' => 1,
-                                       ),
-                               ),
-                       ),
-               );
+                                       'title' => 'UTSysop'
+                               ],
+                               [
+                                       'text' => 'User account UTSysop was created by User'
+                               ],
+                       ],
+               ];
        }
 
        /**
         * @dataProvider provideCreate2LogDatabaseRows
         */
        public function testCreate2LogDatabaseRows( $row, $extra ) {
+               // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
+               $user = static::getTestSysop()->getUser();
+               $row['params']['4::userid'] = $user->getId();
+               $extra['api']['userid'] = $user->getId();
                $this->doTestLogFormatter( $row, $extra );
        }
 
@@ -135,35 +134,33 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideByemailLogDatabaseRows() {
-               return array(
+               return [
                        // Current format
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => 'newusers',
                                        'action' => 'byemail',
                                        'comment' => 'newusers comment',
                                        'user' => 0,
                                        'user_text' => 'Sysop',
                                        'namespace' => NS_USER,
-                                       'title' => 'UTSysop',
-                                       'params' => array(
-                                               '4::userid' => 1,
-                                       ),
-                               ),
-                               array(
-                                       'text' => 'User account UTSysop was created by Sysop and password was sent by email',
-                                       'api' => array(
-                                               'userid' => 1,
-                                       ),
-                               ),
-                       ),
-               );
+                                       'title' => 'UTSysop'
+                               ],
+                               [
+                                       'text' => 'User account UTSysop was created by Sysop and password was sent by email'
+                               ],
+                       ],
+               ];
        }
 
        /**
         * @dataProvider provideByemailLogDatabaseRows
         */
        public function testByemailLogDatabaseRows( $row, $extra ) {
+               // Make UTSysop user and use its user_id (sequence does not reset to 1 for postgres)
+               $user = static::getTestSysop()->getUser();
+               $row['params']['4::userid'] = $user->getId();
+               $extra['api']['userid'] = $user->getId();
                $this->doTestLogFormatter( $row, $extra );
        }
 
@@ -173,10 +170,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * Do not change the existing data, just add a new database row
         */
        public static function provideAutocreateLogDatabaseRows() {
-               return array(
+               return [
                        // Current format
-                       array(
-                               array(
+                       [
+                               [
                                        'type' => 'newusers',
                                        'action' => 'autocreate',
                                        'comment' => 'newusers comment',
@@ -184,18 +181,18 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'user_text' => 'New user',
                                        'namespace' => NS_USER,
                                        'title' => 'New user',
-                                       'params' => array(
+                                       'params' => [
                                                '4::userid' => 1,
-                                       ),
-                               ),
-                               array(
+                                       ],
+                               ],
+                               [
                                        'text' => 'User account New user was created automatically',
-                                       'api' => array(
+                                       'api' => [
                                                'userid' => 1,
-                                       ),
-                               ),
-                       ),
-               );
+                                       ],
+                               ],
+                       ],
+               ];
        }
 
        /**