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