- $this->assertEquals(["biscuits"], $options->searches);
- $this->assertEquals(['"cheese"', '""', '"baked', 'beans"'], $options->exacts);
+ $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);