7
7
8
8
namespace Magento \Catalog \Api ;
9
9
10
+ use Magento \Catalog \Model \ProductWebsiteLink ;
10
11
use Magento \Framework \ObjectManagerInterface ;
11
12
use Magento \Framework \Webapi \Rest \Request ;
12
13
use Magento \Store \Api \WebsiteRepositoryInterface ;
@@ -56,7 +57,12 @@ public function testSaveWebsiteLinkWithUnexistingWebsiteId(): void
56
57
$ pattern = '/(Could \\snot \\sassign \\sproduct)+([ \\s \\S]*)(to \\swebsites)+([ \\s \\S]*)/ ' ;
57
58
$ unexistingWebsiteId = 8932568989 ;
58
59
$ 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
+ ];
60
66
$ this ->expectException (\Exception::class);
61
67
$ this ->expectExceptionMessageMatches ($ pattern );
62
68
$ this ->_webApiCall ($ serviceInfo , $ requestData );
@@ -73,7 +79,10 @@ public function testDeleteWebsiteLink(): void
73
79
$ websiteId = (int )$ this ->websiteRepository ->get ('second_website ' )->getId ();
74
80
$ resourcePath = sprintf ('/V1/products/%s/websites/%u ' , $ productSku , $ websiteId );
75
81
$ 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
+ );
77
86
$ product = $ this ->productRepository ->get ($ productSku , false , null , true );
78
87
$ this ->assertNotContains ($ websiteId , $ product ->getWebsiteIds ());
79
88
}
0 commit comments