Merge "Various test fixes for postgres"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 20 May 2017 19:11:35 +0000 (19:11 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 20 May 2017 19:11:35 +0000 (19:11 +0000)
includes/WatchedItemStore.php
tests/phpunit/includes/logging/NewUsersLogFormatterTest.php
tests/phpunit/includes/pager/RangeChronologicalPagerTest.php

index 228f93b..06f93c6 100644 (file)
@@ -581,7 +581,8 @@ class WatchedItemStore implements StatsdAwareInterface {
                );
 
                foreach ( $res as $row ) {
-                       $timestamps[$row->wl_namespace][$row->wl_title] = $row->wl_notificationtimestamp;
+                       $timestamps[$row->wl_namespace][$row->wl_title] =
+                               wfTimestampOrNull( TS_MW, $row->wl_notificationtimestamp );
                }
 
                return $timestamps;
index c4b52f0..333fd88 100644 (file)
@@ -107,16 +107,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'user' => 0,
                                        'user_text' => 'User',
                                        'namespace' => NS_USER,
-                                       'title' => 'UTSysop',
-                                       'params' => [
-                                               '4::userid' => 1,
-                                       ],
+                                       'title' => 'UTSysop'
                                ],
                                [
-                                       'text' => 'User account UTSysop was created by User',
-                                       'api' => [
-                                               'userid' => 1,
-                                       ],
+                                       'text' => 'User account UTSysop was created by User'
                                ],
                        ],
                ];
@@ -126,6 +120,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * @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 );
        }
 
@@ -145,16 +143,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
                                        'user' => 0,
                                        'user_text' => 'Sysop',
                                        'namespace' => NS_USER,
-                                       'title' => 'UTSysop',
-                                       'params' => [
-                                               '4::userid' => 1,
-                                       ],
+                                       'title' => 'UTSysop'
                                ],
                                [
-                                       'text' => 'User account UTSysop was created by Sysop and password was sent by email',
-                                       'api' => [
-                                               'userid' => 1,
-                                       ],
+                                       'text' => 'User account UTSysop was created by Sysop and password was sent by email'
                                ],
                        ],
                ];
@@ -164,6 +156,10 @@ class NewUsersLogFormatterTest extends LogFormatterTestCase {
         * @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 );
        }
 
index 3374f4a..4721ce6 100644 (file)
@@ -15,7 +15,10 @@ class RangeChronologicalPagerTest extends MediaWikiLangTestCase {
         */
        public function testGetDateCond( $inputYear, $inputMonth, $inputDay, $expected ) {
                $pager = $this->getMockForAbstractClass( 'RangeChronologicalPager' );
-               $this->assertEquals( $expected, $pager->getDateCond( $inputYear, $inputMonth, $inputDay ) );
+               $this->assertEquals(
+                       $expected,
+                       wfTimestamp( TS_MW, $pager->getDateCond( $inputYear, $inputMonth, $inputDay ) )
+               );
        }
 
        /**