]> BookStack Code Mirror - bookstack/blobdiff - tests/Entity/SearchOptionsTest.php
Themes: Documented public file serving
[bookstack] / tests / Entity / SearchOptionsTest.php
index 543badcef95b0cdd9eac0b839f8fb91431c0696f..0c2ad271c58892df4bfc7b186f948a76bf5b20b5 100644 (file)
@@ -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);