X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/93c677a6a955c75318c184d167737836c8c36cd5..refs/pull/5291/head:/tests/Entity/SearchOptionsTest.php diff --git a/tests/Entity/SearchOptionsTest.php b/tests/Entity/SearchOptionsTest.php index 543badcef..0c2ad271c 100644 --- a/tests/Entity/SearchOptionsTest.php +++ b/tests/Entity/SearchOptionsTest.php @@ -113,6 +113,19 @@ class SearchOptionsTest extends TestCase $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([ @@ -123,7 +136,7 @@ class SearchOptionsTest extends TestCase $options = SearchOptions::fromRequest($request); $this->assertCount(2, $options->tags->all()); - $this->assertEquals('b=c', $options->tags->negated()[0]->value); + $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);