@@ -144,10 +144,18 @@ public function assertChecked(string $index): static
144144
145145 /**
146146 * Assert that the given index was created.
147+ *
148+ * @param (callable(?Mapping, ?Settings): bool)|null $callback
147149 */
148- public function assertCreated (string $ index , ?callable $ modifier = null ): static
150+ public function assertCreated (string $ index , ?callable $ callback = null ): static
149151 {
150- $ this ->manager ->assertCreated ($ this ->blueprint ($ index , $ modifier ));
152+ $ this ->manager ->assertCreated (
153+ MigrationPrefix::index ($ index ),
154+ $ callback ? fn (IndexBlueprint $ index ): bool => $ callback (
155+ $ index ->mapping (),
156+ $ index ->settings (),
157+ ) : null ,
158+ );
151159
152160 return $ this ;
153161 }
@@ -164,24 +172,30 @@ public function assertNotCreated(string $index): static
164172
165173 /**
166174 * Assert that the given index mapping was updated.
175+ *
176+ * @param (callable(Mapping): bool)|null $callback
167177 */
168- public function assertMappingPut (string $ index , callable $ modifier ): static
178+ public function assertMappingPut (string $ index , ? callable $ callback = null ): static
169179 {
170- $ modifier ($ mapping = new Mapping );
171-
172- $ this ->manager ->assertMappingPut (MigrationPrefix::index ($ index ), $ mapping );
180+ $ this ->manager ->assertMappingPut (
181+ MigrationPrefix::index ($ index ),
182+ $ callback ,
183+ );
173184
174185 return $ this ;
175186 }
176187
177188 /**
178189 * Assert that the given index settings were updated.
190+ *
191+ * @param (callable(Settings): bool)|null $callback
179192 */
180- public function assertSettingsPut (string $ index , callable $ modifier ): static
193+ public function assertSettingsPut (string $ index , ? callable $ callback = null ): static
181194 {
182- $ modifier ($ settings = new Settings );
183-
184- $ this ->manager ->assertSettingsPut (MigrationPrefix::index ($ index ), $ settings );
195+ $ this ->manager ->assertSettingsPut (
196+ MigrationPrefix::index ($ index ),
197+ $ callback ,
198+ );
185199
186200 return $ this ;
187201 }
@@ -243,21 +257,4 @@ public function assertAliasDeleted(string $index, string $alias): static
243257
244258 return $ this ;
245259 }
246-
247- /**
248- * Create an index blueprint for an assertion.
249- */
250- protected function blueprint (string $ index , ?callable $ modifier = null ): IndexBlueprint
251- {
252- if (isset ($ modifier )) {
253- $ modifier (
254- $ mapping = new Mapping ,
255- $ settings = new Settings ,
256- );
257-
258- return new IndexBlueprint (MigrationPrefix::index ($ index ), $ mapping , $ settings );
259- }
260-
261- return new IndexBlueprint (MigrationPrefix::index ($ index ));
262- }
263260}
0 commit comments