6 declare(strict_types=1);
10 use \Magento\Bundle\Api\Data\LinkInterface;
28 public function testPriceForFixedBundle(array $strategyModifiers, array $expectedResults)
31 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
38 $expectedResults[
'minimalPrice'],
39 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
40 'Failed to check minimal price on product' 43 $expectedResults[
'maximalPrice'],
44 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
45 'Failed to check maximal price on product' 48 $priceInfoFromIndexer = $this->productCollectionFactory->create()
54 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
55 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
67 public function testPriceForFixedBundleInWebsiteScope(array $strategyModifiers, array $expectedResults)
70 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
77 $expectedResults[
'minimalPrice'],
78 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
79 'Failed to check minimal price on product' 82 $expectedResults[
'maximalPrice'],
83 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
84 'Failed to check maximal price on product' 87 $priceInfoFromIndexer = $this->productCollectionFactory->create()
88 ->addFieldToFilter(
'sku',
'bundle_product')
93 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
94 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
105 '#1 Testing price for fixed bundle product with one simple' => [
106 'strategy' => $this->getProductWithOneSimple(),
107 'expectedResults' => [
109 'minimalPrice' => 120,
111 'maximalPrice' => 120,
115 '#2 Testing price for fixed bundle product with three simples and different qty' => [
116 'strategy' => $this->getProductWithDifferentQty(),
117 'expectedResults' => [
119 'minimalPrice' => 120,
121 'maximalPrice' => 170,
125 '#3 Testing price for fixed bundle product with three simples and different price' => [
126 'strategy' => $this->getProductWithDifferentPrice(),
127 'expectedResults' => [
129 'minimalPrice' => 120,
131 'maximalPrice' => 170,
135 '#4 Testing price for fixed bundle product with three simples' => [
136 'strategy' => $this->getProductWithSamePrice(),
137 'expectedResults' => [
139 'minimalPrice' => 120,
141 'maximalPrice' => 140,
146 #5 Testing price for fixed bundle product 147 with fixed sub items, fixed options and without any discounts 149 'strategy' => $this->getBundleConfiguration3(
151 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
153 'expectedResults' => [
155 'minimalPrice' => 230,
158 'maximalPrice' => 230,
163 #6 Testing price for fixed bundle product 164 with percent sub items, percent options and without any discounts 166 'strategy' => $this->getBundleConfiguration3(
168 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
170 'expectedResults' => [
172 'minimalPrice' => 242,
175 'maximalPrice' => 242,
180 #7 Testing price for fixed bundle product 181 with fixed sub items, percent options and without any discounts 183 'strategy' => $this->getBundleConfiguration3(
185 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
187 'expectedResults' => [
189 'minimalPrice' => 240,
192 'maximalPrice' => 240,
197 #8 Testing price for fixed bundle product 198 with percent sub items, fixed options and without any discounts 200 'strategy' => $this->getBundleConfiguration3(
202 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
204 'expectedResults' => [
206 'minimalPrice' => 232,
209 'maximalPrice' => 232,
219 private function getProductWithOneSimple()
225 'type' =>
'checkbox',
239 'modifierName' =>
'addSimpleProduct',
249 private function getProductWithDifferentQty()
255 'type' =>
'checkbox',
281 'modifierName' =>
'addSimpleProduct',
291 private function getProductWithSamePrice()
297 'type' =>
'checkbox',
323 'modifierName' =>
'addSimpleProduct',
333 private function getProductWithDifferentPrice()
339 'type' =>
'checkbox',
365 'modifierName' =>
'addSimpleProduct',
377 private function getBundleConfiguration3($selectionsPriceType, $customOptionsPriceType)
383 'type' =>
'checkbox',
389 'price_type' => $selectionsPriceType
395 $customOptionsData = [
397 'price_type' => $customOptionsPriceType,
398 'title' =>
'Test Field',
408 'modifierName' =>
'addSimpleProduct',
412 'modifierName' =>
'addCustomOption',
413 'data' => [$customOptionsData]
prepareFixture($strategyModifiers, $productSku)