15 "Resources",
"ResourceId",
"SchemaId");
17 # pull out a Reflector 18 $Reflector =
new ReflectionObject($Engine);
20 # get a ReflectionMethod for PSSFW and make it accessible 21 $Parse = $Reflector->getMethod(
22 'ParseSearchStringForWords');
23 $Parse->setAccessible(TRUE);
25 # pull out class constants for easier use 30 # with AND logic, all terms are required 32 $Parse->invoke($Engine,
"THIS IS A TEST",
"AND"),
34 "this" => $Present | $Required,
35 "is" => $Present | $Required,
36 "a" => $Present | $Required,
37 "test" => $Present | $Required,
40 # with OR logic, no terms are required 42 $Parse->invoke($Engine,
"THIS IS A TEST",
"OR"),
50 # command characters (plus, minus, and tilde) override Logic 51 foreach (array(
"AND",
"OR") as $Logic)
54 $Parse->invoke($Engine,
"-WORD ~EXCLUSION +TEST", $Logic),
56 "word" => $Present | $Excluded,
57 "exclusion" => $Present,
58 "test" => $Present | $Required,
62 # possessive plurals are stripped from search words 64 $Parse->invoke($Engine,
"Children's toys",
"AND"),
66 "children" => $Present | $Required,
67 "toys" => $Present | $Required,
70 # single quotes are stripped from search string 72 $Parse->invoke($Engine,
"Children's 'toys'",
"AND"),
74 "children" => $Present | $Required,
75 "toys" => $Present | $Required,
78 # phrases are stripped from search words 80 $Parse->invoke($Engine,
"\"test kitten\"",
"AND"),
83 # groups are stripped from search words 85 $Parse->invoke($Engine,
"(test kitten)",
"AND"),
88 # phrases treated as regular words when IgnoreGroups is TRUE 90 $Parse->invoke($Engine,
"\"test kitten\"",
"AND", TRUE),
92 "test" => $Present | $Required,
93 "kitten" => $Present | $Required,
96 # groups treated as regular words when IgnoreGroups is TRUE 98 $Parse->invoke($Engine,
"(test kitten)",
"AND", TRUE),
100 "test" => $Present | $Required,
101 "kitten" => $Present | $Required,
104 # punctuation is treated as a word separator 106 $Parse->invoke($Engine,
"test...kitten",
"AND"),
108 "test" => $Present | $Required,
109 "kitten" => $Present | $Required,
112 # hyphenated words are considered as separate parts and also 113 # as one combined word 115 $Parse->invoke($Engine,
"pre-process",
"AND"),
117 "pre" => $Present | $Required,
118 "process" => $Present | $Required,
119 "preprocess" => $Present | $Required,
122 # repeated runs of hyphens in the middle of a word are 123 # squeezed to a single hyphen and then processed normally 125 $Parse->invoke($Engine,
"pre---process",
"AND"),
127 "pre" => $Present | $Required,
128 "process" => $Present | $Required,
129 "preprocess" => $Present | $Required,
132 # single non-hyphen command characters (plus and tilde) in the 133 # middle of words are treated as word separators 134 foreach (array(
"+",
"~") as $Sep)
137 $Parse->invoke($Engine,
"pre".$Sep.
"process",
"AND"),
139 "pre" => $Present | $Required,
140 "process" => $Present | $Required,
144 # runs of non-hyphen command characters (plus and tilde) in 145 # the middle of words are treated as word separators 146 foreach (array(
"+",
"~") as $Sep)
149 $Parse->invoke($Engine,
"pre".$Sep.$Sep.$Sep.
"process",
"AND"),
151 "pre" => $Present | $Required,
152 "process" => $Present | $Required,
156 # command characters (plus, minus, tilde) at the end of a word are 158 foreach (array(
"+",
"~",
"-") as $Tail)
161 $Parse->invoke($Engine,
"test".$Tail.
" kitten",
"AND"),
163 "test" => $Present | $Required,
164 "kitten" => $Present | $Required,
168 # runs of command characters (plus, minus, tilde) at the end 169 # of a word are ignored 170 foreach (array(
"+",
"~",
"-") as $Tail)
173 $Parse->invoke($Engine,
"test".$Tail.$Tail.$Tail.
" kitten",
"AND"),
175 "test" => $Present | $Required,
176 "kitten" => $Present | $Required,
testParseSearchStringForWords()
Test ParseSearchStringForWords.
Test cases for SearchEngine.
Core metadata archive search engine class.
Create a concrete class extending SearchEngine (which is abstract) for testing.