public function testQueryParserExceptionsHandling() { $this->assertTrue(Search\QueryParser::queryParsingExceptionsSuppressed()); $query = Search\QueryParser::parse('contents:[business TO by}'); $this->assertEquals('contents business to by', $query->__toString()); Search\QueryParser::dontSuppressQueryParsingExceptions(); $this->assertFalse(Search\QueryParser::queryParsingExceptionsSuppressed()); try { $query = Search\QueryParser::parse('contents:[business TO by}'); $this->fail('exception wasn\'t raised while parsing a query'); } catch (Lucene\Exception\ExceptionInterface $e) { $this->assertEquals('Syntax error at char position 25.', $e->getMessage()); } Search\QueryParser::suppressQueryParsingExceptions(); $this->assertTrue(Search\QueryParser::queryParsingExceptionsSuppressed()); }