66
77namespace Magento \CatalogWidget \Block \Product ;
88
9+ use Magento \Bundle \Test \Fixture \Option as BundleOptionFixture ;
10+ use Magento \Bundle \Test \Fixture \Product as BundleProductFixture ;
11+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
912use Magento \Catalog \Model \Indexer \Product \Eav \Processor ;
1013use Magento \Catalog \Model \ResourceModel \Category \Collection as CategoryCollection ;
1114use Magento \Catalog \Model \ResourceModel \Eav \Attribute ;
1215use Magento \Framework \ObjectManagerInterface ;
16+ use Magento \TestFramework \Fixture \DataFixture ;
17+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
18+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
19+ use Magento \TestFramework \Fixture \DbIsolation ;
1320use Magento \TestFramework \Helper \Bootstrap ;
1421use PHPUnit \Framework \TestCase ;
1522
@@ -34,11 +41,17 @@ class ProductListTest extends TestCase
3441 */
3542 protected $ objectManager ;
3643
44+ /**
45+ * @var DataFixtureStorage
46+ */
47+ private $ fixtures ;
48+
3749 protected function setUp (): void
3850 {
3951 $ this ->objectManager = Bootstrap::getObjectManager ();
4052 $ this ->block = $ this ->objectManager ->create (ProductsList::class);
4153 $ this ->categoryCollection = $ this ->objectManager ->create (CategoryCollection::class);
54+ $ this ->fixtures = Bootstrap::getObjectManager ()->get (DataFixtureStorageManager::class)->getStorage ();
4255 }
4356
4457 /**
@@ -257,6 +270,29 @@ public function testCreateAnchorCollection()
257270 );
258271 }
259272
273+ #[
274+ DbIsolation(false ),
275+ DataFixture(ProductFixture::class, ['price ' => 10 ], 'p1 ' ),
276+ DataFixture(ProductFixture::class, ['price ' => 20 ], 'p2 ' ),
277+ DataFixture(BundleOptionFixture::class, ['product_links ' => ['$p1$ ' , '$p2$ ' ]], 'opt1 ' ),
278+ DataFixture(BundleProductFixture::class, ['_options ' => ['$opt1$ ' ]], 'bundle1 ' ),
279+ ]
280+ public function testBundleProductList ()
281+ {
282+ $ postParams = $ this ->block ->getAddToCartPostParams ($ this ->fixtures ->get ('bundle1 ' ));
283+
284+ $ this ->assertArrayHasKey (
285+ 'product ' ,
286+ $ postParams ['data ' ],
287+ 'Bundle product options is missing from POST params. '
288+ );
289+ $ this ->assertArrayHasKey (
290+ 'options ' ,
291+ $ postParams ['data ' ],
292+ 'Bundle product options is missing from POST params. '
293+ );
294+ }
295+
260296 /**
261297 * Test that price rule condition works correctly
262298 *
0 commit comments