diff options
author | Robin Appelman <robin@icewind.nl> | 2024-02-15 18:16:13 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2024-02-16 10:59:33 +0100 |
commit | 3890aa54be4fc4b577528616249623d2aa531970 (patch) | |
tree | 293e9bdf466e053ae604b2bf4685416352e2b32b /tests | |
parent | 1c87cee5ad8754aec87cb1749f5a495cd8d80961 (diff) | |
download | nextcloud-server-3890aa54be4fc4b577528616249623d2aa531970.tar.gz nextcloud-server-3890aa54be4fc4b577528616249623d2aa531970.zip |
add some comments for the distributive operation and add another test
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php b/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php index 49a241a41af..4c7ecc9d46f 100644 --- a/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php +++ b/tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php @@ -130,4 +130,31 @@ class MergeDistributiveOperationsTest extends TestCase { $this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd")) and mimetype eq "text")', $operator->__toString()); } + + public function testMoveInnerOperations() { + $operator = new SearchBinaryOperator( + ISearchBinaryOperator::OPERATOR_OR, + [ + new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [ + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1), + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "foo"), + ]), + new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [ + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1), + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "bar"), + ]), + new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [ + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "storage", 1), + new SearchComparison(ISearchComparison::COMPARE_EQUAL, "path", "asd"), + new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, "size", "100"), + ]) + ] + ); + $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 1 and path eq "asd" and size gt "100"))', $operator->__toString()); + + $this->optimizer->processOperator($operator); + $this->simplifier->processOperator($operator); + + $this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or (path eq "asd" and size gt "100")))', $operator->__toString()); + } } |