@@ -46,32 +46,19 @@ protected function setUp(): void
4646 $ this ->websiteRepository = $ this ->objectManager ->get (WebsiteRepositoryInterface::class);
4747 }
4848
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-
6349 /**
6450 * @magentoApiDataFixture Magento/Catalog/_files/second_product_simple.php
6551 *
6652 * @return void
6753 */
6854 public function testSaveWebsiteLinkWithUnexistingWebsiteId (): void
6955 {
56+ $ pattern = '/(Could \\snot \\sassign \\sproduct)+([ \\s \\S]*)(to \\swebsites)+([ \\s \\S]*)/ ' ;
7057 $ unexistingWebsiteId = 8932568989 ;
7158 $ serviceInfo = $ this ->fillServiceInfo ('/V1/products/:sku/websites ' , Request::HTTP_METHOD_POST , 'Save ' );
7259 $ requestData = ['productWebsiteLink ' => ['sku ' => 'simple2 ' , 'websiteId ' => $ unexistingWebsiteId ]];
7360 $ this ->expectException (\Exception::class);
74- $ this ->expectExceptionMessageMatches (' /Could not assign product \\ \"%1 \\ \" to websites \\ \"%2 \\ \"/ ' );
61+ $ this ->expectExceptionMessageMatches ($ pattern );
7562 $ this ->_webApiCall ($ serviceInfo , $ requestData );
7663 }
7764
@@ -85,8 +72,8 @@ public function testDeleteWebsiteLink(): void
8572 $ productSku = 'unique-simple-azaza ' ;
8673 $ websiteId = (int )$ this ->websiteRepository ->get ('second_website ' )->getId ();
8774 $ 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 ] );
9077 $ product = $ this ->productRepository ->get ($ productSku , false , null , true );
9178 $ this ->assertNotContains ($ websiteId , $ product ->getWebsiteIds ());
9279 }
0 commit comments