Ejemplo n.º 1
0
 function formatRow($result)
 {
     $title = new TitleValue(NS_CATEGORY, $result->cat_title);
     $text = $title->getText();
     $link = $this->linkRenderer->renderHtmlLink($title, $text);
     $count = $this->msg('nmembers')->numParams($result->cat_pages)->escaped();
     return Html::rawElement('li', null, $this->getLanguage()->specialList($link, $count)) . "\n";
 }
Ejemplo n.º 2
0
 /**
  * Create a new Title from a TitleValue
  *
  * @param TitleValue $titleValue Assumed to be safe.
  *
  * @return Title
  */
 public static function newFromTitleValue(TitleValue $titleValue)
 {
     return self::makeTitle($titleValue->getNamespace(), $titleValue->getText(), $titleValue->getFragment());
 }
Ejemplo n.º 3
0
 /**
  * @see TitleFormatter::getText()
  *
  * @param TitleValue $title
  *
  * @return string
  */
 public function getFullText(TitleValue $title)
 {
     return $this->formatTitle($title->getNamespace(), $title->getText(), $title->getFragment());
 }
 public function testCountVisitingWatchers()
 {
     $titleValue = new TitleValue(0, 'SomeDbKey');
     $mockDb = $this->getMockDb();
     $mockDb->expects($this->exactly(1))->method('selectField')->with('watchlist', 'COUNT(*)', ['wl_namespace' => $titleValue->getNamespace(), 'wl_title' => $titleValue->getDBkey(), 'wl_notificationtimestamp >= \'TS111TS\' OR wl_notificationtimestamp IS NULL'], $this->isType('string'))->will($this->returnValue(7));
     $mockDb->expects($this->exactly(1))->method('addQuotes')->will($this->returnCallback(function ($value) {
         return "'{$value}'";
     }));
     $mockDb->expects($this->exactly(1))->method('timestamp')->will($this->returnCallback(function ($value) {
         return 'TS' . $value . 'TS';
     }));
     $mockCache = $this->getMockCache();
     $mockCache->expects($this->never())->method('set');
     $mockCache->expects($this->never())->method('get');
     $mockCache->expects($this->never())->method('delete');
     $store = $this->newWatchedItemStore($this->getMockLoadBalancer($mockDb), $mockCache);
     $this->assertEquals(7, $store->countVisitingWatchers($titleValue, '111'));
 }
Ejemplo n.º 5
0
 /**
  * @dataProvider getTextProvider
  */
 public function testGetText($dbkey, $text)
 {
     $title = new TitleValue(NS_MAIN, $dbkey);
     $this->assertEquals($text, $title->getText());
 }
 public function testContinueParam()
 {
     $user = $this->getLoggedInTestUser();
     $target1 = new TitleValue(0, 'ApiQueryWatchlistIntegrationTestPage');
     $target2 = new TitleValue(1, 'ApiQueryWatchlistIntegrationTestPage');
     $target3 = new TitleValue(0, 'ApiQueryWatchlistIntegrationTestPage2');
     $this->doPageEdits($user, [['target' => $target1, 'content' => 'Some Content', 'summary' => 'Create the page'], ['target' => $target2, 'content' => 'Some Talk Page Content', 'summary' => 'Create Talk page'], ['target' => $target3, 'content' => 'Some Other Content', 'summary' => 'Create the page']]);
     $this->watchPages($user, [$target1, $target2, $target3]);
     $firstResult = $this->doListWatchlistRequest(['wllimit' => 2, 'wlprop' => 'title']);
     $this->assertArrayHasKey('continue', $firstResult[0]);
     $this->assertArrayHasKey('wlcontinue', $firstResult[0]['continue']);
     $continuationParam = $firstResult[0]['continue']['wlcontinue'];
     $continuedResult = $this->doListWatchlistRequest(['wlcontinue' => $continuationParam, 'wlprop' => 'title']);
     $this->assertEquals([['type' => 'new', 'ns' => $target3->getNamespace(), 'title' => $this->getPrefixedText($target3)], ['type' => 'new', 'ns' => $target2->getNamespace(), 'title' => $this->getPrefixedText($target2)]], $this->getItemsFromApiResponse($firstResult));
     $this->assertEquals([['type' => 'new', 'ns' => $target1->getNamespace(), 'title' => $this->getPrefixedText($target1)]], $this->getItemsFromApiResponse($continuedResult));
 }