Addshore has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/384219 )
Change subject: RevisionUnitTest for various getters and setters ...................................................................... RevisionUnitTest for various getters and setters getId setId setUserIdAndName getTextId getParentId Change-Id: I1890122c0eae16947a4782bc14baa8c3b9ce1391 --- M tests/phpunit/includes/RevisionUnitTest.php 1 file changed, 81 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/19/384219/1 diff --git a/tests/phpunit/includes/RevisionUnitTest.php b/tests/phpunit/includes/RevisionUnitTest.php index 5282ae6..24f0b64 100644 --- a/tests/phpunit/includes/RevisionUnitTest.php +++ b/tests/phpunit/includes/RevisionUnitTest.php @@ -74,6 +74,87 @@ ]; } + public function provideGetId() { + yield [ + [], + null + ]; + yield [ + [ 'id' => 998 ], + 998 + ]; + } + + /** + * @dataProvider provideGetId + * @covers Revision::getId + */ + public function testGetId( $rowArray, $expectedId ) { + $rev = new Revision( $rowArray ); + $this->assertEquals( $expectedId, $rev->getId() ); + } + + public function provideSetId() { + yield [ '123', 123 ]; + yield [ 456, 456 ]; + } + + /** + * @dataProvider provideSetId + * @covers Revision::setId + */ + public function testSetId( $input, $expected ) { + $rev = new Revision( [] ); + $rev->setId( $input ); + $this->assertSame( $expected, $rev->getId() ); + } + + public function provideSetUserIdAndName() { + yield [ '123', 123, 'GOaT' ]; + yield [ 456, 456, 'GOaT' ]; + } + + /** + * @dataProvider provideSetUserIdAndName + * @covers Revision::setUserIdAndName + */ + public function testSetUserIdAndName( $inputId, $expectedId, $name ) { + $rev = new Revision( [] ); + $rev->setUserIdAndName( $inputId, $name ); + $this->assertSame( $expectedId, $rev->getUser( Revision::RAW ) ); + $this->assertEquals( $name, $rev->getUserText( Revision::RAW ) ); + } + + public function provideGetTextId() { + yield [ [], null ]; + yield [ [ 'text_id' => '123' ], 123 ]; + yield [ [ 'text_id' => 456 ], 456 ]; + } + + /** + * @dataProvider provideGetTextId + * @covers Revision::getTextId() + */ + public function testGetTextId( $rowArray, $expected ) { + $rev = new Revision( $rowArray ); + $this->assertSame( $expected, $rev->getTextId() ); + } + + public function provideGetParentId() { + yield [ [], null ]; + yield [ [ 'parent_id' => '123' ], 123 ]; + yield [ [ 'parent_id' => 456 ], 456 ]; + } + + /** + * @dataProvider provideGetParentId + * @covers Revision::getParentId() + */ + public function testGetParentId( $rowArray, $expected ) { + $rev = new Revision( $rowArray ); + $this->assertSame( $expected, $rev->getParentId() ); + } + /** * @covers Revision::getRevisionText * @dataProvider provideGetRevisionText -- To view, visit https://gerrit.wikimedia.org/r/384219 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1890122c0eae16947a4782bc14baa8c3b9ce1391 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits