/**
  * @see SpecialPage::execute
  */
 public function execute($query)
 {
     $output = $this->getOutput();
     $output->setPageTitle($this->msg('searchbyproperty')->text());
     $output->addModules('ext.smw.tooltip');
     $output->addModules('ext.smw.property');
     list($limit, $offset) = $this->getLimitOffset();
     // @see SMWInfolink::encodeParameters
     if ($query === null && $this->getRequest()->getCheck('x')) {
         $query = $this->getRequest()->getVal('x');
     }
     $applicationFactory = ApplicationFactory::getInstance();
     $requestOptions = array('limit' => $limit, 'offset' => $offset, 'property' => $this->getRequest()->getVal('property'), 'value' => $this->getRequest()->getVal('value'), 'nearbySearchForType' => $applicationFactory->getSettings()->get('smwgSearchByPropertyFuzzy'));
     $htmlFormRenderer = $applicationFactory->newMwCollaboratorFactory()->newHtmlFormRenderer($this->getContext()->getTitle(), $this->getLanguage());
     $pageBuilder = new PageBuilder($htmlFormRenderer, new PageRequestOptions($query, $requestOptions), new QueryResultLookup($applicationFactory->getStore()));
     $output->addHTML($pageBuilder->getHtml());
 }
 public function testGetHtmlForNearbyResultsSearch()
 {
     $title = $this->getMockBuilder('\\Title')->disableOriginalConstructor()->getMock();
     $message = $this->getMockBuilder('\\Message')->disableOriginalConstructor()->getMock();
     $message->expects($this->any())->method('numParams')->will($this->returnSelf());
     $message->expects($this->any())->method('rawParams')->will($this->returnSelf());
     $messageBuilder = $this->getMockBuilder('\\SMW\\MediaWiki\\MessageBuilder')->disableOriginalConstructor()->getMock();
     $messageBuilder->expects($this->any())->method('getMessage')->will($this->returnValue($message));
     $queryResult = $this->getMockBuilder('\\SMWQueryResult')->disableOriginalConstructor()->getMock();
     $queryResult->expects($this->any())->method('getNext')->will($this->returnValue(false));
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->any())->method('getPropertySubjects')->will($this->returnValue(array(new DIWikiPage('ResultOne', NS_MAIN), new DIWikiPage('ResultTwo', NS_HELP))));
     $store->expects($this->atLeastOnce())->method('getQueryResult')->will($this->returnValue($queryResult));
     $requestOptions = array('propertyString' => 'Foo', 'valueString' => 'Bar', 'nearbySearchForType' => array('_wpg'));
     $instance = new PageBuilder(new HtmlFormRenderer($title, $messageBuilder), new PageRequestOptions('Foo/Bar', $requestOptions), new QueryResultLookup($store));
     $expected = array('value="Foo"', 'value="Bar"', 'title="ResultOne', 'title="' . $this->localizer->getNamespaceTextById(NS_HELP) . ':ResultTwo');
     $this->stringValidator->assertThatStringContains($expected, $instance->getHtml());
 }