|
| 1 | +<?php |
| 2 | +/************************************************************************ |
| 3 | + * |
| 4 | + * Copyright 2023 Adobe |
| 5 | + * All Rights Reserved. |
| 6 | + * |
| 7 | + * NOTICE: All information contained herein is, and remains |
| 8 | + * the property of Adobe and its suppliers, if any. The intellectual |
| 9 | + * and technical concepts contained herein are proprietary to Adobe |
| 10 | + * and its suppliers and are protected by all applicable intellectual |
| 11 | + * property laws, including trade secret and copyright laws. |
| 12 | + * Dissemination of this information or reproduction of this material |
| 13 | + * is strictly forbidden unless prior written permission is obtained |
| 14 | + * from Adobe. |
| 15 | + * ************************************************************************ |
| 16 | + */ |
| 17 | +declare(strict_types=1); |
| 18 | + |
| 19 | +namespace Magento\Bundle\Model\ResourceModel\Selection; |
| 20 | + |
| 21 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
| 22 | +use Magento\TestFramework\Helper\Bootstrap; |
| 23 | + |
| 24 | +class CollectionTest extends \Magento\Bundle\Model\Product\BundlePriceAbstract |
| 25 | +{ |
| 26 | + /** |
| 27 | + * @var CollectionFactory |
| 28 | + */ |
| 29 | + protected $collectionFactory; |
| 30 | + |
| 31 | + protected function setUp(): void |
| 32 | + { |
| 33 | + parent::setUp(); |
| 34 | + |
| 35 | + $this->collectionFactory = Bootstrap::getObjectManager()->create(CollectionFactory::class); |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * @magentoIndexerDimensionMode catalog_product_price website |
| 40 | + * @magentoDataFixture Magento/Bundle/_files/PriceCalculator/dynamic_bundle_product.php |
| 41 | + * @magentoAppIsolation enabled |
| 42 | + * @magentoDbIsolation disabled |
| 43 | + * @group indexer_dimension |
| 44 | + * @dataProvider getTestCases |
| 45 | + */ |
| 46 | + public function testAddPriceDataWithIndexerDimensionMode(array $strategy, int $expectedCount) |
| 47 | + { |
| 48 | + $this->prepareFixture($strategy, 'bundle_product'); |
| 49 | + |
| 50 | + $productRepository = Bootstrap::getObjectManager()->get(ProductRepositoryInterface::class); |
| 51 | + $product = $productRepository->get('bundle_product', false, null, true); |
| 52 | + |
| 53 | + /** @var Collection $collection */ |
| 54 | + $collection = $this->collectionFactory->create(); |
| 55 | + $collection->setStoreId(0); |
| 56 | + $collection->addPriceFilter($product, true); |
| 57 | + $items = $collection->getItems(); |
| 58 | + |
| 59 | + $this->assertCount($expectedCount, $items); |
| 60 | + } |
| 61 | + |
| 62 | + public function getTestCases() |
| 63 | + { |
| 64 | + return [ |
| 65 | + 'Dynamic bundle product with three Simple products' => [ |
| 66 | + 'variation' => $this->getBundleConfiguration(), |
| 67 | + 'expectedCount' => 1 |
| 68 | + ] |
| 69 | + ]; |
| 70 | + } |
| 71 | + |
| 72 | + private function getBundleConfiguration() |
| 73 | + { |
| 74 | + $optionsData = [ |
| 75 | + [ |
| 76 | + 'title' => 'op1', |
| 77 | + 'required' => true, |
| 78 | + 'type' => 'checkbox', |
| 79 | + 'links' => [ |
| 80 | + [ |
| 81 | + 'sku' => 'simple1', |
| 82 | + 'qty' => 3, |
| 83 | + 'price' => 100, |
| 84 | + 'price_type' => 0, |
| 85 | + ], |
| 86 | + [ |
| 87 | + 'sku' => 'simple2', |
| 88 | + 'qty' => 2, |
| 89 | + 'price' => 100, |
| 90 | + 'price_type' => 0, |
| 91 | + ], |
| 92 | + [ |
| 93 | + 'sku' => 'simple3', |
| 94 | + 'qty' => 1, |
| 95 | + 'price' => 100, |
| 96 | + 'price_type' => 0, |
| 97 | + ], |
| 98 | + ] |
| 99 | + ] |
| 100 | + ]; |
| 101 | + |
| 102 | + return [ |
| 103 | + [ |
| 104 | + 'modifierName' => 'addSimpleProduct', |
| 105 | + 'data' => [$optionsData] |
| 106 | + ], |
| 107 | + ]; |
| 108 | + } |
| 109 | +} |
0 commit comments