private function getChangeRunCoalescer()
 {
     $entityRevisionLookup = $this->getEntityRevisionLookup();
     $changeFactory = TestChanges::getEntityChangeFactory();
     $coalescer = new ChangeRunCoalescer($entityRevisionLookup, $changeFactory, 'enwiki');
     return $coalescer;
 }
 public function itemChangeProvider()
 {
     $changes = array_filter(TestChanges::getChanges(), function (EntityChange $change) {
         return $change instanceof ItemChange;
     });
     $cases = array_map(function (ItemChange $change) {
         return array($change);
     }, $changes);
     return $cases;
 }
 private function getRestoreDiff()
 {
     $item = $this->getNewItem();
     $item->getSiteLinkList()->addNewSiteLink('enwiki', 'Japan');
     $changeFactory = TestChanges::getEntityChangeFactory();
     $change = $changeFactory->newFromUpdate(ItemChange::RESTORE, null, $item);
     return $change->getSiteLinkDiff();
 }
 public function testGetAffectedUsagesByPage_withDeletedPage()
 {
     $pageTitle = 'RandomKitten-2x5jsg8j3bvmpm4!5';
     $affectedPagesFinder = new AffectedPagesFinder($this->getSiteLinkUsageLookup($pageTitle), new TitleFactory(), 'enwiki', 'en', false);
     $itemId = new ItemId('Q1');
     $changeFactory = TestChanges::getEntityChangeFactory();
     $change = $changeFactory->newFromUpdate(ItemChange::UPDATE, $this->getItemWithSiteLinks($itemId, array('enwiki' => $pageTitle)), new Item($itemId));
     $usages = $affectedPagesFinder->getAffectedUsagesByPage($change);
     $this->assertCount(0, $usages);
 }
 public function provideHandleChange()
 {
     $changes = TestChanges::getChanges();
     $userEmmy2 = Title::newFromText('User:Emmy2')->getPrefixedText();
     $empty = array('purgeParserCache' => array(), 'scheduleRefreshLinks' => array(), 'purgeWebCache' => array(), 'injectRCRecord' => array());
     $emmy2PurgeParser = array('purgeParserCache' => array('Emmy2' => true), 'scheduleRefreshLinks' => array(), 'purgeWebCache' => array('Emmy2' => true), 'injectRCRecord' => array('Emmy2' => true));
     $userEmmy2PurgeParser = array('purgeParserCache' => array($userEmmy2 => true), 'scheduleRefreshLinks' => array(), 'purgeWebCache' => array($userEmmy2 => true), 'injectRCRecord' => array($userEmmy2 => true));
     $emmyUpdateLinks = array('purgeParserCache' => array('Emmy' => true), 'scheduleRefreshLinks' => array('Emmy' => true), 'purgeWebCache' => array('Emmy' => true), 'injectRCRecord' => array('Emmy' => true));
     $emmy2UpdateLinks = array('purgeParserCache' => array('Emmy2' => true), 'scheduleRefreshLinks' => array('Emmy2' => true), 'purgeWebCache' => array('Emmy2' => true), 'injectRCRecord' => array('Emmy2' => true));
     $emmy2UpdateAll = array('purgeParserCache' => array('Emmy2' => true), 'scheduleRefreshLinks' => array('Emmy2' => true), 'purgeWebCache' => array('Emmy2' => true), 'injectRCRecord' => array('Emmy2' => true));
     return array(array($changes['property-creation'], array('q100' => array()), $empty), array($changes['property-deletion'], array('q100' => array()), $empty), array($changes['property-set-label'], array('q100' => array()), $empty), array($changes['item-creation'], array('q100' => array()), $empty), array($changes['item-deletion'], array('q100' => array()), $empty), array($changes['item-deletion-linked'], array('q100' => array('enwiki' => 'Emmy2')), $emmy2UpdateAll), array($changes['set-de-label'], array('q100' => array('enwiki' => 'Emmy2')), $empty), array($changes['set-en-label'], array('q100' => array('enwiki' => 'Emmy2')), $emmy2PurgeParser), array($changes['set-en-label'], array('q100' => array('enwiki' => 'User:Emmy2')), $userEmmy2PurgeParser), array($changes['set-en-aliases'], array('q100' => array('enwiki' => 'Emmy2')), $empty), array($changes['add-claim'], array('q100' => array('enwiki' => 'Emmy2')), $empty), array($changes['remove-claim'], array('q100' => array('enwiki' => 'Emmy2')), $empty), array($changes['set-dewiki-sitelink'], array('q100' => array()), $empty), array($changes['set-enwiki-sitelink'], array('q100' => array('enwiki' => 'Emmy')), $emmyUpdateLinks), array($changes['change-dewiki-sitelink'], array('q100' => array('enwiki' => 'Emmy')), $emmyUpdateLinks), array($changes['change-enwiki-sitelink'], array('q100' => array('enwiki' => 'Emmy'), 'q200' => array('enwiki' => 'Emmy2')), array('purgeParserCache' => array('Emmy' => true, 'Emmy2' => true), 'scheduleRefreshLinks' => array('Emmy' => true, 'Emmy2' => true), 'purgeWebCache' => array('Emmy' => true, 'Emmy2' => true), 'injectRCRecord' => array('Emmy' => true, 'Emmy2' => true))), array($changes['change-enwiki-sitelink-badges'], array('q100' => array('enwiki' => 'Emmy2')), $emmy2UpdateLinks), array($changes['remove-dewiki-sitelink'], array('q100' => array('enwiki' => 'Emmy2')), $emmy2UpdateLinks), array($changes['remove-enwiki-sitelink'], array('q100' => array('enwiki' => 'Emmy2')), $emmy2UpdateLinks));
 }
 public function testSetTimestamp()
 {
     $q7 = new ItemId('Q7');
     $changeFactory = TestChanges::getEntityChangeFactory();
     $change = $changeFactory->newForEntity(EntityChange::UPDATE, $q7);
     $timestamp = '20140523' . '174422';
     $change->setTimestamp($timestamp);
     $this->assertEquals($timestamp, $change->getTime());
 }