9
9
use Magento \Catalog \Api \ProductRepositoryInterface ;
10
10
use Magento \Framework \Indexer \IndexerRegistry ;
11
11
use Magento \Indexer \Model \Config ;
12
+ use Magento \Store \Model \WebsiteRepository ;
12
13
use Magento \TestFramework \Helper \Bootstrap ;
13
14
14
15
/**
15
16
* @magentoAppArea adminhtml
16
17
* @magentoDataFixture Magento/Catalog/_files/category.php
18
+ * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
17
19
*/
18
20
class ProductGeneratorTest extends \PHPUnit \Framework \TestCase
19
21
{
@@ -37,6 +39,11 @@ class ProductGeneratorTest extends \PHPUnit\Framework\TestCase
37
39
*/
38
40
private $ indexersState = [];
39
41
42
+ /**
43
+ * @var WebsiteRepository
44
+ */
45
+ private $ websiteRepository ;
46
+
40
47
/**
41
48
* @return void
42
49
*/
@@ -45,7 +52,7 @@ protected function setUp()
45
52
$ this ->objectManager = Bootstrap::getObjectManager ();
46
53
$ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
47
54
$ this ->productGenerator = $ this ->objectManager ->get (ProductGenerator::class);
48
-
55
+ $ this -> websiteRepository = $ this -> objectManager -> get (WebsiteRepository::class);
49
56
$ indexerRegistry = $ this ->objectManager ->get (IndexerRegistry::class);
50
57
$ indexerListIds = $ this ->objectManager ->get (Config::class)->getIndexers ();
51
58
@@ -79,6 +86,7 @@ public function testProductGeneration()
79
86
$ price = 7.99 ;
80
87
$ url = 'simple-product-url ' ;
81
88
$ categoryId = 333 ;
89
+ $ secondWebsiteId = $ this ->websiteRepository ->get ('test ' )->getId ();
82
90
83
91
$ fixtureMap = [
84
92
'name ' => function () use ($ name ) {
@@ -96,6 +104,9 @@ public function testProductGeneration()
96
104
'category_ids ' => function () use ($ categoryId ) {
97
105
return $ categoryId ;
98
106
},
107
+ 'website_ids ' => function () use ($ secondWebsiteId ) {
108
+ return [1 , $ secondWebsiteId ];
109
+ }
99
110
];
100
111
$ this ->productGenerator ->generate (1 , $ fixtureMap );
101
112
0 commit comments