예제 #1
0
 /**
  * @dataProvider provideUserTitleTimestamp
  */
 public function testConstruction($user, LinkTarget $linkTarget, $notifTimestamp)
 {
     $item = new WatchedItem($user, $linkTarget, $notifTimestamp);
     $this->assertSame($user, $item->getUser());
     $this->assertSame($linkTarget, $item->getLinkTarget());
     $this->assertSame($notifTimestamp, $item->getNotificationTimestamp());
     // The below tests the internal WatchedItem::getTitle method
     $this->assertInstanceOf('Title', $item->getTitle());
     $this->assertSame($linkTarget->getDBkey(), $item->getTitle()->getDBkey());
     $this->assertSame($linkTarget->getFragment(), $item->getTitle()->getFragment());
     $this->assertSame($linkTarget->getNamespace(), $item->getTitle()->getNamespace());
     $this->assertSame($linkTarget->getText(), $item->getTitle()->getText());
 }
예제 #2
0
 private function cache(WatchedItem $item)
 {
     $user = $item->getUser();
     $target = $item->getLinkTarget();
     $key = $this->getCacheKey($user, $target);
     $this->cache->set($key, $item);
     $this->cacheIndex[$target->getNamespace()][$target->getDBkey()][$user->getId()] = $key;
     $this->stats->increment('WatchedItemStore.cache');
 }
예제 #3
0
 public function testBatchAddWatch()
 {
     $itemOne = new WatchedItem($this->getMockUser(1), new TitleValue(0, 'Title1'), null);
     $itemTwo = new WatchedItem($this->getMockUser(3), Title::newFromText('Title2'), '20150101010101');
     $store = $this->getMockWatchedItemStore();
     $store->expects($this->exactly(2))->method('addWatchBatchForUser');
     $store->expects($this->at(0))->method('addWatchBatchForUser')->with($itemOne->getUser(), [$itemOne->getTitle()->getSubjectPage(), $itemOne->getTitle()->getTalkPage()]);
     $store->expects($this->at(1))->method('addWatchBatchForUser')->with($itemTwo->getUser(), [$itemTwo->getTitle()->getSubjectPage(), $itemTwo->getTitle()->getTalkPage()]);
     $this->setService('WatchedItemStore', $store);
     WatchedItem::batchAddWatch([$itemOne, $itemTwo]);
 }