|
8 | 8 | namespace NextrasTests\Orm\Integration\Collection; |
9 | 9 |
|
10 | 10 |
|
| 11 | +use Nextras\Orm\Collection\Aggregations\NoneAggregator; |
11 | 12 | use Nextras\Orm\Collection\Functions\AvgAggregateFunction; |
12 | 13 | use Nextras\Orm\Collection\Functions\CompareGreaterThanEqualsFunction; |
13 | 14 | use Nextras\Orm\Collection\Functions\CompareGreaterThanFunction; |
@@ -214,6 +215,31 @@ class CollectionAggregationTest extends DataTestCase |
214 | 215 | ]); |
215 | 216 | Assert::same(3, $books->count()); // book #1, #2, #3 |
216 | 217 | } |
| 218 | + |
| 219 | + |
| 220 | + public function testRowAggregatorImposingLifting(): void |
| 221 | + { |
| 222 | + $books = $this->orm->books->findBy([ |
| 223 | + ICollection::OR, |
| 224 | + ['title' => 'Book 1'], // book #1 |
| 225 | + [ICollection::AND, new NoneAggregator(), 'tags->id' => 2], // book #3, #4 |
| 226 | + ]); |
| 227 | + Assert::same(3, $books->count()); |
| 228 | + |
| 229 | + $books = $this->orm->books->findBy([ |
| 230 | + ICollection::AND, |
| 231 | + ['title' => 'Book 1'], // book #1 |
| 232 | + [ICollection::AND, new NoneAggregator(), 'tags->id' => 2], // book #3, #4 |
| 233 | + ]); |
| 234 | + Assert::same(0, $books->count()); |
| 235 | + |
| 236 | + $books = $this->orm->books->findBy([ |
| 237 | + ICollection::AND, |
| 238 | + ['title' => 'Book 1'], // book #1 |
| 239 | + [ICollection::AND, new NoneAggregator(), 'tags->id' => 3], // book #1, #4 |
| 240 | + ]); |
| 241 | + Assert::same(1, $books->count()); |
| 242 | + } |
217 | 243 | } |
218 | 244 |
|
219 | 245 |
|
|
0 commit comments