SearchIntegrationTest.php 1.2 KB

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