/** * @dataProvider pageRequestOptionsProvider */ public function testProcess($queryString, $requestOptions, $expected) { $instance = new PageRequestOptions($queryString, $requestOptions); $instance->initialize(); foreach ($expected as $key => $value) { $this->assertEquals($expected[$key], $instance->{$key}, "{$key}"); } $this->assertInstanceOf('SMWPropertyValue', $instance->property); }
public function testDoQueryForNearbyResults() { $pageRequestOptions = new PageRequestOptions('Foo/Bar', array()); $pageRequestOptions->initialize(); $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->once())->method('getQueryResult')->with($this->isInstanceOf('\\SMWQuery'))->will($this->returnValue($queryResult)); $instance = new QueryResultLookup($store); $this->assertInternaltype('array', $instance->doQueryForNearbyResults($pageRequestOptions, 1)); }
/** * @since 2.1 * * @return string */ public function getHtml() { $this->pageRequestOptions->initialize(); $this->messageBuilder = $this->htmlFormBuilder->getMessageBuilder(); list($resultMessage, $resultList, $resultCount) = $this->getResultHtml(); if ($resultList === '' || $resultList === null) { $resultList = $this->messageBuilder->getMessage('smw_result_noresults')->text(); } $pageDescription = Html::rawElement('p', array('class' => 'smw-sp-searchbyproperty-description'), $this->messageBuilder->getMessage('smw-sp-searchbyproperty-description')->parse()); $resultListHeader = Html::element('h2', array(), $this->messageBuilder->getMessage('smw-sp-searchbyproperty-resultlist-header')->text()); return $pageDescription . $this->getHtmlForm($resultMessage, $resultCount) . $resultListHeader . $resultList; }
/** * @since 2.1 * * @return string */ public function getHtml() { $this->pageRequestOptions->initialize(); $this->messageBuilder = $this->htmlFormRenderer->getMessageBuilder(); list($resultMessage, $resultList, $resultCount) = $this->getResultHtml(); if (($resultList === '' || $resultList === null) && $this->pageRequestOptions->property->getDataItem() instanceof DIProperty && $this->pageRequestOptions->valueString === '') { list($resultMessage, $resultList, $resultCount) = $this->tryToFindAtLeastOnePropertyTableReferenceFor($this->pageRequestOptions->property->getDataItem()); } if ($resultList === '' || $resultList === null) { $resultList = $this->messageBuilder->getMessage('smw_result_noresults')->text(); } $pageDescription = Html::rawElement('p', array('class' => 'smw-sp-searchbyproperty-description'), $this->messageBuilder->getMessage('smw-sp-searchbyproperty-description')->parse()); $resultListHeader = Html::element('h2', array(), $this->messageBuilder->getMessage('smw-sp-searchbyproperty-resultlist-header')->text()); return $pageDescription . $this->getHtmlForm($resultMessage, $resultCount) . $resultListHeader . $resultList; }