SearchIntegrationTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Test\Files\Search;
  3. use OC\Files\Search\SearchBinaryOperator;
  4. use OC\Files\Search\SearchComparison;
  5. use OC\Files\Search\SearchQuery;
  6. use OC\Files\Storage\Temporary;
  7. use OCP\Files\Search\ISearchBinaryOperator;
  8. use OCP\Files\Search\ISearchComparison;
  9. use Test\TestCase;
  10. /**
  11. * @group DB
  12. */
  13. class SearchIntegrationTest extends TestCase {
  14. private $cache;
  15. private $storage;
  16. protected function setUp(): void {
  17. parent::setUp();
  18. $this->storage = new Temporary([]);
  19. $this->cache = $this->storage->getCache();
  20. $this->storage->getScanner()->scan('');
  21. }
  22. public function testThousandAndOneFilters() {
  23. $id = $this->cache->put("file10", ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']);
  24. $comparisons = [];
  25. for($i = 1; $i <= 1001; $i++) {
  26. $comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, "name", "file$i");
  27. }
  28. $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons);
  29. $query = new SearchQuery($operator, 10, 0, []);
  30. $results = $this->cache->searchQuery($query);
  31. $this->assertCount(1, $results);
  32. $this->assertEquals($id, $results[0]->getId());
  33. }
  34. }