+ 'name' => 'dan',
+ 'cat' => 'happy',
+ ], $opts->filters->toValueMap());
+ }
+ public function test_it_cannot_parse_out_empty_exacts()
+ {
+ $options = SearchOptions::fromString('"" test ""');
+
+ $this->assertEmpty($options->exacts->toValueArray());
+ $this->assertCount(1, $options->searches->toValueArray());
+ }
+
+ public function test_from_request_properly_parses_exacts_from_search_terms()
+ {
+ $request = new Request([
+ 'search' => 'biscuits "cheese" "" "baked beans"'
+ ]);
+
+ $options = SearchOptions::fromRequest($request);
+ $this->assertEquals(["biscuits"], $options->searches->toValueArray());
+ $this->assertEquals(['"cheese"', '""', '"baked', 'beans"'], $options->exacts->toValueArray());
+ }
+
+ public function test_from_request_properly_parses_provided_types()
+ {
+ $request = new Request([
+ 'search' => '',
+ 'types' => ['page', 'book'],
+ ]);
+
+ $options = SearchOptions::fromRequest($request);
+ $filters = $options->filters->toValueMap();
+ $this->assertCount(1, $filters);
+ $this->assertEquals('page|book', $filters['type'] ?? 'notfound');
+ }
+
+ public function test_from_request_properly_parses_out_extras_as_string()
+ {
+ $request = new Request([
+ 'search' => '',
+ 'tags' => ['a=b'],
+ 'extras' => '-[b=c] -{viewed_by_me} -"dino"'
+ ]);
+
+ $options = SearchOptions::fromRequest($request);
+ $this->assertCount(2, $options->tags->all());
+ $this->assertEquals('b=c', $options->tags->negated()->all()[0]->value);
+ $this->assertEquals('viewed_by_me', $options->filters->all()[0]->getKey());
+ $this->assertTrue($options->filters->all()[0]->negated);
+ $this->assertEquals('dino', $options->exacts->all()[0]->value);
+ $this->assertTrue($options->exacts->all()[0]->negated);