10 use Magento\Catalog\Test\Page\Product\CatalogProductView;
12 use Magento\Checkout\Test\Page\CheckoutCart;
30 $checkoutCart->open();
31 $sourceProducts =
$cart->getDataFieldConfig(
'items')[
'source'];
32 $products = $sourceProducts->getProducts();
37 $formOptions = $catalogProductView->getBundleViewBlock()->getBundleBlock()->getOptions(
$product);
38 $this->checkOptions(
$product, $formOptions,
$item->getData()[
'options']);
49 return 'Bundle options data on cart configuration page is correct.';
60 private function checkOptions(BundleProduct
$product, array $formOptions, array $cartItemOptions)
68 foreach ($formOptions as $key => $formOption) {
69 $formOptions[$key] = $this->
sortDataByPath($formOption,
'options::title');
73 \PHPUnit\Framework\Assert::assertEmpty($error, $error);
83 private function prepareBundleOptions(BundleProduct
$product, array $cartItemOptions)
85 $bundleSelections =
$product->getBundleSelections();
90 'title' => $bundleOption[
'title'],
91 'type' => $bundleOption[
'frontend_type'],
92 'is_require' => $bundleOption[
'required'],
94 foreach ($bundleOption[
'assigned_products'] as $productKey => $assignedProduct) {
95 $price = $assignedProduct[
'data'][
'selection_price_value']
96 ?? $bundleSelections[
'products'][$optionKey][$productKey]->getPrice();
97 $title = $assignedProduct[
'search_data'][
'name'];
100 'price' => number_format(
$price, 2),
102 foreach ($cartItemOptions as
$option) {
104 $optionData[
'options'][$productKey][
'selected'] =
true;
processAssert(CheckoutCart $checkoutCart, Cart $cart, CatalogProductView $catalogProductView)