9 use \Magento\Bundle\Api\Data\LinkInterface;
24 public function testPriceForFixedBundle(array $strategyModifiers, array $expectedResults)
26 if (empty($strategyModifiers)) {
27 $this->markTestSkipped(
'Unskip after fixing https://github.com/magento-engcom/msi/issues/1398');
30 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
37 $expectedResults[
'minimalPrice'],
38 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
39 'Failed to check minimal price on product' 42 $expectedResults[
'maximalPrice'],
43 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
44 'Failed to check maximal price on product' 47 $priceInfoFromIndexer = $this->productCollectionFactory->create()
48 ->addFieldToFilter(
'sku',
'bundle_product')
53 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
54 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
66 #1 Testing price for fixed bundle product 67 with special price and without any sub items and options 69 'strategy' => $this->getBundleConfiguration1(),
70 'expectedResults' => [
80 #2 Testing price for fixed bundle product 81 with special price, fixed sub items and fixed options 83 'strategy' => $this->getBundleConfiguration2(
85 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
87 'expectedResults' => [
89 'minimalPrice' => 165,
92 'maximalPrice' => 165,
97 #3 Testing price for fixed bundle product 98 with special price, percent sub items and percent options 100 'strategy' => $this->getBundleConfiguration2(
102 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
104 'expectedResults' => [
106 'minimalPrice' => 121,
109 'maximalPrice' => 121,
114 #4 Testing price for fixed bundle product 115 with special price, fixed sub items and percent options 117 'strategy' => $this->getBundleConfiguration2(
119 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
121 'expectedResults' => [
123 'minimalPrice' => 120,
126 'maximalPrice' => 120,
131 #5 Testing price for fixed bundle product 132 with special price, percent sub items and fixed options 134 'strategy' => $this->getBundleConfiguration2(
136 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
138 'expectedResults' => [
140 'minimalPrice' => 166,
143 'maximalPrice' => 166,
148 #6 Testing price for fixed bundle product 149 with special price, fixed sub items and fixed options 151 'strategy' => $this->getBundleConfiguration3(
153 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
155 'expectedResults' => [
157 'minimalPrice' => 155,
160 'maximalPrice' => 175,
165 #7 Testing price for fixed bundle product 166 with special price, percent sub items and percent options 168 'strategy' => $this->getBundleConfiguration3(
170 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
172 'expectedResults' => [
174 'minimalPrice' => 110,
177 'maximalPrice' => 132,
182 #8 Testing price for fixed bundle product 183 with special price, fixed sub items and percent options 185 'strategy' => $this->getBundleConfiguration3(
187 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
189 'expectedResults' => [
191 'minimalPrice' => 110,
194 'maximalPrice' => 130,
199 #9 Testing price for fixed bundle product 200 with special price, percent sub items and fixed options 202 'strategy' => $this->getBundleConfiguration3(
204 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
206 'expectedResults' => [
208 'minimalPrice' => 155,
211 'maximalPrice' => 177,
216 #10 Testing price for fixed bundle product 217 with special price, fixed sub items and fixed options 219 'strategy' => $this->getBundleConfiguration4(
221 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
223 'expectedResults' => [
225 'minimalPrice' => 170,
228 'maximalPrice' => 190,
233 #11 Testing price for fixed bundle product 234 with special price, percent sub items and percent options 236 'strategy' => $this->getBundleConfiguration4(
238 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
240 'expectedResults' => [
242 'minimalPrice' => 126.5,
245 'maximalPrice' => 148.5,
250 #12 Testing price for fixed bundle product 251 with special price, fixed sub items and percent options 253 'strategy' => $this->getBundleConfiguration4(
255 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
257 'expectedResults' => [
259 'minimalPrice' => 125,
262 'maximalPrice' => 145,
267 #13 Testing price for fixed bundle product 268 with special price, percent sub items and fixed options 270 'strategy' => $this->getBundleConfiguration4(
272 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
274 'expectedResults' => [
276 'minimalPrice' => 171.5,
279 'maximalPrice' => 193.5,
284 #14 Testing price for fixed bundle product 285 with special price, fixed sub items and fixed options 287 'strategy' => $this->getBundleConfiguration5(
289 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
291 'expectedResults' => [
293 'minimalPrice' => 175,
296 'maximalPrice' => 197.5,
301 #15 Testing price for fixed bundle product 302 with special price, percent sub items and percent options 304 'strategy' => $this->getBundleConfiguration5(
306 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
308 'expectedResults' => [
310 'minimalPrice' => 132,
313 'maximalPrice' => 156.75,
318 #16 Testing price for fixed bundle product 319 with special price, fixed sub items and percent options 321 'strategy' => $this->getBundleConfiguration5(
323 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
325 'expectedResults' => [
327 'minimalPrice' => 130,
330 'maximalPrice' => 152.5,
335 #17 Testing price for fixed bundle product 336 with special price, percent sub items and fixed options 338 'strategy' => $this->getBundleConfiguration5(
340 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
342 'expectedResults' => [
344 'minimalPrice' => 177,
347 'maximalPrice' => 201.75,
352 #18 Testing price for fixed bundle product 353 with special price, fixed sub items and fixed options 355 'strategy' => $this->getBundleConfiguration6(
357 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
359 'expectedResults' => [
361 'minimalPrice' => 175,
364 'maximalPrice' => 177.5,
369 #19 Testing price for fixed bundle product 370 with special price, percent sub items and percent options 372 'strategy' => $this->getBundleConfiguration6(
374 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
376 'expectedResults' => [
378 'minimalPrice' => 132,
381 'maximalPrice' => 134.75,
386 #20 Testing price for fixed bundle product 387 with special price, fixed sub items and percent options 389 'strategy' => $this->getBundleConfiguration6(
391 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
393 'expectedResults' => [
395 'minimalPrice' => 130,
398 'maximalPrice' => 132.5,
403 #21 Testing price for fixed bundle product 404 with special price, percent sub items and fixed options 406 'strategy' => $this->getBundleConfiguration6(
408 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
410 'expectedResults' => [
412 'minimalPrice' => 177,
415 'maximalPrice' => 179.75,
420 #22 Testing price for fixed bundle product 421 with special price, fixed sub items and fixed options 423 'strategy' => $this->getBundleConfiguration7(
425 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
427 'expectedResults' => [
429 'minimalPrice' => 185,
432 'maximalPrice' => 202.5,
437 #23 Testing price for fixed bundle product 438 with special price, percent sub items and percent options 440 'strategy' => $this->getBundleConfiguration7(
442 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
444 'expectedResults' => [
446 'minimalPrice' => 143,
449 'maximalPrice' => 162.25,
454 #24 Testing price for fixed bundle product 455 with special price, fixed sub items and percent options 457 'strategy' => $this->getBundleConfiguration7(
459 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
461 'expectedResults' => [
463 'minimalPrice' => 140,
466 'maximalPrice' => 157.5,
471 #25 Testing price for fixed bundle product 472 with special price, percent sub items and fixed options 474 'strategy' => $this->getBundleConfiguration7(
476 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
478 'expectedResults' => [
480 'minimalPrice' => 188,
483 'maximalPrice' => 207.25,
493 private function getBundleConfiguration1()
504 private function getBundleConfiguration2(
505 $selectionsPriceType,
506 $customOptionsPriceType
512 'type' =>
'checkbox',
518 'price_type' => $selectionsPriceType
524 $customOptionsData = [
526 'price_type' => $customOptionsPriceType,
527 'title' =>
'Test Field',
537 'modifierName' =>
'addSimpleProduct',
541 'modifierName' =>
'addCustomOption',
542 'data' => [$customOptionsData]
553 private function getBundleConfiguration3(
554 $selectionsPriceType,
555 $customOptionsPriceType
560 'type' =>
'checkbox',
567 'price_type' => $selectionsPriceType
573 $customOptionsData = [
575 'price_type' => $customOptionsPriceType,
576 'title' =>
'Test Field',
586 'modifierName' =>
'addSimpleProduct',
590 'modifierName' =>
'addCustomOption',
591 'data' => [$customOptionsData]
602 private function getBundleConfiguration4(
603 $selectionsPriceType,
604 $customOptionsPriceType
610 'type' =>
'checkbox',
616 'price_type' => $selectionsPriceType
622 'price_type' => $selectionsPriceType
628 $customOptionsData = [
630 'price_type' => $customOptionsPriceType,
631 'title' =>
'Test Field',
641 'modifierName' =>
'addSimpleProduct',
645 'modifierName' =>
'addCustomOption',
646 'data' => [$customOptionsData]
657 private function getBundleConfiguration5(
658 $selectionsPriceType,
659 $customOptionsPriceType
671 'price_type' => $selectionsPriceType
677 'price_type' => $selectionsPriceType
683 $customOptionsData = [
685 'price_type' => $customOptionsPriceType,
686 'title' =>
'Test Field',
696 'modifierName' =>
'addSimpleProduct',
700 'modifierName' =>
'addCustomOption',
701 'data' => [$customOptionsData]
712 private function getBundleConfiguration6(
713 $selectionsPriceType,
714 $customOptionsPriceType
726 'price_type' => $selectionsPriceType
732 'price_type' => $selectionsPriceType
738 $customOptionsData = [
740 'price_type' => $customOptionsPriceType,
741 'title' =>
'Test Field',
751 'modifierName' =>
'addSimpleProduct',
755 'modifierName' =>
'addCustomOption',
756 'data' => [$customOptionsData]
767 private function getBundleConfiguration7(
768 $selectionsPriceType,
769 $customOptionsPriceType
781 'price_type' => $selectionsPriceType
787 'price_type' => $selectionsPriceType
794 'type' =>
'checkbox',
800 'price_type' => $selectionsPriceType
806 'price_type' => $selectionsPriceType
812 $customOptionsData = [
814 'price_type' => $customOptionsPriceType,
815 'title' =>
'Test Field',
825 'modifierName' =>
'addSimpleProduct',
829 'modifierName' =>
'addCustomOption',
830 'data' => [$customOptionsData]
prepareFixture($strategyModifiers, $productSku)