Skip to content

Commit 4c1243c

Browse files
MC-36960: Create automated test for "Create product for "all" store views using API service"
1 parent fceacab commit 4c1243c

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryAllStoreViewsTest.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77

88
namespace Magento\Catalog\Api;
99

10+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
11+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
1012
use Magento\Catalog\Model\Product\Type;
13+
use Magento\Catalog\Model\Product\Visibility;
1114
use Magento\Catalog\Model\ResourceModel\Product\Website\Link;
15+
use Magento\Eav\Model\Config;
1216
use Magento\Framework\ObjectManagerInterface;
1317
use Magento\Framework\Registry;
1418
use Magento\Framework\Webapi\Rest\Request;
@@ -48,14 +52,18 @@ class ProductRepositoryAllStoreViewsTest extends WebapiAbstract
4852
private $storeManager;
4953

5054
/**
51-
* @var string
55+
* @var Link
5256
*/
53-
private $productSku = 'simple';
57+
private $productWebsiteLink;
58+
/**
59+
* @var Config
60+
*/
61+
private $eavConfig;
5462

5563
/**
56-
* @var Link
64+
* @var string
5765
*/
58-
private $productWebsiteLink;
66+
private $productSku = 'simple';
5967

6068
/**
6169
* @inheritdoc
@@ -66,6 +74,7 @@ protected function setUp(): void
6674
$this->objectManager = Bootstrap::getObjectManager();
6775
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
6876
$this->productRepository->cleanCache();
77+
$this->eavConfig = $this->objectManager->get(Config::class);
6978
$this->registry = $this->objectManager->get(Registry::class);
7079
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
7180
$this->productWebsiteLink = $this->objectManager->get(Link::class);
@@ -137,15 +146,18 @@ private function saveProduct($product): array
137146
*/
138147
private function getProductData(): array
139148
{
149+
$setId =(int)$this->eavConfig->getEntityType(ProductAttributeInterface::ENTITY_TYPE_CODE)
150+
->getDefaultAttributeSetId();
151+
140152
return [
141153
'sku' => $this->productSku,
142154
'name' => 'simple',
143155
'type_id' => Type::TYPE_SIMPLE,
144156
'weight' => 1,
145-
'attribute_set_id' => 4,
157+
'attribute_set_id' => $setId,
146158
'price' => 10,
147-
'status' => 1,
148-
'visibility' => 4,
159+
'status' => Status::STATUS_ENABLED,
160+
'visibility' => Visibility::VISIBILITY_BOTH,
149161
'extension_attributes' => [
150162
'stock_item' => ['is_in_stock' => true, 'qty' => 1000]
151163
],

0 commit comments

Comments
 (0)