@@ -206,7 +206,7 @@ public function testBundleProductWithNotVisibleChildren()
206
206
}
207
207
$ this ->assertBundleBaseFields ($ bundleProduct , $ response ['products ' ]['items ' ][0 ]);
208
208
209
- $ this ->assertBundleProductOptions ($ bundleProduct , $ response ['products ' ]['items ' ][0 ]);
209
+ $ this ->assertBundleProductOptions ($ bundleProduct , $ response ['products ' ]['items ' ][0 ], false );
210
210
$ this ->assertNotEmpty (
211
211
$ response ['products ' ]['items ' ][0 ]['items ' ],
212
212
"Precondition failed: 'items' must not be empty "
@@ -236,8 +236,9 @@ private function assertBundleBaseFields($product, $actualResponse)
236
236
/**
237
237
* @param ProductInterface $product
238
238
* @param array $actualResponse
239
+ * @param bool $isChildVisible
239
240
*/
240
- private function assertBundleProductOptions ($ product , $ actualResponse )
241
+ private function assertBundleProductOptions ($ product , $ actualResponse, $ isChildVisible = true )
241
242
{
242
243
$ this ->assertNotEmpty (
243
244
$ actualResponse ['items ' ],
@@ -273,19 +274,27 @@ private function assertBundleProductOptions($product, $actualResponse)
273
274
'position ' => $ bundleProductLink ->getPosition (),
274
275
'is_default ' => (bool )$ bundleProductLink ->getIsDefault (),
275
276
'price_type ' => self ::KEY_PRICE_TYPE_FIXED ,
276
- 'can_change_quantity ' => $ bundleProductLink ->getCanChangeQuantity (),
277
- 'label ' => $ childProduct ->getName ()
277
+ 'can_change_quantity ' => $ bundleProductLink ->getCanChangeQuantity ()
278
278
]
279
279
);
280
- $ this ->assertResponseFields (
281
- $ actualResponse ['items ' ][0 ]['options ' ][0 ]['product ' ],
282
- [
283
- 'id ' => $ childProduct ->getId (),
284
- 'name ' => $ childProduct ->getName (),
285
- 'type_id ' => $ childProduct ->getTypeId (),
286
- 'sku ' => $ bundleProductLink ->getSku ()
287
- ]
280
+ $ this ->assertEquals (
281
+ $ isChildVisible ? $ childProduct ->getName () : null ,
282
+ $ actualResponse ['items ' ][0 ]['options ' ][0 ]['label ' ]
288
283
);
284
+ if ($ isChildVisible ) {
285
+ $ this ->assertResponseFields (
286
+ $ actualResponse ['items ' ][0 ]['options ' ][0 ]['product ' ],
287
+ [
288
+ 'id ' => $ childProduct ->getId (),
289
+ 'name ' => $ childProduct ->getName (),
290
+ 'type_id ' => $ childProduct ->getTypeId (),
291
+ 'sku ' => $ childProduct ->getSku ()
292
+ ]
293
+ );
294
+ } else {
295
+ $ this ->assertNull ($ actualResponse ['items ' ][0 ]['options ' ][0 ]['product ' ]);
296
+ }
297
+
289
298
}
290
299
291
300
/**
0 commit comments