private function assertQueryResultErrorCode($errorCode, QueryResult $queryResult) { if ($errorCode > 0) { return $this->assertNotEmpty($queryResult->getErrors()); } $this->assertEmpty($queryResult->getErrors()); }
/** * Provides a simple formatted string of all the error messages that occurred. * Can be used if not specific error formatting is desired. Compatible with HTML * and Wiki. * * @param SMWQueryResult $res * * @return string */ public function getErrorString(SMWQueryResult $res) { return $this->mShowErrors ? smwfEncodeMessages(array_merge($this->mErrors, $res->getErrors())) : ''; }
/** * @since 2.0 * * @param mixed $expected * @param QueryResult $queryResult */ public function assertThatQueryResultHasSubjects($expectedSubjects, QueryResult $queryResult) { $expectedSubjects = is_array($expectedSubjects) ? $expectedSubjects : array($expectedSubjects); $expectedToCount = count($expectedSubjects); $actualComparedToCount = 0; $this->assertEmpty($queryResult->getErrors()); if ($expectedToCount == 0) { return; } $resultSubjects = $queryResult->getResults(); foreach ($resultSubjects as $rKey => $resultSubject) { foreach ($expectedSubjects as $ekey => $expectedSubject) { if ($expectedSubject instanceof DIWikiPage && $expectedSubject->equals($resultSubject)) { $actualComparedToCount++; unset($expectedSubjects[$ekey]); unset($resultSubjects[$rKey]); } } } $this->assertEquals($expectedToCount, $actualComparedToCount, 'Failed asserting that ' . implode(', ', $expectedSubjects) . ' is set.'); $this->assertEmpty($resultSubjects, 'Failed to match results [ ' . implode(', ', $resultSubjects) . ' ] against the expected subjects.'); }