99use Magento \Catalog \Api \ProductRepositoryInterface ;
1010use Magento \Framework \Indexer \IndexerRegistry ;
1111use Magento \Indexer \Model \Config ;
12+ use Magento \Store \Model \WebsiteRepository ;
1213use Magento \TestFramework \Helper \Bootstrap ;
1314
1415/**
1516 * @magentoAppArea adminhtml
1617 * @magentoDataFixture Magento/Catalog/_files/category.php
18+ * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
1719 */
1820class ProductGeneratorTest extends \PHPUnit \Framework \TestCase
1921{
@@ -37,6 +39,11 @@ class ProductGeneratorTest extends \PHPUnit\Framework\TestCase
3739 */
3840 private $ indexersState = [];
3941
42+ /**
43+ * @var WebsiteRepository
44+ */
45+ private $ websiteRepository ;
46+
4047 /**
4148 * @return void
4249 */
@@ -45,7 +52,7 @@ protected function setUp()
4552 $ this ->objectManager = Bootstrap::getObjectManager ();
4653 $ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
4754 $ this ->productGenerator = $ this ->objectManager ->get (ProductGenerator::class);
48-
55+ $ this -> websiteRepository = $ this -> objectManager -> get (WebsiteRepository::class);
4956 $ indexerRegistry = $ this ->objectManager ->get (IndexerRegistry::class);
5057 $ indexerListIds = $ this ->objectManager ->get (Config::class)->getIndexers ();
5158
@@ -79,6 +86,7 @@ public function testProductGeneration()
7986 $ price = 7.99 ;
8087 $ url = 'simple-product-url ' ;
8188 $ categoryId = 333 ;
89+ $ secondWebsiteId = $ this ->websiteRepository ->get ('test ' )->getId ();
8290
8391 $ fixtureMap = [
8492 'name ' => function () use ($ name ) {
@@ -96,6 +104,9 @@ public function testProductGeneration()
96104 'category_ids ' => function () use ($ categoryId ) {
97105 return $ categoryId ;
98106 },
107+ 'website_ids ' => function () use ($ secondWebsiteId ) {
108+ return [1 , $ secondWebsiteId ];
109+ }
99110 ];
100111 $ this ->productGenerator ->generate (1 , $ fixtureMap );
101112
0 commit comments