Skip to content

Commit 9b0799b

Browse files
committed
MC-39598: Create automated test for: "Assign/Unassign product to websites via API"
1 parent 04fd1ac commit 9b0799b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Magento\Catalog\Api;
99

10+
use Magento\Catalog\Model\ProductWebsiteLink;
1011
use Magento\Framework\ObjectManagerInterface;
1112
use Magento\Framework\Webapi\Rest\Request;
1213
use Magento\Store\Api\WebsiteRepositoryInterface;
@@ -56,7 +57,12 @@ public function testSaveWebsiteLinkWithUnexistingWebsiteId(): void
5657
$pattern = '/(Could\\snot\\sassign\\sproduct)+([\\s\\S]*)(to\\swebsites)+([\\s\\S]*)/';
5758
$unexistingWebsiteId = 8932568989;
5859
$serviceInfo = $this->fillServiceInfo('/V1/products/:sku/websites', Request::HTTP_METHOD_POST, 'Save');
59-
$requestData = ['productWebsiteLink' => ['sku' => 'simple2', 'websiteId' => $unexistingWebsiteId]];
60+
$requestData = [
61+
'productWebsiteLink' => [
62+
ProductWebsiteLink::KEY_SKU => 'simple2',
63+
ProductWebsiteLink::WEBSITE_ID => $unexistingWebsiteId,
64+
],
65+
];
6066
$this->expectException(\Exception::class);
6167
$this->expectExceptionMessageMatches($pattern);
6268
$this->_webApiCall($serviceInfo, $requestData);
@@ -73,7 +79,10 @@ public function testDeleteWebsiteLink(): void
7379
$websiteId = (int)$this->websiteRepository->get('second_website')->getId();
7480
$resourcePath = sprintf('/V1/products/%s/websites/%u', $productSku, $websiteId);
7581
$serviceInfo = $this->fillServiceInfo($resourcePath, Request::HTTP_METHOD_DELETE, 'DeleteById');
76-
$this->_webApiCall($serviceInfo, ['sku' => $productSku, 'websiteId' => $websiteId]);
82+
$this->_webApiCall(
83+
$serviceInfo,
84+
[ProductWebsiteLink::KEY_SKU => $productSku, ProductWebsiteLink::WEBSITE_ID => $websiteId]
85+
);
7786
$product = $this->productRepository->get($productSku, false, null, true);
7887
$this->assertNotContains($websiteId, $product->getWebsiteIds());
7988
}

0 commit comments

Comments
 (0)