@@ -142,4 +142,53 @@ public function test_from_request_properly_parses_out_extras_as_string()
142142 $ this ->assertEquals ('dino ' , $ options ->exacts ->all ()[0 ]->value );
143143 $ this ->assertTrue ($ options ->exacts ->all ()[0 ]->negated );
144144 }
145+
146+ public function test_from_string_results_are_count_limited_and_larger_for_logged_in_users ()
147+ {
148+ $ terms = [
149+ ...array_fill (0 , 40 , 'cat ' ),
150+ ...array_fill (0 , 50 , '"bees" ' ),
151+ ...array_fill (0 , 50 , '{is_template} ' ),
152+ ...array_fill (0 , 50 , '[a=b] ' ),
153+ ];
154+
155+ $ options = SearchOptions::fromString (implode (' ' , $ terms ));
156+
157+ $ this ->assertCount (5 , $ options ->searches ->all ());
158+ $ this ->assertCount (2 , $ options ->exacts ->all ());
159+ $ this ->assertCount (4 , $ options ->tags ->all ());
160+ $ this ->assertCount (5 , $ options ->filters ->all ());
161+
162+ $ this ->asEditor ();
163+ $ options = SearchOptions::fromString (implode (' ' , $ terms ));
164+
165+ $ this ->assertCount (10 , $ options ->searches ->all ());
166+ $ this ->assertCount (4 , $ options ->exacts ->all ());
167+ $ this ->assertCount (8 , $ options ->tags ->all ());
168+ $ this ->assertCount (10 , $ options ->filters ->all ());
169+ }
170+
171+ public function test_from_request_results_are_count_limited_and_larger_for_logged_in_users ()
172+ {
173+ $ request = new Request ([
174+ 'search ' => str_repeat ('hello ' , 20 ),
175+ 'tags ' => array_fill (0 , 20 , 'a=b ' ),
176+ 'extras ' => str_repeat ('-[b=c] -{viewed_by_me} -"dino" ' , 20 ),
177+ ]);
178+
179+ $ options = SearchOptions::fromRequest ($ request );
180+
181+ $ this ->assertCount (5 , $ options ->searches ->all ());
182+ $ this ->assertCount (2 , $ options ->exacts ->all ());
183+ $ this ->assertCount (4 , $ options ->tags ->all ());
184+ $ this ->assertCount (5 , $ options ->filters ->all ());
185+
186+ $ this ->asEditor ();
187+ $ options = SearchOptions::fromRequest ($ request );
188+
189+ $ this ->assertCount (10 , $ options ->searches ->all ());
190+ $ this ->assertCount (4 , $ options ->exacts ->all ());
191+ $ this ->assertCount (8 , $ options ->tags ->all ());
192+ $ this ->assertCount (10 , $ options ->filters ->all ());
193+ }
145194}
0 commit comments