Completed
Push — master ( 38c8ea...c9712b )
by Joas
40:21
created
tests/lib/User/Dummy.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@
 block discarded – undo
8 8
 namespace Test\User;
9 9
 
10 10
 class Dummy extends Backend {
11
-	protected function setUp(): void {
12
-		parent::setUp();
13
-		$this->backend = new \Test\Util\User\Dummy();
14
-	}
11
+    protected function setUp(): void {
12
+        parent::setUp();
13
+        $this->backend = new \Test\Util\User\Dummy();
14
+    }
15 15
 }
Please login to merge, or discard this patch.
tests/lib/User/AvatarUserDummy.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 namespace Test\User;
9 9
 
10 10
 class AvatarUserDummy extends \Test\Util\User\Dummy {
11
-	public function canChangeAvatar($uid) {
12
-		return true;
13
-	}
11
+    public function canChangeAvatar($uid) {
12
+        return true;
13
+    }
14 14
 }
Please login to merge, or discard this patch.
tests/lib/Files/Search/QueryOptimizer/OrEqualsToInTest.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -14,110 +14,110 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class OrEqualsToInTest extends TestCase {
17
-	private $optimizer;
18
-	private $simplifier;
19
-
20
-	protected function setUp(): void {
21
-		parent::setUp();
22
-
23
-		$this->optimizer = new OrEqualsToIn();
24
-		$this->simplifier = new FlattenSingleArgumentBinaryOperation();
25
-	}
26
-
27
-	public function testOrs(): void {
28
-		$operator = new SearchBinaryOperator(
29
-			ISearchBinaryOperator::OPERATOR_OR,
30
-			[
31
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
32
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
33
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
34
-			]
35
-		);
36
-		$this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
37
-
38
-		$this->optimizer->processOperator($operator);
39
-		$this->simplifier->processOperator($operator);
40
-
41
-		$this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
42
-	}
43
-
44
-	public function testOrsMultipleFields(): void {
45
-		$operator = new SearchBinaryOperator(
46
-			ISearchBinaryOperator::OPERATOR_OR,
47
-			[
48
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
49
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
50
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'fileid', 1),
51
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'fileid', 2),
52
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'asd'),
53
-			]
54
-		);
55
-		$this->assertEquals('(path eq "foo" or path eq "bar" or fileid eq 1 or fileid eq 2 or mimetype eq "asd")', $operator->__toString());
56
-
57
-		$this->optimizer->processOperator($operator);
58
-		$this->simplifier->processOperator($operator);
59
-
60
-		$this->assertEquals('(path in ["foo","bar"] or fileid in [1,2] or mimetype eq "asd")', $operator->__toString());
61
-	}
62
-
63
-	public function testPreserveHints(): void {
64
-		$operator = new SearchBinaryOperator(
65
-			ISearchBinaryOperator::OPERATOR_OR,
66
-			[
67
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
68
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
69
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
70
-			]
71
-		);
72
-		foreach ($operator->getArguments() as $argument) {
73
-			$argument->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, false);
74
-		}
75
-		$this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
76
-
77
-		$this->optimizer->processOperator($operator);
78
-		$this->simplifier->processOperator($operator);
79
-
80
-		$this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
81
-		$this->assertEquals(false, $operator->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true));
82
-	}
83
-
84
-	public function testOrSomeEq(): void {
85
-		$operator = new SearchBinaryOperator(
86
-			ISearchBinaryOperator::OPERATOR_OR,
87
-			[
88
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
89
-				new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'foo%'),
90
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
91
-			]
92
-		);
93
-		$this->assertEquals('(path eq "foo" or path like "foo%" or path eq "bar")', $operator->__toString());
94
-
95
-		$this->optimizer->processOperator($operator);
96
-		$this->simplifier->processOperator($operator);
97
-
98
-		$this->assertEquals('(path in ["foo","bar"] or path like "foo%")', $operator->__toString());
99
-	}
100
-
101
-	public function testOrsInside(): void {
102
-		$operator = new SearchBinaryOperator(
103
-			ISearchBinaryOperator::OPERATOR_AND,
104
-			[
105
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'text'),
106
-				new SearchBinaryOperator(
107
-					ISearchBinaryOperator::OPERATOR_OR,
108
-					[
109
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
110
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
111
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
112
-					]
113
-				)
114
-			]
115
-		);
116
-		$this->assertEquals('(mimetype eq "text" and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
117
-
118
-		$this->optimizer->processOperator($operator);
119
-		$this->simplifier->processOperator($operator);
120
-
121
-		$this->assertEquals('(mimetype eq "text" and path in ["foo","bar","asd"])', $operator->__toString());
122
-	}
17
+    private $optimizer;
18
+    private $simplifier;
19
+
20
+    protected function setUp(): void {
21
+        parent::setUp();
22
+
23
+        $this->optimizer = new OrEqualsToIn();
24
+        $this->simplifier = new FlattenSingleArgumentBinaryOperation();
25
+    }
26
+
27
+    public function testOrs(): void {
28
+        $operator = new SearchBinaryOperator(
29
+            ISearchBinaryOperator::OPERATOR_OR,
30
+            [
31
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
32
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
33
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
34
+            ]
35
+        );
36
+        $this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
37
+
38
+        $this->optimizer->processOperator($operator);
39
+        $this->simplifier->processOperator($operator);
40
+
41
+        $this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
42
+    }
43
+
44
+    public function testOrsMultipleFields(): void {
45
+        $operator = new SearchBinaryOperator(
46
+            ISearchBinaryOperator::OPERATOR_OR,
47
+            [
48
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
49
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
50
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'fileid', 1),
51
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'fileid', 2),
52
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'asd'),
53
+            ]
54
+        );
55
+        $this->assertEquals('(path eq "foo" or path eq "bar" or fileid eq 1 or fileid eq 2 or mimetype eq "asd")', $operator->__toString());
56
+
57
+        $this->optimizer->processOperator($operator);
58
+        $this->simplifier->processOperator($operator);
59
+
60
+        $this->assertEquals('(path in ["foo","bar"] or fileid in [1,2] or mimetype eq "asd")', $operator->__toString());
61
+    }
62
+
63
+    public function testPreserveHints(): void {
64
+        $operator = new SearchBinaryOperator(
65
+            ISearchBinaryOperator::OPERATOR_OR,
66
+            [
67
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
68
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
69
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
70
+            ]
71
+        );
72
+        foreach ($operator->getArguments() as $argument) {
73
+            $argument->setQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, false);
74
+        }
75
+        $this->assertEquals('(path eq "foo" or path eq "bar" or path eq "asd")', $operator->__toString());
76
+
77
+        $this->optimizer->processOperator($operator);
78
+        $this->simplifier->processOperator($operator);
79
+
80
+        $this->assertEquals('path in ["foo","bar","asd"]', $operator->__toString());
81
+        $this->assertEquals(false, $operator->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true));
82
+    }
83
+
84
+    public function testOrSomeEq(): void {
85
+        $operator = new SearchBinaryOperator(
86
+            ISearchBinaryOperator::OPERATOR_OR,
87
+            [
88
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
89
+                new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'foo%'),
90
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
91
+            ]
92
+        );
93
+        $this->assertEquals('(path eq "foo" or path like "foo%" or path eq "bar")', $operator->__toString());
94
+
95
+        $this->optimizer->processOperator($operator);
96
+        $this->simplifier->processOperator($operator);
97
+
98
+        $this->assertEquals('(path in ["foo","bar"] or path like "foo%")', $operator->__toString());
99
+    }
100
+
101
+    public function testOrsInside(): void {
102
+        $operator = new SearchBinaryOperator(
103
+            ISearchBinaryOperator::OPERATOR_AND,
104
+            [
105
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'text'),
106
+                new SearchBinaryOperator(
107
+                    ISearchBinaryOperator::OPERATOR_OR,
108
+                    [
109
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
110
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
111
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
112
+                    ]
113
+                )
114
+            ]
115
+        );
116
+        $this->assertEquals('(mimetype eq "text" and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
117
+
118
+        $this->optimizer->processOperator($operator);
119
+        $this->simplifier->processOperator($operator);
120
+
121
+        $this->assertEquals('(mimetype eq "text" and path in ["foo","bar","asd"])', $operator->__toString());
122
+    }
123 123
 }
Please login to merge, or discard this patch.
tests/lib/Files/Search/QueryOptimizer/CombinedTests.php 1 patch
Indentation   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -13,182 +13,182 @@
 block discarded – undo
13 13
 use Test\TestCase;
14 14
 
15 15
 class CombinedTests extends TestCase {
16
-	private QueryOptimizer $optimizer;
17
-
18
-	protected function setUp(): void {
19
-		parent::setUp();
20
-
21
-		$this->optimizer = new QueryOptimizer();
22
-	}
23
-
24
-	public function testBasicOrOfAnds(): void {
25
-		$operator = new SearchBinaryOperator(
26
-			ISearchBinaryOperator::OPERATOR_OR,
27
-			[
28
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
29
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
30
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
31
-				]),
32
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
33
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
34
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
35
-				]),
36
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
37
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
38
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
39
-				])
40
-			]
41
-		);
42
-		$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"))', $operator->__toString());
43
-
44
-		$this->optimizer->processOperator($operator);
45
-
46
-		$this->assertEquals('(storage eq 1 and path in ["foo","bar","asd"])', $operator->__toString());
47
-	}
48
-
49
-	public function testComplexSearchPattern1(): void {
50
-		$operator = new SearchBinaryOperator(
51
-			ISearchBinaryOperator::OPERATOR_OR,
52
-			[
53
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
54
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
55
-				]),
56
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
57
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
58
-					new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
59
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '201'),
60
-						new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', '201/%'),
61
-					]),
62
-				]),
63
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
64
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
65
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '301'),
66
-				]),
67
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
68
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
69
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '401'),
70
-				]),
71
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
72
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
73
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '302'),
74
-				]),
75
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
76
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
77
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '402'),
78
-				]),
79
-			]
80
-		);
81
-		$this->assertEquals('((storage eq 1) or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
82
-
83
-		$this->optimizer->processOperator($operator);
84
-
85
-		$this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
86
-	}
87
-
88
-	public function testComplexSearchPattern2(): void {
89
-		$operator = new SearchBinaryOperator(
90
-			ISearchBinaryOperator::OPERATOR_OR,
91
-			[
92
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
93
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
94
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
95
-					new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
96
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '201'),
97
-						new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', '201/%'),
98
-					]),
99
-				]),
100
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
101
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
102
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '301'),
103
-				]),
104
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
105
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
106
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '401'),
107
-				]),
108
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
109
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
110
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '302'),
111
-				]),
112
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
113
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
114
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '402'),
115
-				]),
116
-			]
117
-		);
118
-		$this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
119
-
120
-		$this->optimizer->processOperator($operator);
121
-
122
-		$this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
123
-	}
124
-
125
-	public function testApplySearchConstraints1(): void {
126
-		$operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
127
-			new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
128
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
129
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/png'),
130
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/jpeg'),
131
-				]),
132
-			]),
133
-			new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
134
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
135
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
136
-					new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
137
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files'),
138
-						new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'files/%'),
139
-					]),
140
-				]),
141
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
142
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
143
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
144
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/301'),
145
-				]),
146
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
147
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
148
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/302'),
149
-				]),
150
-			]),
151
-		]);
152
-		$this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
153
-
154
-		$this->optimizer->processOperator($operator);
155
-
156
-		$this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
157
-	}
158
-
159
-	public function testApplySearchConstraints2(): void {
160
-		$operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
161
-			new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
162
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
163
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/png'),
164
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/jpeg'),
165
-				]),
166
-			]),
167
-			new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
168
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
169
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
170
-					new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
171
-						new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files'),
172
-						new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'files/%'),
173
-					]),
174
-				]),
175
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
176
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
177
-				]),
178
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
179
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
180
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/301'),
181
-				]),
182
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
183
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
184
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/302'),
185
-				]),
186
-			]),
187
-		]);
188
-		$this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or (storage eq 2) or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
189
-
190
-		$this->optimizer->processOperator($operator);
191
-
192
-		$this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
193
-	}
16
+    private QueryOptimizer $optimizer;
17
+
18
+    protected function setUp(): void {
19
+        parent::setUp();
20
+
21
+        $this->optimizer = new QueryOptimizer();
22
+    }
23
+
24
+    public function testBasicOrOfAnds(): void {
25
+        $operator = new SearchBinaryOperator(
26
+            ISearchBinaryOperator::OPERATOR_OR,
27
+            [
28
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
29
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
30
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
31
+                ]),
32
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
33
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
34
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
35
+                ]),
36
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
37
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
38
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
39
+                ])
40
+            ]
41
+        );
42
+        $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"))', $operator->__toString());
43
+
44
+        $this->optimizer->processOperator($operator);
45
+
46
+        $this->assertEquals('(storage eq 1 and path in ["foo","bar","asd"])', $operator->__toString());
47
+    }
48
+
49
+    public function testComplexSearchPattern1(): void {
50
+        $operator = new SearchBinaryOperator(
51
+            ISearchBinaryOperator::OPERATOR_OR,
52
+            [
53
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
54
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
55
+                ]),
56
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
57
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
58
+                    new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
59
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '201'),
60
+                        new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', '201/%'),
61
+                    ]),
62
+                ]),
63
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
64
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
65
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '301'),
66
+                ]),
67
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
68
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
69
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '401'),
70
+                ]),
71
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
72
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
73
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '302'),
74
+                ]),
75
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
76
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
77
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '402'),
78
+                ]),
79
+            ]
80
+        );
81
+        $this->assertEquals('((storage eq 1) or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
82
+
83
+        $this->optimizer->processOperator($operator);
84
+
85
+        $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
86
+    }
87
+
88
+    public function testComplexSearchPattern2(): void {
89
+        $operator = new SearchBinaryOperator(
90
+            ISearchBinaryOperator::OPERATOR_OR,
91
+            [
92
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
93
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
94
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
95
+                    new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
96
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '201'),
97
+                        new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', '201/%'),
98
+                    ]),
99
+                ]),
100
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
101
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
102
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '301'),
103
+                ]),
104
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
105
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
106
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '401'),
107
+                ]),
108
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
109
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
110
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '302'),
111
+                ]),
112
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
113
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 4),
114
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', '402'),
115
+                ]),
116
+            ]
117
+        );
118
+        $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path eq "301") or (storage eq 4 and path eq "401") or (storage eq 3 and path eq "302") or (storage eq 4 and path eq "402"))', $operator->__toString());
119
+
120
+        $this->optimizer->processOperator($operator);
121
+
122
+        $this->assertEquals('(storage eq 1 or (storage eq 2 and (path eq "201" or path like "201\/%")) or (storage eq 3 and path in ["301","302"]) or (storage eq 4 and path in ["401","402"]))', $operator->__toString());
123
+    }
124
+
125
+    public function testApplySearchConstraints1(): void {
126
+        $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
127
+            new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
128
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
129
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/png'),
130
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/jpeg'),
131
+                ]),
132
+            ]),
133
+            new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
134
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
135
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
136
+                    new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
137
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files'),
138
+                        new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'files/%'),
139
+                    ]),
140
+                ]),
141
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
142
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
143
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
144
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/301'),
145
+                ]),
146
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
147
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
148
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/302'),
149
+                ]),
150
+            ]),
151
+        ]);
152
+        $this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
153
+
154
+        $this->optimizer->processOperator($operator);
155
+
156
+        $this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
157
+    }
158
+
159
+    public function testApplySearchConstraints2(): void {
160
+        $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
161
+            new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
162
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
163
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/png'),
164
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'image/jpeg'),
165
+                ]),
166
+            ]),
167
+            new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
168
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
169
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
170
+                    new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, [
171
+                        new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files'),
172
+                        new SearchComparison(ISearchComparison::COMPARE_LIKE, 'path', 'files/%'),
173
+                    ]),
174
+                ]),
175
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
176
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
177
+                ]),
178
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
179
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
180
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/301'),
181
+                ]),
182
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
183
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
184
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'files/302'),
185
+                ]),
186
+            ]),
187
+        ]);
188
+        $this->assertEquals('(((mimetype eq "image\/png" or mimetype eq "image\/jpeg")) and ((storage eq 1 and (path eq "files" or path like "files\/%")) or (storage eq 2) or (storage eq 3 and path eq "files\/301") or (storage eq 3 and path eq "files\/302")))', $operator->__toString());
189
+
190
+        $this->optimizer->processOperator($operator);
191
+
192
+        $this->assertEquals('(mimetype in ["image\/png","image\/jpeg"] and ((storage eq 1 and (path eq "files" or path like "files\/%")) or storage eq 2 or (storage eq 3 and path in ["files\/301","files\/302"])))', $operator->__toString());
193
+    }
194 194
 }
Please login to merge, or discard this patch.
tests/lib/Files/Search/QueryOptimizer/MergeDistributiveOperationsTest.php 1 patch
Indentation   +146 added lines, -146 removed lines patch added patch discarded remove patch
@@ -14,150 +14,150 @@
 block discarded – undo
14 14
 use Test\TestCase;
15 15
 
16 16
 class MergeDistributiveOperationsTest extends TestCase {
17
-	private $optimizer;
18
-	private $simplifier;
19
-
20
-	protected function setUp(): void {
21
-		parent::setUp();
22
-
23
-		$this->optimizer = new MergeDistributiveOperations();
24
-		$this->simplifier = new FlattenSingleArgumentBinaryOperation();
25
-	}
26
-
27
-	public function testBasicOrOfAnds(): void {
28
-		$operator = new SearchBinaryOperator(
29
-			ISearchBinaryOperator::OPERATOR_OR,
30
-			[
31
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
32
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
33
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
34
-				]),
35
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
36
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
37
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
38
-				]),
39
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
40
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
41
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
42
-				])
43
-			]
44
-		);
45
-		$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"))', $operator->__toString());
46
-
47
-		$this->optimizer->processOperator($operator);
48
-		$this->simplifier->processOperator($operator);
49
-
50
-		$this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
51
-	}
52
-
53
-	public function testDontTouchIfNotSame(): void {
54
-		$operator = new SearchBinaryOperator(
55
-			ISearchBinaryOperator::OPERATOR_OR,
56
-			[
57
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
58
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
59
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
60
-				]),
61
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
62
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
63
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
64
-				]),
65
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
66
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
67
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
68
-				])
69
-			]
70
-		);
71
-		$this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
72
-
73
-		$this->optimizer->processOperator($operator);
74
-		$this->simplifier->processOperator($operator);
75
-
76
-		$this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
77
-	}
78
-
79
-	public function testMergePartial(): void {
80
-		$operator = new SearchBinaryOperator(
81
-			ISearchBinaryOperator::OPERATOR_OR,
82
-			[
83
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
84
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
85
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
86
-				]),
87
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
88
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
89
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
90
-				]),
91
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
92
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
93
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
94
-				])
95
-			]
96
-		);
97
-		$this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 2 and path eq "asd"))', $operator->__toString());
98
-
99
-		$this->optimizer->processOperator($operator);
100
-		$this->simplifier->processOperator($operator);
101
-
102
-		$this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar")) or (storage eq 2 and path eq "asd"))', $operator->__toString());
103
-	}
104
-
105
-	public function testOptimizeInside(): void {
106
-		$operator = new SearchBinaryOperator(
107
-			ISearchBinaryOperator::OPERATOR_AND,
108
-			[
109
-				new SearchBinaryOperator(
110
-					ISearchBinaryOperator::OPERATOR_OR,
111
-					[
112
-						new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
113
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
114
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
115
-						]),
116
-						new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
117
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
118
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
119
-						]),
120
-						new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
121
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
122
-							new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
123
-						])
124
-					]
125
-				),
126
-				new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'text')
127
-			]
128
-		);
129
-		$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 mimetype eq "text")', $operator->__toString());
130
-
131
-		$this->optimizer->processOperator($operator);
132
-		$this->simplifier->processOperator($operator);
133
-
134
-		$this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd")) and mimetype eq "text")', $operator->__toString());
135
-	}
136
-
137
-	public function testMoveInnerOperations(): void {
138
-		$operator = new SearchBinaryOperator(
139
-			ISearchBinaryOperator::OPERATOR_OR,
140
-			[
141
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
142
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
143
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
144
-				]),
145
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
146
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
147
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
148
-				]),
149
-				new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
150
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
151
-					new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
152
-					new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, 'size', '100'),
153
-				])
154
-			]
155
-		);
156
-		$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());
157
-
158
-		$this->optimizer->processOperator($operator);
159
-		$this->simplifier->processOperator($operator);
160
-
161
-		$this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or (path eq "asd" and size gt "100")))', $operator->__toString());
162
-	}
17
+    private $optimizer;
18
+    private $simplifier;
19
+
20
+    protected function setUp(): void {
21
+        parent::setUp();
22
+
23
+        $this->optimizer = new MergeDistributiveOperations();
24
+        $this->simplifier = new FlattenSingleArgumentBinaryOperation();
25
+    }
26
+
27
+    public function testBasicOrOfAnds(): void {
28
+        $operator = new SearchBinaryOperator(
29
+            ISearchBinaryOperator::OPERATOR_OR,
30
+            [
31
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
32
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
33
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
34
+                ]),
35
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
36
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
37
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
38
+                ]),
39
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
40
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
41
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
42
+                ])
43
+            ]
44
+        );
45
+        $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"))', $operator->__toString());
46
+
47
+        $this->optimizer->processOperator($operator);
48
+        $this->simplifier->processOperator($operator);
49
+
50
+        $this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd"))', $operator->__toString());
51
+    }
52
+
53
+    public function testDontTouchIfNotSame(): void {
54
+        $operator = new SearchBinaryOperator(
55
+            ISearchBinaryOperator::OPERATOR_OR,
56
+            [
57
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
58
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
59
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
60
+                ]),
61
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
62
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
63
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
64
+                ]),
65
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
66
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 3),
67
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
68
+                ])
69
+            ]
70
+        );
71
+        $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
72
+
73
+        $this->optimizer->processOperator($operator);
74
+        $this->simplifier->processOperator($operator);
75
+
76
+        $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 2 and path eq "bar") or (storage eq 3 and path eq "asd"))', $operator->__toString());
77
+    }
78
+
79
+    public function testMergePartial(): void {
80
+        $operator = new SearchBinaryOperator(
81
+            ISearchBinaryOperator::OPERATOR_OR,
82
+            [
83
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
84
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
85
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
86
+                ]),
87
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
88
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
89
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
90
+                ]),
91
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
92
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 2),
93
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
94
+                ])
95
+            ]
96
+        );
97
+        $this->assertEquals('((storage eq 1 and path eq "foo") or (storage eq 1 and path eq "bar") or (storage eq 2 and path eq "asd"))', $operator->__toString());
98
+
99
+        $this->optimizer->processOperator($operator);
100
+        $this->simplifier->processOperator($operator);
101
+
102
+        $this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar")) or (storage eq 2 and path eq "asd"))', $operator->__toString());
103
+    }
104
+
105
+    public function testOptimizeInside(): void {
106
+        $operator = new SearchBinaryOperator(
107
+            ISearchBinaryOperator::OPERATOR_AND,
108
+            [
109
+                new SearchBinaryOperator(
110
+                    ISearchBinaryOperator::OPERATOR_OR,
111
+                    [
112
+                        new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
113
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
114
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
115
+                        ]),
116
+                        new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
117
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
118
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
119
+                        ]),
120
+                        new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
121
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
122
+                            new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
123
+                        ])
124
+                    ]
125
+                ),
126
+                new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', 'text')
127
+            ]
128
+        );
129
+        $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 mimetype eq "text")', $operator->__toString());
130
+
131
+        $this->optimizer->processOperator($operator);
132
+        $this->simplifier->processOperator($operator);
133
+
134
+        $this->assertEquals('((storage eq 1 and (path eq "foo" or path eq "bar" or path eq "asd")) and mimetype eq "text")', $operator->__toString());
135
+    }
136
+
137
+    public function testMoveInnerOperations(): void {
138
+        $operator = new SearchBinaryOperator(
139
+            ISearchBinaryOperator::OPERATOR_OR,
140
+            [
141
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
142
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
143
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'foo'),
144
+                ]),
145
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
146
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
147
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'bar'),
148
+                ]),
149
+                new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, [
150
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'storage', 1),
151
+                    new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', 'asd'),
152
+                    new SearchComparison(ISearchComparison::COMPARE_GREATER_THAN, 'size', '100'),
153
+                ])
154
+            ]
155
+        );
156
+        $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());
157
+
158
+        $this->optimizer->processOperator($operator);
159
+        $this->simplifier->processOperator($operator);
160
+
161
+        $this->assertEquals('(storage eq 1 and (path eq "foo" or path eq "bar" or (path eq "asd" and size gt "100")))', $operator->__toString());
162
+    }
163 163
 }
Please login to merge, or discard this patch.
tests/lib/Files/Search/SearchIntegrationTest.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -17,31 +17,31 @@
 block discarded – undo
17 17
  * @group DB
18 18
  */
19 19
 class SearchIntegrationTest extends TestCase {
20
-	private $cache;
21
-	private $storage;
20
+    private $cache;
21
+    private $storage;
22 22
 
23
-	protected function setUp(): void {
24
-		parent::setUp();
23
+    protected function setUp(): void {
24
+        parent::setUp();
25 25
 
26
-		$this->storage = new Temporary([]);
27
-		$this->cache = $this->storage->getCache();
28
-		$this->storage->getScanner()->scan('');
29
-	}
26
+        $this->storage = new Temporary([]);
27
+        $this->cache = $this->storage->getCache();
28
+        $this->storage->getScanner()->scan('');
29
+    }
30 30
 
31 31
 
32
-	public function testThousandAndOneFilters(): void {
33
-		$id = $this->cache->put('file10', ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']);
32
+    public function testThousandAndOneFilters(): void {
33
+        $id = $this->cache->put('file10', ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']);
34 34
 
35
-		$comparisons = [];
36
-		for ($i = 1; $i <= 1001; $i++) {
37
-			$comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', "file$i");
38
-		}
39
-		$operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons);
40
-		$query = new SearchQuery($operator, 10, 0, []);
35
+        $comparisons = [];
36
+        for ($i = 1; $i <= 1001; $i++) {
37
+            $comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', "file$i");
38
+        }
39
+        $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons);
40
+        $query = new SearchQuery($operator, 10, 0, []);
41 41
 
42
-		$results = $this->cache->searchQuery($query);
42
+        $results = $this->cache->searchQuery($query);
43 43
 
44
-		$this->assertCount(1, $results);
45
-		$this->assertEquals($id, $results[0]->getId());
46
-	}
44
+        $this->assertCount(1, $results);
45
+        $this->assertEquals($id, $results[0]->getId());
46
+    }
47 47
 }
Please login to merge, or discard this patch.
tests/lib/Files/SimpleFS/SimpleFolderTest.php 1 patch
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -19,96 +19,96 @@
 block discarded – undo
19 19
  * @group DB
20 20
  */
21 21
 class SimpleFolderTest extends \Test\TestCase {
22
-	use MountProviderTrait;
23
-	use UserTrait;
22
+    use MountProviderTrait;
23
+    use UserTrait;
24 24
 
25
-	/** @var Folder */
26
-	private $folder;
25
+    /** @var Folder */
26
+    private $folder;
27 27
 
28
-	/** @var Folder */
29
-	private $parentFolder;
28
+    /** @var Folder */
29
+    private $parentFolder;
30 30
 
31
-	/** @var SimpleFolder */
32
-	private $simpleFolder;
31
+    /** @var SimpleFolder */
32
+    private $simpleFolder;
33 33
 
34
-	private $storage;
34
+    private $storage;
35 35
 
36
-	protected function setUp(): void {
37
-		parent::setUp();
36
+    protected function setUp(): void {
37
+        parent::setUp();
38 38
 
39
-		$this->storage = new Temporary([]);
40
-		$this->createUser('simple', 'simple');
41
-		$this->registerMount('simple', $this->storage, '/simple/files');
42
-		$this->loginAsUser('simple');
39
+        $this->storage = new Temporary([]);
40
+        $this->createUser('simple', 'simple');
41
+        $this->registerMount('simple', $this->storage, '/simple/files');
42
+        $this->loginAsUser('simple');
43 43
 
44
-		$this->parentFolder = \OC::$server->getUserFolder('simple');
44
+        $this->parentFolder = \OC::$server->getUserFolder('simple');
45 45
 
46
-		$this->folder = $this->parentFolder->newFolder('test');
47
-		$this->simpleFolder = new SimpleFolder($this->folder);
48
-	}
46
+        $this->folder = $this->parentFolder->newFolder('test');
47
+        $this->simpleFolder = new SimpleFolder($this->folder);
48
+    }
49 49
 
50
-	public function testGetName(): void {
51
-		$this->assertEquals('test', $this->simpleFolder->getName());
52
-	}
50
+    public function testGetName(): void {
51
+        $this->assertEquals('test', $this->simpleFolder->getName());
52
+    }
53 53
 
54
-	public function testDelete(): void {
55
-		$this->assertTrue($this->parentFolder->nodeExists('test'));
56
-		$this->simpleFolder->delete();
57
-		$this->assertFalse($this->parentFolder->nodeExists('test'));
58
-	}
54
+    public function testDelete(): void {
55
+        $this->assertTrue($this->parentFolder->nodeExists('test'));
56
+        $this->simpleFolder->delete();
57
+        $this->assertFalse($this->parentFolder->nodeExists('test'));
58
+    }
59 59
 
60
-	public function testFileExists(): void {
61
-		$this->folder->newFile('exists');
60
+    public function testFileExists(): void {
61
+        $this->folder->newFile('exists');
62 62
 
63
-		$this->assertFalse($this->simpleFolder->fileExists('not-exists'));
64
-		$this->assertTrue($this->simpleFolder->fileExists('exists'));
65
-	}
63
+        $this->assertFalse($this->simpleFolder->fileExists('not-exists'));
64
+        $this->assertTrue($this->simpleFolder->fileExists('exists'));
65
+    }
66 66
 
67
-	public function testGetFile(): void {
68
-		$this->folder->newFile('exists');
67
+    public function testGetFile(): void {
68
+        $this->folder->newFile('exists');
69 69
 
70
-		$result = $this->simpleFolder->getFile('exists');
71
-		$this->assertInstanceOf(ISimpleFile::class, $result);
70
+        $result = $this->simpleFolder->getFile('exists');
71
+        $this->assertInstanceOf(ISimpleFile::class, $result);
72 72
 
73
-		$this->expectException(NotFoundException::class);
74
-		$this->simpleFolder->getFile('not-exists');
75
-	}
73
+        $this->expectException(NotFoundException::class);
74
+        $this->simpleFolder->getFile('not-exists');
75
+    }
76 76
 
77
-	public function testNewFile(): void {
78
-		$result = $this->simpleFolder->newFile('file');
79
-		$this->assertInstanceOf(ISimpleFile::class, $result);
80
-		$this->assertFalse($this->folder->nodeExists('file'));
81
-		$result->putContent('bar');
77
+    public function testNewFile(): void {
78
+        $result = $this->simpleFolder->newFile('file');
79
+        $this->assertInstanceOf(ISimpleFile::class, $result);
80
+        $this->assertFalse($this->folder->nodeExists('file'));
81
+        $result->putContent('bar');
82 82
 
83
-		$this->assertTrue($this->folder->nodeExists('file'));
84
-		$this->assertEquals('bar', $result->getContent());
85
-	}
83
+        $this->assertTrue($this->folder->nodeExists('file'));
84
+        $this->assertEquals('bar', $result->getContent());
85
+    }
86 86
 
87
-	public function testGetDirectoryListing(): void {
88
-		$this->folder->newFile('file1');
89
-		$this->folder->newFile('file2');
87
+    public function testGetDirectoryListing(): void {
88
+        $this->folder->newFile('file1');
89
+        $this->folder->newFile('file2');
90 90
 
91
-		$result = $this->simpleFolder->getDirectoryListing();
92
-		$this->assertCount(2, $result);
93
-		$this->assertInstanceOf(ISimpleFile::class, $result[0]);
94
-		$this->assertInstanceOf(ISimpleFile::class, $result[1]);
95
-	}
91
+        $result = $this->simpleFolder->getDirectoryListing();
92
+        $this->assertCount(2, $result);
93
+        $this->assertInstanceOf(ISimpleFile::class, $result[0]);
94
+        $this->assertInstanceOf(ISimpleFile::class, $result[1]);
95
+    }
96 96
 
97
-	public function testGetFolder(): void {
98
-		$this->folder->newFolder('exists');
97
+    public function testGetFolder(): void {
98
+        $this->folder->newFolder('exists');
99 99
 
100
-		$result = $this->simpleFolder->getFolder('exists');
101
-		$this->assertInstanceOf(ISimpleFolder::class, $result);
100
+        $result = $this->simpleFolder->getFolder('exists');
101
+        $this->assertInstanceOf(ISimpleFolder::class, $result);
102 102
 
103
-		$this->expectException(NotFoundException::class);
104
-		$this->simpleFolder->getFolder('not-exists');
105
-	}
103
+        $this->expectException(NotFoundException::class);
104
+        $this->simpleFolder->getFolder('not-exists');
105
+    }
106 106
 
107
-	public function testNewFolder(): void {
108
-		$result = $this->simpleFolder->newFolder('folder');
109
-		$this->assertInstanceOf(ISimpleFolder::class, $result);
110
-		$result->newFile('file');
107
+    public function testNewFolder(): void {
108
+        $result = $this->simpleFolder->newFolder('folder');
109
+        $this->assertInstanceOf(ISimpleFolder::class, $result);
110
+        $result->newFile('file');
111 111
 
112
-		$this->assertTrue($this->folder->nodeExists('folder'));
113
-	}
112
+        $this->assertTrue($this->folder->nodeExists('folder'));
113
+    }
114 114
 }
Please login to merge, or discard this patch.
tests/lib/Files/SimpleFS/InMemoryFileTest.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -19,113 +19,113 @@
 block discarded – undo
19 19
  * @package Test\File\SimpleFS
20 20
  */
21 21
 class InMemoryFileTest extends TestCase {
22
-	/**
23
-	 * Holds a pdf file with know attributes for tests.
24
-	 *
25
-	 * @var InMemoryFile
26
-	 */
27
-	private $testPdf;
28
-
29
-	/**
30
-	 * Sets the test file from "./resources/test.pdf".
31
-	 *
32
-	 * @before
33
-	 * @return void
34
-	 */
35
-	public function setupTestPdf() {
36
-		$fileContents = file_get_contents(
37
-			__DIR__ . '/../../../data/test.pdf'
38
-		);
39
-		$this->testPdf = new InMemoryFile('test.pdf', $fileContents);
40
-	}
41
-
42
-	/**
43
-	 * Asserts that putContent replaces the file contents.
44
-	 *
45
-	 * @return void
46
-	 */
47
-	public function testPutContent(): void {
48
-		$this->testPdf->putContent('test');
49
-		self::assertEquals('test', $this->testPdf->getContent());
50
-	}
51
-
52
-	/**
53
-	 * Asserts that delete() doesn't rise an exception.
54
-	 *
55
-	 * @return void
56
-	 */
57
-	public function testDelete(): void {
58
-		$this->testPdf->delete();
59
-		// assert true, otherwise phpunit complains about not doing any assert
60
-		self::assertTrue(true);
61
-	}
62
-
63
-	/**
64
-	 * Asserts that getName returns the name passed on file creation.
65
-	 *
66
-	 * @return void
67
-	 */
68
-	public function testGetName(): void {
69
-		self::assertEquals('test.pdf', $this->testPdf->getName());
70
-	}
71
-
72
-	/**
73
-	 * Asserts that the file size is the size of the test file.
74
-	 *
75
-	 * @return void
76
-	 */
77
-	public function testGetSize(): void {
78
-		self::assertEquals(7083, $this->testPdf->getSize());
79
-	}
80
-
81
-	/**
82
-	 * Asserts the file contents are the same than the original file contents.
83
-	 *
84
-	 * @return void
85
-	 */
86
-	public function testGetContent(): void {
87
-		self::assertEquals(
88
-			file_get_contents(__DIR__ . '/../../../data/test.pdf'),
89
-			$this->testPdf->getContent()
90
-		);
91
-	}
92
-
93
-	/**
94
-	 * Asserts the test file modification time is an integer.
95
-	 *
96
-	 * @return void
97
-	 */
98
-	public function testGetMTime(): void {
99
-		self::assertTrue(is_int($this->testPdf->getMTime()));
100
-	}
101
-
102
-	/**
103
-	 * Asserts the test file mime type is "application/json".
104
-	 *
105
-	 * @return void
106
-	 */
107
-	public function testGetMimeType(): void {
108
-		self::assertEquals('application/pdf', $this->testPdf->getMimeType());
109
-	}
110
-
111
-
112
-	/**
113
-	 * Asserts that read() raises an NotPermittedException.
114
-	 *
115
-	 * @return void
116
-	 */
117
-	public function testRead(): void {
118
-		self::expectException(NotPermittedException::class);
119
-		$this->testPdf->read();
120
-	}
121
-
122
-	/**
123
-	 * Asserts that write() raises an NotPermittedException.
124
-	 *
125
-	 * @return void
126
-	 */
127
-	public function testWrite(): void {
128
-		self::expectException(NotPermittedException::class);
129
-		$this->testPdf->write();
130
-	}
22
+    /**
23
+     * Holds a pdf file with know attributes for tests.
24
+     *
25
+     * @var InMemoryFile
26
+     */
27
+    private $testPdf;
28
+
29
+    /**
30
+     * Sets the test file from "./resources/test.pdf".
31
+     *
32
+     * @before
33
+     * @return void
34
+     */
35
+    public function setupTestPdf() {
36
+        $fileContents = file_get_contents(
37
+            __DIR__ . '/../../../data/test.pdf'
38
+        );
39
+        $this->testPdf = new InMemoryFile('test.pdf', $fileContents);
40
+    }
41
+
42
+    /**
43
+     * Asserts that putContent replaces the file contents.
44
+     *
45
+     * @return void
46
+     */
47
+    public function testPutContent(): void {
48
+        $this->testPdf->putContent('test');
49
+        self::assertEquals('test', $this->testPdf->getContent());
50
+    }
51
+
52
+    /**
53
+     * Asserts that delete() doesn't rise an exception.
54
+     *
55
+     * @return void
56
+     */
57
+    public function testDelete(): void {
58
+        $this->testPdf->delete();
59
+        // assert true, otherwise phpunit complains about not doing any assert
60
+        self::assertTrue(true);
61
+    }
62
+
63
+    /**
64
+     * Asserts that getName returns the name passed on file creation.
65
+     *
66
+     * @return void
67
+     */
68
+    public function testGetName(): void {
69
+        self::assertEquals('test.pdf', $this->testPdf->getName());
70
+    }
71
+
72
+    /**
73
+     * Asserts that the file size is the size of the test file.
74
+     *
75
+     * @return void
76
+     */
77
+    public function testGetSize(): void {
78
+        self::assertEquals(7083, $this->testPdf->getSize());
79
+    }
80
+
81
+    /**
82
+     * Asserts the file contents are the same than the original file contents.
83
+     *
84
+     * @return void
85
+     */
86
+    public function testGetContent(): void {
87
+        self::assertEquals(
88
+            file_get_contents(__DIR__ . '/../../../data/test.pdf'),
89
+            $this->testPdf->getContent()
90
+        );
91
+    }
92
+
93
+    /**
94
+     * Asserts the test file modification time is an integer.
95
+     *
96
+     * @return void
97
+     */
98
+    public function testGetMTime(): void {
99
+        self::assertTrue(is_int($this->testPdf->getMTime()));
100
+    }
101
+
102
+    /**
103
+     * Asserts the test file mime type is "application/json".
104
+     *
105
+     * @return void
106
+     */
107
+    public function testGetMimeType(): void {
108
+        self::assertEquals('application/pdf', $this->testPdf->getMimeType());
109
+    }
110
+
111
+
112
+    /**
113
+     * Asserts that read() raises an NotPermittedException.
114
+     *
115
+     * @return void
116
+     */
117
+    public function testRead(): void {
118
+        self::expectException(NotPermittedException::class);
119
+        $this->testPdf->read();
120
+    }
121
+
122
+    /**
123
+     * Asserts that write() raises an NotPermittedException.
124
+     *
125
+     * @return void
126
+     */
127
+    public function testWrite(): void {
128
+        self::expectException(NotPermittedException::class);
129
+        $this->testPdf->write();
130
+    }
131 131
 }
Please login to merge, or discard this patch.
tests/lib/Files/SimpleFS/SimpleFileTest.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -12,114 +12,114 @@
 block discarded – undo
12 12
 use OCP\Files\NotFoundException;
13 13
 
14 14
 class SimpleFileTest extends \Test\TestCase {
15
-	/** @var File|\PHPUnit\Framework\MockObject\MockObject */
16
-	private $file;
15
+    /** @var File|\PHPUnit\Framework\MockObject\MockObject */
16
+    private $file;
17 17
 
18
-	/** @var SimpleFile */
19
-	private $simpleFile;
18
+    /** @var SimpleFile */
19
+    private $simpleFile;
20 20
 
21
-	protected function setUp(): void {
22
-		parent::setUp();
21
+    protected function setUp(): void {
22
+        parent::setUp();
23 23
 
24
-		$this->file = $this->createMock(File::class);
25
-		$this->simpleFile = new SimpleFile($this->file);
26
-	}
24
+        $this->file = $this->createMock(File::class);
25
+        $this->simpleFile = new SimpleFile($this->file);
26
+    }
27 27
 
28
-	public function testGetName(): void {
29
-		$this->file->expects($this->once())
30
-			->method('getName')
31
-			->willReturn('myname');
28
+    public function testGetName(): void {
29
+        $this->file->expects($this->once())
30
+            ->method('getName')
31
+            ->willReturn('myname');
32 32
 
33
-		$this->assertEquals('myname', $this->simpleFile->getName());
34
-	}
33
+        $this->assertEquals('myname', $this->simpleFile->getName());
34
+    }
35 35
 
36
-	public function testGetSize(): void {
37
-		$this->file->expects($this->once())
38
-			->method('getSize')
39
-			->willReturn(42);
36
+    public function testGetSize(): void {
37
+        $this->file->expects($this->once())
38
+            ->method('getSize')
39
+            ->willReturn(42);
40 40
 
41
-		$this->assertEquals(42, $this->simpleFile->getSize());
42
-	}
41
+        $this->assertEquals(42, $this->simpleFile->getSize());
42
+    }
43 43
 
44
-	public function testGetETag(): void {
45
-		$this->file->expects($this->once())
46
-			->method('getETag')
47
-			->willReturn('etag');
44
+    public function testGetETag(): void {
45
+        $this->file->expects($this->once())
46
+            ->method('getETag')
47
+            ->willReturn('etag');
48 48
 
49
-		$this->assertEquals('etag', $this->simpleFile->getETag());
50
-	}
49
+        $this->assertEquals('etag', $this->simpleFile->getETag());
50
+    }
51 51
 
52
-	public function testGetMTime(): void {
53
-		$this->file->expects($this->once())
54
-			->method('getMTime')
55
-			->willReturn(101);
52
+    public function testGetMTime(): void {
53
+        $this->file->expects($this->once())
54
+            ->method('getMTime')
55
+            ->willReturn(101);
56 56
 
57
-		$this->assertEquals(101, $this->simpleFile->getMTime());
58
-	}
57
+        $this->assertEquals(101, $this->simpleFile->getMTime());
58
+    }
59 59
 
60
-	public function testGetContent(): void {
61
-		$this->file->expects($this->once())
62
-			->method('getContent')
63
-			->willReturn('foo');
60
+    public function testGetContent(): void {
61
+        $this->file->expects($this->once())
62
+            ->method('getContent')
63
+            ->willReturn('foo');
64 64
 
65
-		$this->assertEquals('foo', $this->simpleFile->getContent());
66
-	}
65
+        $this->assertEquals('foo', $this->simpleFile->getContent());
66
+    }
67 67
 
68
-	public function testPutContent(): void {
69
-		$this->file->expects($this->once())
70
-			->method('putContent')
71
-			->with($this->equalTo('bar'));
68
+    public function testPutContent(): void {
69
+        $this->file->expects($this->once())
70
+            ->method('putContent')
71
+            ->with($this->equalTo('bar'));
72 72
 
73
-		$this->simpleFile->putContent('bar');
74
-	}
73
+        $this->simpleFile->putContent('bar');
74
+    }
75 75
 
76
-	public function testDelete(): void {
77
-		$this->file->expects($this->once())
78
-			->method('delete');
76
+    public function testDelete(): void {
77
+        $this->file->expects($this->once())
78
+            ->method('delete');
79 79
 
80
-		$this->simpleFile->delete();
81
-	}
80
+        $this->simpleFile->delete();
81
+    }
82 82
 
83
-	public function testGetMimeType(): void {
84
-		$this->file->expects($this->once())
85
-			->method('getMimeType')
86
-			->willReturn('app/awesome');
83
+    public function testGetMimeType(): void {
84
+        $this->file->expects($this->once())
85
+            ->method('getMimeType')
86
+            ->willReturn('app/awesome');
87 87
 
88
-		$this->assertEquals('app/awesome', $this->simpleFile->getMimeType());
89
-	}
88
+        $this->assertEquals('app/awesome', $this->simpleFile->getMimeType());
89
+    }
90 90
 
91
-	public function testGetContentInvalidAppData(): void {
92
-		$this->file->method('getContent')
93
-			->willReturn(false);
94
-		$this->file->method('stat')->willReturn(false);
91
+    public function testGetContentInvalidAppData(): void {
92
+        $this->file->method('getContent')
93
+            ->willReturn(false);
94
+        $this->file->method('stat')->willReturn(false);
95 95
 
96
-		$parent = $this->createMock(Folder::class);
97
-		$parent->method('stat')->willReturn(false);
96
+        $parent = $this->createMock(Folder::class);
97
+        $parent->method('stat')->willReturn(false);
98 98
 
99
-		$root = $this->createMock(Folder::class);
100
-		$root->method('stat')->willReturn([]);
99
+        $root = $this->createMock(Folder::class);
100
+        $root->method('stat')->willReturn([]);
101 101
 
102
-		$this->file->method('getParent')->willReturn($parent);
103
-		$parent->method('getParent')->willReturn($root);
102
+        $this->file->method('getParent')->willReturn($parent);
103
+        $parent->method('getParent')->willReturn($root);
104 104
 
105
-		$this->expectException(NotFoundException::class);
105
+        $this->expectException(NotFoundException::class);
106 106
 
107
-		$this->simpleFile->getContent();
108
-	}
107
+        $this->simpleFile->getContent();
108
+    }
109 109
 
110
-	public function testRead(): void {
111
-		$this->file->expects($this->once())
112
-			->method('fopen')
113
-			->with('r');
110
+    public function testRead(): void {
111
+        $this->file->expects($this->once())
112
+            ->method('fopen')
113
+            ->with('r');
114 114
 
115
-		$this->simpleFile->read();
116
-	}
115
+        $this->simpleFile->read();
116
+    }
117 117
 
118
-	public function testWrite(): void {
119
-		$this->file->expects($this->once())
120
-			->method('fopen')
121
-			->with('w');
118
+    public function testWrite(): void {
119
+        $this->file->expects($this->once())
120
+            ->method('fopen')
121
+            ->with('w');
122 122
 
123
-		$this->simpleFile->write();
124
-	}
123
+        $this->simpleFile->write();
124
+    }
125 125
 }
Please login to merge, or discard this patch.