本文整理汇总了PHP中SMWQuery::setContextPage方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWQuery::setContextPage方法的具体用法?PHP SMWQuery::setContextPage怎么用?PHP SMWQuery::setContextPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWQuery
的用法示例。
在下文中一共展示了SMWQuery::setContextPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processQueryCase
/**
* @since 2.2
*
* @param QueryTestCaseInterpreter $queryTestCaseInterpreter
*/
public function processQueryCase(QueryTestCaseInterpreter $queryTestCaseInterpreter)
{
if (!$queryTestCaseInterpreter->hasCondition()) {
$this->markTestSkipped('Found no condition for ' . $queryTestCaseInterpreter->isAbout());
}
$description = $this->queryParser->getQueryDescription($queryTestCaseInterpreter->getCondition());
$this->printDescriptionToOutput($queryTestCaseInterpreter->isAbout(), $description);
$query = new Query($description, false, false);
$query->querymode = $queryTestCaseInterpreter->getQueryMode();
$query->setLimit($queryTestCaseInterpreter->getLimit());
$query->setOffset($queryTestCaseInterpreter->getOffset());
$query->setExtraPrintouts($queryTestCaseInterpreter->getExtraPrintouts());
$query->setSortKeys($queryTestCaseInterpreter->getSortKeys());
$query->setContextPage($queryTestCaseInterpreter->getSubject());
if ($queryTestCaseInterpreter->isRequiredToClearStoreCache()) {
$this->getStore()->clear();
}
$queryResult = $this->getStore()->getQueryResult($query);
$this->printQueryResultToOutput($queryResult);
if (is_string($queryResult)) {
return;
}
$this->assertEquals($queryTestCaseInterpreter->getExpectedCount(), $queryResult->getCount(), 'Failed asserting query result count on ' . $queryTestCaseInterpreter->isAbout());
$this->assertCount($queryTestCaseInterpreter->getExpectedErrorCount(), $queryResult->getErrors(), 'Failed asserting error count ' . $queryTestCaseInterpreter->isAbout());
if ($queryTestCaseInterpreter->getExpectedErrorCount() > 0) {
return null;
}
if ($queryTestCaseInterpreter->isFromCache() !== null) {
$this->assertEquals($queryTestCaseInterpreter->isFromCache(), $queryResult->isFromCache(), 'Failed asserting isFromCache for ' . $queryTestCaseInterpreter->isAbout());
}
$this->queryResultValidator->assertThatQueryResultHasSubjects($queryTestCaseInterpreter->getExpectedSubjects(), $queryResult, $queryTestCaseInterpreter->isAbout());
$this->queryResultValidator->assertThatDataItemIsSet($queryTestCaseInterpreter->getExpectedDataItems(), $queryResult, $queryTestCaseInterpreter->isAbout());
$this->queryResultValidator->assertThatDataValueIsSet($queryTestCaseInterpreter->getExpectedDataValues(), $queryResult, $queryTestCaseInterpreter->isAbout());
}
示例2: queryProvider
public function queryProvider()
{
$subject = DIWikiPage::newFromText('Foo');
#0
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(DIWikiPage::newFromText('Bar')));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#1
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(new DIBlob('Bar')));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#2 uses inverse property declaration
$description = new SomeProperty(new DIProperty('Foobar', true), new ValueDescription(DIWikiPage::newFromText('Bar')));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#3 Conjunction
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(DIWikiPage::newFromText('Bar')));
$query = new Query(new Conjunction(array($description, new NamespaceDescription(NS_MAIN))));
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#4 Disjunction
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(DIWikiPage::newFromText('Bar')));
$query = new Query(new Disjunction(array($description, new NamespaceDescription(NS_MAIN))));
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#5
$description = new ClassDescription(DIWikiPage::newFromText('Foocat', NS_CATEGORY));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Foocat', NS_CATEGORY)));
#6
$description = new ConceptDescription(DIWikiPage::newFromText('FooConcept', SMW_NS_CONCEPT));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('FooConcept', SMW_NS_CONCEPT)));
#7 Printrequest
$pv = \SMWPropertyValue::makeUserProperty('Foobaz');
$description = new SomeProperty(new DIProperty('Foobar', true), new ValueDescription(DIWikiPage::newFromText('Bar')));
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, '', $pv));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), DIWikiPage::newFromText('Foobaz', SMW_NS_PROPERTY), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#8 Inverse printrequest
$pv = \SMWPropertyValue::makeUserProperty('Foobaz');
$pv->setInverse(true);
$description = new SomeProperty(new DIProperty('Foobar', true), new ValueDescription(DIWikiPage::newFromText('Bar')));
$description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, '', $pv));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('Bar'), DIWikiPage::newFromText('Foobaz', SMW_NS_PROPERTY), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#9 SMW_CMP_EQ comparator
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(DIWikiPage::newFromText('EQ_Comparator'), null, SMW_CMP_EQ));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), DIWikiPage::newFromText('EQ_Comparator'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
#10 Ignore entity with SMW_CMP_EQ comparator
$description = new SomeProperty(new DIProperty('Foobar'), new ValueDescription(DIWikiPage::newFromText('LIKE_Comparator'), null, SMW_CMP_LIKE));
$query = new Query($description);
$query->setContextPage($subject);
$provider[] = array($query, array(DIWikiPage::newFromText('Foo'), 'Foobar#102#' => DIWikiPage::newFromText('Foobar', SMW_NS_PROPERTY)));
return $provider;
}