diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php b/tests/phpunit/includes/RevisionIntegrationTest.php index 96ce7660c47..48e00e0e2cc 100644 --- a/tests/phpunit/includes/RevisionIntegrationTest.php +++ b/tests/phpunit/includes/RevisionIntegrationTest.php @@ -991,4 +991,59 @@ class RevisionIntegrationTest extends MediaWikiTestCase { ); } + /** + * @covers Revision::getParentLengths + */ + public function testGetParentLengths_noRevIds() { + $this->assertSame( + [], + Revision::getParentLengths( + wfGetDB( DB_MASTER ), + [] + ) + ); + } + + /** + * @covers Revision::getParentLengths + */ + public function testGetParentLengths_oneRevId() { + $text = '831jr091jr0921kr21kr0921kjr0921j09rj1'; + $textLength = strlen( $text ); + + $this->testPage->doEditContent( new WikitextContent( $text ), __METHOD__ ); + $rev[1] = $this->testPage->getLatest(); + + $this->assertSame( + [ $rev[1] => strval( $textLength ) ], + Revision::getParentLengths( + wfGetDB( DB_MASTER ), + [ $rev[1] ] + ) + ); + } + + /** + * @covers Revision::getParentLengths + */ + public function testGetParentLengths_multipleRevIds() { + $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1'; + $textOneLength = strlen( $textOne ); + $textTwo = '831jr091jr092121j09rj1'; + $textTwoLength = strlen( $textTwo ); + + $this->testPage->doEditContent( new WikitextContent( $textOne ), __METHOD__ ); + $rev[1] = $this->testPage->getLatest(); + $this->testPage->doEditContent( new WikitextContent( $textTwo ), __METHOD__ ); + $rev[2] = $this->testPage->getLatest(); + + $this->assertSame( + [ $rev[1] => strval( $textOneLength ), $rev[2] => strval( $textTwoLength ) ], + Revision::getParentLengths( + wfGetDB( DB_MASTER ), + [ $rev[1], $rev[2] ] + ) + ); + } + }