From: addshore Date: Mon, 4 Dec 2017 14:14:12 +0000 (+0100) Subject: Tests for WikiPage::newFromID X-Git-Tag: 1.31.0-rc.0~1283 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=ece8130b6aa07d4eaaefa6fa9193f4fe05032f7d Tests for WikiPage::newFromID Bug: T180989 Change-Id: Idb4d7ce8ccc27226b0f00e2127acef6158dd32a9 --- diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index 99749a21e7..961b44e654 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -1389,4 +1389,37 @@ more stuff $assertions( $page, $this ); } + public function provideTestNewFromId_returnsNullOnBadPageId() { + yield[ 0 ]; + yield[ -11 ]; + } + + /** + * @covers WikiPage::newFromID + * @dataProvider provideTestNewFromId_returnsNullOnBadPageId + */ + public function testNewFromId_returnsNullOnBadPageId( $pageId ) { + $this->assertNull( WikiPage::newFromID( $pageId ) ); + } + + /** + * @covers WikiPage::newFromID + */ + public function testNewFromId_appearsToFetchCorrectRow() { + $createdPage = $this->createPage( __METHOD__, 'Xsfaij09' ); + $fetchedPage = WikiPage::newFromID( $createdPage->getId() ); + $this->assertSame( $createdPage->getId(), $fetchedPage->getId() ); + $this->assertEquals( + $createdPage->getContent()->getNativeData(), + $fetchedPage->getContent()->getNativeData() + ); + } + + /** + * @covers WikiPage::newFromID + */ + public function testNewFromId_returnsNullOnNonExistingId() { + $this->assertNull( WikiPage::newFromID( 73574757437437743743 ) ); + } + }