File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -193,6 +193,16 @@ public function getMetadata(): array
193
193
return $ this ->metadata ;
194
194
}
195
195
196
+ /**
197
+ * @param array $metadata
198
+ *
199
+ * @return void
200
+ */
201
+ public function withMetadata (array $ metadata )
202
+ {
203
+ $ this ->metadata = $ metadata ;
204
+ }
205
+
196
206
/**
197
207
* Get all elements.
198
208
*
Original file line number Diff line number Diff line change @@ -249,4 +249,22 @@ public function testCreateFromArrayAllValues()
249
249
$ this ->assertEquals (100 , $ aggregation ->getTotalElements ());
250
250
$ this ->assertCount (1 , $ aggregation ->getActiveElements ());
251
251
}
252
+
253
+ /**
254
+ * @return void
255
+ */
256
+ public function testWithMetadata ()
257
+ {
258
+ $ aggregation = Aggregation::createFromArray ([
259
+ 'name ' => 'agg1 ' ,
260
+ 'counters ' => [],
261
+ 'application_type ' => Filter::MUST_ALL ,
262
+ 'active_elements ' => ['1 ' ],
263
+ 'total_elements ' => 100 ,
264
+ 'metadata ' => ['a ' => 1 , 'b ' => 2 ],
265
+ ]);
266
+
267
+ $ aggregation ->withMetadata (['m ' ]);
268
+ $ this ->assertEquals (['m ' ], $ aggregation ->getMetadata ());
269
+ }
252
270
}
You can’t perform that action at this time.
0 commit comments