9 use \Magento\Bundle\Api\Data\LinkInterface;
24 public function testPriceForFixedBundle(array $strategyModifiers, array $expectedResults)
27 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
34 $expectedResults[
'minimalPrice'],
35 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
36 'Failed to check minimal price on product' 39 $expectedResults[
'maximalPrice'],
40 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
41 'Failed to check maximal price on product' 44 $priceInfoFromIndexer = $this->productCollectionFactory->create()
50 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
51 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
63 public function testPriceForFixedBundleInWebsiteScope(array $strategyModifiers, array $expectedResults)
66 $bundleProduct = $this->productRepository->get(
'bundle_product',
false,
null,
true);
73 $expectedResults[
'minimalPrice'],
74 $priceInfo->getPrice($priceCode)->getMinimalPrice()->getValue(),
75 'Failed to check minimal price on product' 78 $expectedResults[
'maximalPrice'],
79 $priceInfo->getPrice($priceCode)->getMaximalPrice()->getValue(),
80 'Failed to check maximal price on product' 83 $priceInfoFromIndexer = $this->productCollectionFactory->create()
84 ->addFieldToFilter(
'sku',
'bundle_product')
89 $this->assertEquals($expectedResults[
'minimalPrice'], $priceInfoFromIndexer->getMinimalPrice());
90 $this->assertEquals($expectedResults[
'maximalPrice'], $priceInfoFromIndexer->getMaxPrice());
101 '#1 Testing price for fixed bundle product with one simple' => [
102 'strategy' => $this->getProductWithOneSimple(),
103 'expectedResults' => [
105 'minimalPrice' => 120,
107 'maximalPrice' => 120,
111 '#2 Testing price for fixed bundle product with three simples and different qty' => [
112 'strategy' => $this->getProductWithDifferentQty(),
113 'expectedResults' => [
115 'minimalPrice' => 120,
117 'maximalPrice' => 170,
121 '#3 Testing price for fixed bundle product with three simples and different price' => [
122 'strategy' => $this->getProductWithDifferentPrice(),
123 'expectedResults' => [
125 'minimalPrice' => 120,
127 'maximalPrice' => 170,
131 '#4 Testing price for fixed bundle product with three simples' => [
132 'strategy' => $this->getProductWithSamePrice(),
133 'expectedResults' => [
135 'minimalPrice' => 120,
137 'maximalPrice' => 140,
142 #5 Testing price for fixed bundle product 143 with fixed sub items, fixed options and without any discounts 145 'strategy' => $this->getBundleConfiguration3(
147 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
149 'expectedResults' => [
151 'minimalPrice' => 230,
154 'maximalPrice' => 230,
159 #6 Testing price for fixed bundle product 160 with percent sub items, percent options and without any discounts 162 'strategy' => $this->getBundleConfiguration3(
164 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
166 'expectedResults' => [
168 'minimalPrice' => 242,
171 'maximalPrice' => 242,
176 #7 Testing price for fixed bundle product 177 with fixed sub items, percent options and without any discounts 179 'strategy' => $this->getBundleConfiguration3(
181 self::CUSTOM_OPTION_PRICE_TYPE_PERCENT
183 'expectedResults' => [
185 'minimalPrice' => 240,
188 'maximalPrice' => 240,
193 #8 Testing price for fixed bundle product 194 with percent sub items, fixed options and without any discounts 196 'strategy' => $this->getBundleConfiguration3(
198 self::CUSTOM_OPTION_PRICE_TYPE_FIXED
200 'expectedResults' => [
202 'minimalPrice' => 232,
205 'maximalPrice' => 232,
215 private function getProductWithOneSimple()
221 'type' =>
'checkbox',
235 'modifierName' =>
'addSimpleProduct',
245 private function getProductWithDifferentQty()
251 'type' =>
'checkbox',
277 'modifierName' =>
'addSimpleProduct',
287 private function getProductWithSamePrice()
293 'type' =>
'checkbox',
319 'modifierName' =>
'addSimpleProduct',
329 private function getProductWithDifferentPrice()
335 'type' =>
'checkbox',
361 'modifierName' =>
'addSimpleProduct',
373 private function getBundleConfiguration3($selectionsPriceType, $customOptionsPriceType)
379 'type' =>
'checkbox',
385 'price_type' => $selectionsPriceType
391 $customOptionsData = [
393 'price_type' => $customOptionsPriceType,
394 'title' =>
'Test Field',
404 'modifierName' =>
'addSimpleProduct',
408 'modifierName' =>
'addCustomOption',
409 'data' => [$customOptionsData]
prepareFixture($strategyModifiers, $productSku)