@@ -46,32 +46,19 @@ protected function setUp(): void
46
46
$ this ->websiteRepository = $ this ->objectManager ->get (WebsiteRepositoryInterface::class);
47
47
}
48
48
49
- /**
50
- * @magentoApiDataFixture Magento/Catalog/_files/second_product_simple.php
51
- *
52
- * @return void
53
- */
54
- public function testSaveWebsiteLinkWithoutWebsiteId (): void
55
- {
56
- $ serviceInfo = $ this ->fillServiceInfo ('/V1/products/:sku/websites ' , Request::HTTP_METHOD_POST , 'Save ' );
57
- $ requestData = ['productWebsiteLink ' => ['sku ' => 'simple2 ' ]];
58
- $ this ->expectException (\Exception::class);
59
- $ this ->expectErrorMessage ((string )__ ('There are not websites for assign to product ' ));
60
- $ this ->_webApiCall ($ serviceInfo , $ requestData );
61
- }
62
-
63
49
/**
64
50
* @magentoApiDataFixture Magento/Catalog/_files/second_product_simple.php
65
51
*
66
52
* @return void
67
53
*/
68
54
public function testSaveWebsiteLinkWithUnexistingWebsiteId (): void
69
55
{
56
+ $ pattern = '/(Could \\snot \\sassign \\sproduct)+([ \\s \\S]*)(to \\swebsites)+([ \\s \\S]*)/ ' ;
70
57
$ unexistingWebsiteId = 8932568989 ;
71
58
$ serviceInfo = $ this ->fillServiceInfo ('/V1/products/:sku/websites ' , Request::HTTP_METHOD_POST , 'Save ' );
72
59
$ requestData = ['productWebsiteLink ' => ['sku ' => 'simple2 ' , 'websiteId ' => $ unexistingWebsiteId ]];
73
60
$ this ->expectException (\Exception::class);
74
- $ this ->expectExceptionMessageMatches (' /Could not assign product \\ \"%1 \\ \" to websites \\ \"%2 \\ \"/ ' );
61
+ $ this ->expectExceptionMessageMatches ($ pattern );
75
62
$ this ->_webApiCall ($ serviceInfo , $ requestData );
76
63
}
77
64
@@ -85,8 +72,8 @@ public function testDeleteWebsiteLink(): void
85
72
$ productSku = 'unique-simple-azaza ' ;
86
73
$ websiteId = (int )$ this ->websiteRepository ->get ('second_website ' )->getId ();
87
74
$ resourcePath = sprintf ('/V1/products/%s/websites/%u ' , $ productSku , $ websiteId );
88
- $ serviceInfo = $ this ->fillServiceInfo ($ resourcePath , Request::HTTP_METHOD_DELETE , 'Delete ' );
89
- $ this ->_webApiCall ($ serviceInfo );
75
+ $ serviceInfo = $ this ->fillServiceInfo ($ resourcePath , Request::HTTP_METHOD_DELETE , 'DeleteById ' );
76
+ $ this ->_webApiCall ($ serviceInfo, [ ' sku ' => $ productSku , ' websiteId ' => $ websiteId ] );
90
77
$ product = $ this ->productRepository ->get ($ productSku , false , null , true );
91
78
$ this ->assertNotContains ($ websiteId , $ product ->getWebsiteIds ());
92
79
}
0 commit comments