/** * @dataProvider needsTargetSpecificSummaryProvider */ public function testNeedsTargetSpecificSummary($expected, Diff $siteLinkDiff, Title $title) { $siteStore = new HashSiteStore(TestSites::getSites()); $commentCreator = new SiteLinkCommentCreator(Language::factory('qqx'), $siteStore, 'enwiki'); $res = $commentCreator->needsTargetSpecificSummary($siteLinkDiff, $title); $this->assertSame($expected, $res); }
/** * Returns a human readable comment representing the change. * * @since 0.4 * * @param EntityChange $change the change to get a comment for * @param Title|null $target The page we create an edit summary for. Needed to create an article * specific edit summary on site link changes. Ignored otherwise. * * @throws MWException * @return string */ private function getEditComment(EntityChange $change, Title $target = null) { $siteLinkDiff = $change instanceof ItemChange ? $change->getSiteLinkDiff() : null; $editComment = ''; if ($siteLinkDiff !== null && !$siteLinkDiff->isEmpty()) { $action = $change->getAction(); $siteLinkComment = $this->siteLinkCommentCreator->getEditComment($siteLinkDiff, $action, $target); $editComment = $siteLinkComment === null ? '' : $siteLinkComment; } if ($editComment === '') { $editComment = $change->getComment(); } if ($editComment === '') { // If there is no comment, use something generic. This shouldn't happen. wfWarn('Failed to find edit comment for EntityChange'); $editComment = $this->msg('wikibase-comment-update')->text(); } Assert::postcondition(is_string($editComment), '$editComment must be a string'); return $editComment; }