Fix flakey MCR test in RevisionDbTestBase by mocking the time
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 29 Mar 2019 21:14:05 +0000 (14:14 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 29 Mar 2019 21:17:47 +0000 (14:17 -0700)
Change-Id: I1d089d7b155adb865b42f7e8a26466553508c9be

tests/phpunit/includes/RevisionDbTestBase.php

index a17d21d..d7f4fd6 100644 (file)
@@ -26,6 +26,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                        [
                                'page',
                                'revision',
+                               'comment',
                                'ip_changes',
                                'text',
                                'archive',
@@ -1396,6 +1397,9 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->setService( 'MainWANObjectCache', $cache );
                $db = wfGetDB( DB_MASTER );
 
+               $now = 1553893742;
+               $cache->setMockTime( $now );
+
                // Get a fresh revision to use during testing
                $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
                $rev = $this->testPage->getRevision();
@@ -1410,6 +1414,8 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $cache->delete( $key, WANObjectCache::HOLDOFF_NONE );
                $this->assertFalse( $cache->get( $key ) );
 
+               ++$now;
+
                // Get the new revision and make sure it is in the cache and correct
                $newRev = Revision::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
                $this->assertRevEquals( $rev, $newRev );