public function testTryResolveSegmentForInvalidIdThrowsException() { $connection = $this->getMockBuilder('\\SMW\\MediaWiki\\Database')->disableOriginalConstructor()->getMock(); $temporaryIdTableCreator = $this->getMockBuilder('\\SMW\\SQLStore\\TemporaryIdTableCreator')->disableOriginalConstructor()->getMock(); $resolverOptions = $this->getMockBuilder('\\SMW\\SQLStore\\QueryEngine\\ResolverOptions')->disableOriginalConstructor()->getMock(); $instance = new QuerySegmentListResolver($connection, $temporaryIdTableCreator, $resolverOptions); $this->setExpectedException('RuntimeException'); $instance->resolveForSegmentId(42); }
/** * Using a preprocessed internal query description referenced by $rootid, compute * the proper debug output for the given query. * * @param Query $query * @param integer $rootid * * @return string */ private function getDebugQueryResult(Query $query, $rootid) { $qobj = $this->querySegments[$rootid]; $db = $this->store->getConnection(); $entries = array(); $sql_options = $this->getSQLOptions($query, $rootid); list($startOpts, $useIndex, $tailOpts) = $db->makeSelectOptions($sql_options); if ($qobj->joinfield !== '') { $entries['SQL Query'] = "<tt>SELECT DISTINCT {$qobj->alias}.smw_title AS t,{$qobj->alias}.smw_namespace AS ns FROM " . $db->tableName($qobj->joinTable) . " AS {$qobj->alias}" . $qobj->from . ($qobj->where === '' ? '' : ' WHERE ') . $qobj->where . "{$tailOpts} LIMIT " . $sql_options['LIMIT'] . ' OFFSET ' . $sql_options['OFFSET'] . ';</tt>'; } else { $entries['SQL Query'] = 'Empty result, no SQL query created.'; } $auxtables = ''; foreach ($this->querySegmentListResolver->getListOfResolvedQueries() as $table => $log) { $auxtables .= "<li>Temporary table {$table}"; foreach ($log as $q) { $auxtables .= "<br />  <tt>{$q}</tt>"; } $auxtables .= '</li>'; } if ($auxtables) { $entries['Auxilliary Tables Used'] = "<ul>{$auxtables}</ul>"; } else { $entries['Auxilliary Tables Used'] = 'No auxilliary tables used.'; } return QueryOutputFormatter::formatDebugOutput('SQLStore', $entries, $query); }