Example #1
0
 /**
  * @group Slow
  * @slowExecutionTime 0.09599 ms
  * @covers Wikia\Search\Hooks::onLinkEnd
  * @covers Wikia\Search\Hooks::popLinks
  */
 public function testOnLinkEndAndPopLinks()
 {
     $mockService = $this->getMock('Wikia\\Search\\MediaWikiService', ['getWikiId', 'getCanonicalPageIdFromPageId']);
     $mockTitle = $this->getMockBuilder('Title')->disableOriginalConstructor()->setMethods(['getArticleId'])->getMock();
     $mockSkin = $this->getMockBuilder('Skin')->disableOriginalConstructor()->getMock();
     $mockTitle->expects($this->once())->method('getArticleId')->will($this->returnValue(123));
     $mockService->expects($this->at(0))->method('getCanonicalPageIdFromPageId')->with(123)->will($this->returnValue(456));
     $mockService->expects($this->at(1))->method('getWikiId')->will($this->returnValue(123));
     $options = [];
     $text = 'foo';
     $attribs = [];
     $ret = false;
     $expected = '123_456 | foo';
     $this->mockClass('Wikia\\Search\\MediaWikiService', $mockService);
     $this->assertTrue(\Wikia\Search\Hooks::onLinkEnd($mockSkin, $mockTitle, $options, $text, $attribs, $ret));
     $this->assertAttributeContains($expected, 'outboundLinks', 'Wikia\\Search\\Hooks');
     $this->assertEquals([$expected], \Wikia\Search\Hooks::popLinks());
     $this->assertAttributeEmpty('outboundLinks', 'Wikia\\Search\\Hooks');
 }
Example #2
0
 /**
  * @group Slow
  * @slowExecutionTime 0.07897 ms
  * @covers Wikia\Search\Hooks::onGetPreferences
  */
 public function testonGetPreferences()
 {
     $badKeys = array('searchlimit', 'contextlines', 'contextchars', 'disablesuggest', 'searcheverything', 'searchnamespaces');
     $prefs = array_flip($badKeys);
     $mockUser = $this->getMock('User');
     $hooks = new \Wikia\Search\Hooks();
     $hooks->onGetPreferences($mockUser, $prefs);
     foreach ($badKeys as $key) {
         $this->assertArrayNotHasKey($key, $prefs);
     }
     $this->assertArrayHasKey('enableGoSearch', $prefs);
     $this->assertArrayHasKey('searchAllNamespaces', $prefs);
 }