|
4 | 4 | namespace EventEngineTest\DocumentStore; |
5 | 5 |
|
6 | 6 | use EventEngine\DocumentStore\FieldIndex; |
| 7 | +use EventEngine\DocumentStore\Filter\AnyFilter; |
7 | 8 | use EventEngine\DocumentStore\Filter\EqFilter; |
8 | 9 | use EventEngine\DocumentStore\InMemoryDocumentStore; |
9 | 10 | use EventEngine\DocumentStore\MultiFieldIndex; |
@@ -200,4 +201,50 @@ public function it_does_not_block_adding_a_unique_multi_field_index_if_no_confli |
200 | 201 | $this->store->addCollectionIndex('test', $uniqueIndex); |
201 | 202 | $this->assertTrue($this->store->hasCollectionIndex('test', 'test_idx')); |
202 | 203 | } |
| 204 | + |
| 205 | + /** |
| 206 | + * @test |
| 207 | + */ |
| 208 | + public function it_updates_many() |
| 209 | + { |
| 210 | + $this->store->addCollection('test'); |
| 211 | + |
| 212 | + $this->store->addDoc('test', '1', ['some' => ['prop' => 'foo', 'other' => ['prop' => 'bat']]]); |
| 213 | + $this->store->addDoc('test', '2', ['some' => ['prop' => 'bar', 'other' => ['prop' => 'bat']]]); |
| 214 | + $this->store->addDoc('test', '3', ['some' => ['prop' => 'bar']]); |
| 215 | + |
| 216 | + $this->store->updateMany( |
| 217 | + 'test', |
| 218 | + new EqFilter('some.other.prop', 'bat'), |
| 219 | + ['some' => ['prop' => 'fuzz']] |
| 220 | + ); |
| 221 | + |
| 222 | + $filteredDocs = iterator_to_array($this->store->filterDocs('test', new EqFilter('some.prop', 'fuzz'))); |
| 223 | + |
| 224 | + $this->assertCount(2, $filteredDocs); |
| 225 | + $this->assertEquals('fuzz', $filteredDocs[0]['some']['prop']); |
| 226 | + $this->assertEquals('fuzz', $filteredDocs[1]['some']['prop']); |
| 227 | + } |
| 228 | + |
| 229 | + /** |
| 230 | + * @test |
| 231 | + */ |
| 232 | + public function it_deletes_many() |
| 233 | + { |
| 234 | + $this->store->addCollection('test'); |
| 235 | + |
| 236 | + $this->store->addDoc('test', '1', ['some' => ['prop' => 'foo', 'other' => ['prop' => 'bat']]]); |
| 237 | + $this->store->addDoc('test', '2', ['some' => ['prop' => 'bar', 'other' => ['prop' => 'bat']]]); |
| 238 | + $this->store->addDoc('test', '3', ['some' => ['prop' => 'bar']]); |
| 239 | + |
| 240 | + $this->store->deleteMany( |
| 241 | + 'test', |
| 242 | + new EqFilter('some.other.prop', 'bat') |
| 243 | + ); |
| 244 | + |
| 245 | + $filteredDocs = iterator_to_array($this->store->filterDocs('test', new AnyFilter())); |
| 246 | + |
| 247 | + $this->assertCount(1, $filteredDocs); |
| 248 | + $this->assertEquals(['some' => ['prop' => 'bar']], $filteredDocs[0]); |
| 249 | + } |
203 | 250 | } |
0 commit comments