protected function CheckQuery($sQuery, $bIsCorrectQuery) { $oOql = new OqlInterpreter($sQuery); try { $oTrash = $oOql->Parse(); // Not expecting a given format, otherwise use ParseExpression/ParseObjectQuery/ParseValueSetQuery self::DumpVariable($oTrash); } catch (OQLException $OqlException) { if ($bIsCorrectQuery) { echo "<p>More info on this unexpected failure:<br/>" . $OqlException->getHtmlDesc() . "</p>\n"; throw $OqlException; return false; } else { // Everything is fine :-) echo "<p>More info on this expected failure:<br/>" . $OqlException->getHtmlDesc() . "</p>\n"; return true; } } catch (Exception $e) { if ($bIsCorrectQuery) { echo "<p>More info on this <b>un</b>expected failure:<br/>" . htmlentities($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</p>\n"; throw $OqlException; return false; } else { // Everything is fine :-) echo "<p>More info on this expected failure:<br/>" . htmlentities($e->getMessage(), ENT_QUOTES, 'UTF-8') . "</p>\n"; return true; } } // The query was correctly parsed, was it expected to be correct ? if ($bIsCorrectQuery) { return true; } else { throw new UnitTestException("The query '{$sQuery}' was parsed with success, while it shouldn't (?)"); return false; } }