/**
  * @param User $user
  *
  * @return ItemMergeInteractor
  */
 private function newInteractor(User $user = null)
 {
     if (!$user) {
         $user = $GLOBALS['wgUser'];
     }
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $summaryFormatter = $wikibaseRepo->getSummaryFormatter();
     //XXX: we may want or need to mock some of these services
     $changeOpsFactory = new MergeChangeOpsFactory($wikibaseRepo->getEntityConstraintProvider(), $wikibaseRepo->getChangeOpFactoryProvider(), MockSiteStore::newFromTestSites());
     $interactor = new ItemMergeInteractor($changeOpsFactory, $this->mockRepository, $this->mockRepository, $this->getPermissionCheckers(), $summaryFormatter, $user, new RedirectCreationInteractor($this->mockRepository, $this->mockRepository, $this->getPermissionCheckers(), $summaryFormatter, $user, $this->getMockEditFilterHookRunner(), $this->mockRepository));
     return $interactor;
 }
 public function testSetSitelinkXmlFormat()
 {
     $entityRevision = $this->getNewEntityRevision();
     $entityId = $entityRevision->getEntity()->getId()->getSerialization();
     $params = array('action' => 'wbsetsitelink', 'id' => $entityId, 'linksite' => 'enwiki', 'linktitle' => 'Japan');
     /** @var SetSiteLink $module */
     $module = $this->getApiModule('\\Wikibase\\Repo\\Api\\SetSiteLink', 'wbsetsitelink', $params, true);
     $siteTargetProvider = new SiteLinkTargetProvider(MockSiteStore::newFromTestSites(), array());
     $module->setServices($siteTargetProvider);
     $result = $this->executeApiModule($module);
     $actual = $this->removePageInfoAttributes($result, $entityId);
     //If a URL has been added just remove it as it is not always present
     $actual = str_replace('url="https://en.wikipedia.org/wiki/Japan"', '', $actual);
     $this->assertXmlStringEqualsXmlString($this->getExpectedXml('setsitelink'), $actual);
     $params = array('action' => 'wbsetsitelink', 'id' => $entityId, 'linksite' => 'enwiki');
     /** @var SetSiteLink $module */
     $module = $this->getApiModule('\\Wikibase\\Repo\\Api\\SetSiteLink', 'wbsetsitelink', $params, true);
     $module->setServices($siteTargetProvider);
     $result = $this->executeApiModule($module);
     $actual = $this->removePageInfoAttributes($result, $entityId);
     $this->assertXmlStringEqualsXmlString($this->getExpectedXml('setsitelink-removed'), $actual);
 }