Changeset View
Changeset View
Standalone View
Standalone View
src/search/__tests__/PhutilSearchQueryCompilerTestCase.php
| Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | private function assertCompileQueries( | ||||
| foreach ($tests as $input => $expect) { | foreach ($tests as $input => $expect) { | ||||
| $caught = null; | $caught = null; | ||||
| $query = null; | $query = null; | ||||
| $literal_query = null; | $literal_query = null; | ||||
| $stemmed_query = null; | $stemmed_query = null; | ||||
| try { | try { | ||||
| $compiler = id(new PhutilSearchQueryCompiler()) | $compiler = new PhutilSearchQueryCompiler(); | ||||
| ->setQuery($input); | |||||
| if ($operators !== null) { | if ($operators !== null) { | ||||
| $compiler->setOperators($operators); | $compiler->setOperators($operators); | ||||
| } | } | ||||
| if ($stemmer !== null) { | if ($stemmer !== null) { | ||||
| $compiler->setStemmer($stemmer); | $compiler->setStemmer($stemmer); | ||||
| } | } | ||||
| $tokens = $compiler->newTokens($input); | |||||
| if ($stemmer) { | if ($stemmer) { | ||||
| $literal_query = $compiler->compileLiteralQuery(); | $literal_query = $compiler->compileLiteralQuery($tokens); | ||||
| $stemmed_query = $compiler->compileStemmedQuery(); | $stemmed_query = $compiler->compileStemmedQuery($tokens); | ||||
| } else { | } else { | ||||
| $query = $compiler->compileQuery(); | $query = $compiler->compileQuery($tokens); | ||||
| } | } | ||||
| } catch (PhutilSearchQueryCompilerSyntaxException $ex) { | } catch (PhutilSearchQueryCompilerSyntaxException $ex) { | ||||
| $caught = $ex; | $caught = $ex; | ||||
| } | } | ||||
| if ($caught !== null) { | if ($caught !== null) { | ||||
| $query = false; | $query = false; | ||||
| $literal_query = false; | $literal_query = false; | ||||
| Show All 20 Lines | |||||