From d68cffa1a20e30a0f1d7d2cf5ce095720b1b8551 Mon Sep 17 00:00:00 2001 From: addshore Date: Sat, 14 Oct 2017 11:35:11 +0100 Subject: [PATCH] RevisionIntegrationTest for loadFromId & loadFromPageId Change-Id: I31431267d761b5d97d7e298c3451341358d54bba --- .../includes/RevisionIntegrationTest.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php b/tests/phpunit/includes/RevisionIntegrationTest.php index 45e33dba8d..771332942e 100644 --- a/tests/phpunit/includes/RevisionIntegrationTest.php +++ b/tests/phpunit/includes/RevisionIntegrationTest.php @@ -791,4 +791,54 @@ class RevisionIntegrationTest extends MediaWikiTestCase { $this->assertSame( $content, $content2 ); } + /** + * @covers Revision::loadFromId + */ + public function testLoadFromId() { + $rev = $this->testPage->getRevision(); + $this->assertRevEquals( + $rev, + Revision::loadFromId( wfGetDB( DB_MASTER ), $rev->getId() ) + ); + } + + /** + * @covers Revision::loadFromPageId + */ + public function testLoadFromPageId() { + $this->assertRevEquals( + $this->testPage->getRevision(), + Revision::loadFromPageId( wfGetDB( DB_MASTER ), $this->testPage->getId() ) + ); + } + + /** + * @covers Revision::loadFromPageId + */ + public function testLoadFromPageIdWithLatestRevId() { + $this->assertRevEquals( + $this->testPage->getRevision(), + Revision::loadFromPageId( + wfGetDB( DB_MASTER ), + $this->testPage->getId(), + $this->testPage->getLatest() + ) + ); + } + + /** + * @covers Revision::loadFromPageId + */ + public function testLoadFromPageIdWithNotLatestRevId() { + $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ ); + $this->assertRevEquals( + $this->testPage->getRevision()->getPrevious(), + Revision::loadFromPageId( + wfGetDB( DB_MASTER ), + $this->testPage->getId(), + $this->testPage->getRevision()->getPrevious()->getId() + ) + ); + } + } -- 2.20.1