blob: 6777047d68b20a3e835d968c52da30503ab4c199 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<?php
/**
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Search\QueryOptimizer;
use OC\Files\Search\QueryOptimizer\FlattenNestedBool;
use OC\Files\Search\QueryOptimizer\FlattenSingleArgumentBinaryOperation;
use OC\Files\Search\SearchBinaryOperator;
use OC\Files\Search\SearchComparison;
use OCP\Files\Search\ISearchBinaryOperator;
use OCP\Files\Search\ISearchComparison;
use Test\TestCase;
class FlattenNestedBoolTest extends TestCase {
private $optimizer;
private $simplifier;
protected function setUp(): void {
parent::setUp();
$this->optimizer = new FlattenNestedBool();
$this->simplifier = new FlattenSingleArgumentBinaryOperation();
}
public function testOrs(): void {
$operator = new SearchBinaryOperator(
ISearchBinaryOperator::OPERATOR_OR,
[
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
])
]
);
$this->assertEquals('(path eq "foo" or (path eq "bar" or path eq "asd"))', $operator->__toString());
$this->optimizer->processOperator($operator);
$this->simplifier->processOperator($operator);
$this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
}
}
|