Add tests for Revision::getParentLengths

This method name is quite missleading as it doesnt
get the parent lengths at all, it gets the lengths of
the rev ids that you ask for......

This method is touched in I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2
hence adding some test coverage now.

Change-Id: Ic837bd60a34341860c4d2287a1b999f40d4f95f1
This commit is contained in:
addshore 2017-11-09 10:20:49 +00:00
parent fdd862b6f0
commit 763546fea5

View file

@ -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] ]
)
);
}
}