6
6
7
7
namespace Magento \CatalogWidget \Block \Product ;
8
8
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 ;
9
12
use Magento \Catalog \Model \Indexer \Product \Eav \Processor ;
10
13
use Magento \Catalog \Model \ResourceModel \Category \Collection as CategoryCollection ;
11
14
use Magento \Catalog \Model \ResourceModel \Eav \Attribute ;
12
15
use 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 ;
13
20
use Magento \TestFramework \Helper \Bootstrap ;
14
21
use PHPUnit \Framework \TestCase ;
15
22
@@ -34,11 +41,17 @@ class ProductListTest extends TestCase
34
41
*/
35
42
protected $ objectManager ;
36
43
44
+ /**
45
+ * @var DataFixtureStorage
46
+ */
47
+ private $ fixtures ;
48
+
37
49
protected function setUp (): void
38
50
{
39
51
$ this ->objectManager = Bootstrap::getObjectManager ();
40
52
$ this ->block = $ this ->objectManager ->create (ProductsList::class);
41
53
$ this ->categoryCollection = $ this ->objectManager ->create (CategoryCollection::class);
54
+ $ this ->fixtures = Bootstrap::getObjectManager ()->get (DataFixtureStorageManager::class)->getStorage ();
42
55
}
43
56
44
57
/**
@@ -257,6 +270,29 @@ public function testCreateAnchorCollection()
257
270
);
258
271
}
259
272
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
+
260
296
/**
261
297
* Test that price rule condition works correctly
262
298
*
0 commit comments