Add tests for Revision::getTitle
authoraddshore <addshorewiki@gmail.com>
Thu, 9 Nov 2017 10:36:22 +0000 (10:36 +0000)
committeraddshore <addshorewiki@gmail.com>
Thu, 9 Nov 2017 11:48:50 +0000 (11:48 +0000)
This method is touched in I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2
hence adding some test coverage now.

Change-Id: Ie39a294546d84413bfb716efb27fd2c0321b349b

tests/phpunit/includes/RevisionIntegrationTest.php

index 48e00e0..ad211c6 100644 (file)
@@ -1046,4 +1046,35 @@ class RevisionIntegrationTest extends MediaWikiTestCase {
                );
        }
 
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_fromExistingRevision() {
+               $this->assertTrue(
+                       $this->testPage->getTitle()->equals(
+                               $this->testPage->getRevision()->getTitle()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
+               $rev = new Revision( [ 'id' => $this->testPage->getLatest() ] );
+               $this->assertTrue(
+                       $this->testPage->getTitle()->equals(
+                               $rev->getTitle()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::getTitle
+        */
+       public function testGetTitle_forBadRevision() {
+               $rev = new Revision( [] );
+               $this->assertNull( $rev->getTitle() );
+       }
+
 }