Merge "Revision: Handle all return values of Title::newFromId"
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionDbTestBase.php
index 94f8fba..6139524 100644 (file)
@@ -1364,6 +1364,24 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->assertEquals( $rev->getId(), $cachedRow->rev_id );
        }
 
+       public function testNewKnownCurrent_withPageId() {
+               $db = wfGetDB( DB_MASTER );
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev = $this->testPage->getRevision();
+
+               $pageId = $this->testPage->getId();
+
+               $newRev = Revision::newKnownCurrent( $db, $pageId, $rev->getId() );
+               $this->assertRevEquals( $rev, $newRev );
+       }
+
+       public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
+               $db = wfGetDB( DB_MASTER );
+
+               $this->assertFalse( Revision::newKnownCurrent( $db, 0 ) );
+       }
+
        public function provideUserCanBitfield() {
                yield [ 0, 0, [], null, true ];
                // Bitfields match, user has no permissions