Update suppressWarning()/restoreWarning() calls
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionDbTestBase.php
index 9ab76c8..b05a742 100644 (file)
@@ -396,7 +396,8 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $store = new RevisionStore(
                        $services->getDBLoadBalancer(),
                        $services->getService( '_SqlBlobStore' ),
-                       $services->getMainWANObjectCache()
+                       $services->getMainWANObjectCache(),
+                       $services->getCommentStore()
                );
 
                $store->setContentHandlerUseDB( $this->getContentHandlerUseDB() );
@@ -619,6 +620,16 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->assertEquals( __METHOD__, $rev->getContent()->getNativeData() );
        }
 
+       /**
+        * @covers Revision::newNullRevision
+        */
+       public function testNewNullRevision_badPage() {
+               $dbw = wfGetDB( DB_MASTER );
+               $rev = Revision::newNullRevision( $dbw, -1, 'a null revision', false );
+
+               $this->assertNull( $rev );
+       }
+
        /**
         * @covers Revision::insertOn
         */
@@ -649,6 +660,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
        }
 
        /**
+        * @covers Revision::userWasLastToEdit
         * @dataProvider provideUserWasLastToEdit
         */
        public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
@@ -826,9 +838,9 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
        public function provideGetContentHandler() {
                // NOTE: we expect the help namespace to always contain wikitext
                return [
-                       [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
-                       [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
-                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
+                       [ 'hello world', 'Help:Hello', null, null, WikitextContentHandler::class ],
+                       [ 'hello world', 'User:hello/there.css', null, null, CssContentHandler::class ],
+                       [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentHandlerForTesting::class ],
                ];
        }
 
@@ -891,7 +903,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                        'text_id' => 123456789, // not in the test DB
                ] );
 
-               MediaWiki\suppressWarnings(); // bad text_id will trigger a warning.
+               Wikimedia\suppressWarnings(); // bad text_id will trigger a warning.
 
                $this->assertNull( $rev->getContent(),
                        "getContent() should return null if the revision's text blob could not be loaded." );
@@ -900,7 +912,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->assertNull( $rev->getContent(),
                        "getContent() should return null if the revision's text blob could not be loaded." );
 
-               MediaWiki\suppressWarnings( 'end' );
+               Wikimedia\restoreWarnings();
        }
 
        public function provideGetSize() {
@@ -1363,6 +1375,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