This repository was archived by the owner on Jun 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 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
193193 return $ this ->metadata ;
194194 }
195195
196+ /**
197+ * @param array $metadata
198+ *
199+ * @return void
200+ */
201+ public function withMetadata (array $ metadata )
202+ {
203+ $ this ->metadata = $ metadata ;
204+ }
205+
196206 /**
197207 * Get all elements.
198208 *
Original file line number Diff line number Diff line change @@ -249,4 +249,22 @@ public function testCreateFromArrayAllValues()
249249 $ this ->assertEquals (100 , $ aggregation ->getTotalElements ());
250250 $ this ->assertCount (1 , $ aggregation ->getActiveElements ());
251251 }
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+ }
252270}
You can’t perform that action at this time.
0 commit comments