77
88namespace Magento \Catalog \Api ;
99
10+ use Magento \Catalog \Model \ProductWebsiteLink ;
1011use Magento \Framework \ObjectManagerInterface ;
1112use Magento \Framework \Webapi \Rest \Request ;
1213use 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