From: addshore Date: Mon, 4 Dec 2017 15:00:17 +0000 (+0100) Subject: Test for WikiPge::insertProtectNullRevision X-Git-Tag: 1.31.0-rc.0~1282 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=2af18246aaeda5a61bd298ebc6edd572e73f418a Test for WikiPge::insertProtectNullRevision Bug: T180989 Change-Id: Iffee0bbe9fb18bb6c7f7af10b6405007468ac0b9 --- diff --git a/tests/phpunit/includes/page/WikiPageDbTestBase.php b/tests/phpunit/includes/page/WikiPageDbTestBase.php index 961b44e654..be8b444f70 100644 --- a/tests/phpunit/includes/page/WikiPageDbTestBase.php +++ b/tests/phpunit/includes/page/WikiPageDbTestBase.php @@ -1422,4 +1422,68 @@ more stuff $this->assertNull( WikiPage::newFromID( 73574757437437743743 ) ); } + public function provideTestInsertProtectNullRevision() { + // @codingStandardsIgnoreStart Generic.Files.LineLength + yield [ + 'goat-message-key', + [ 'edit' => 'sysop' ], + [ 'edit' => '20200101040404' ], + false, + 'Goat Reason', + true, + '(goat-message-key: WikiPageDbTestBase::testInsertProtectNullRevision, UTSysop)(colon-separator)Goat Reason(word-separator)(parentheses: (protect-summary-desc: (restriction-edit), (protect-level-sysop), (protect-expiring: 04:04, 1 (january) 2020, 1 (january) 2020, 04:04)))' + ]; + yield [ + 'goat-key', + [ 'edit' => 'sysop', 'move' => 'something' ], + [ 'edit' => '20200101040404', 'move' => '20210101050505' ], + false, + 'Goat Goat', + true, + '(goat-key: WikiPageDbTestBase::testInsertProtectNullRevision, UTSysop)(colon-separator)Goat Goat(word-separator)(parentheses: (protect-summary-desc: (restriction-edit), (protect-level-sysop), (protect-expiring: 04:04, 1 (january) 2020, 1 (january) 2020, 04:04))(word-separator)(protect-summary-desc: (restriction-move), (protect-level-something), (protect-expiring: 05:05, 1 (january) 2021, 1 (january) 2021, 05:05)))' + ]; + // @codingStandardsIgnoreEnd Generic.Files.LineLength + } + + /** + * @dataProvider provideTestInsertProtectNullRevision + * @covers WikiPge::insertProtectNullRevision + * @covers WikiPge::protectDescription + * + * @param string $revCommentMsg + * @param array $limit + * @param array $expiry + * @param bool $cascade + * @param string $reason + * @param bool|null $user true if the test sysop should be used, or null + * @param string $expectedComment + */ + public function testInsertProtectNullRevision( + $revCommentMsg, + array $limit, + array $expiry, + $cascade, + $reason, + $user, + $expectedComment + ) { + $this->setContentLang( 'qqx' ); + + $page = $this->createPage( __METHOD__, 'Goat' ); + + $user = $user === null ? $user : $this->getTestSysop()->getUser(); + + $result = $page->insertProtectNullRevision( + $revCommentMsg, + $limit, + $expiry, + $cascade, + $reason, + $user + ); + + $this->assertTrue( $result instanceof Revision ); + $this->assertSame( $expectedComment, $result->getComment( Revision::RAW ) ); + } + }