@@ -308,4 +308,88 @@ private function getServiceInfoAddToCart(string $token): array
308
308
]
309
309
];
310
310
}
311
+
312
+ /**
313
+ * Test for product name in different store view
314
+ *
315
+ * @magentoConfigFixture web/url/use_store 1
316
+ * @magentoApiDataFixture Magento/Catalog/_files/product_simple_multistore.php
317
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
318
+ *
319
+ * @param string $storeCode
320
+ * @param string $expectedProductName
321
+ *
322
+ * @return void
323
+ * @dataProvider dataProviderForMultiStoreView
324
+ * @throws \Magento\Framework\Exception\AuthenticationException
325
+ */
326
+ public function testForProductNameAsPerStoreView (string $ storeCode , string $ expectedProductName ): void
327
+ {
328
+ $ this ->_markTestAsRestOnly ();
329
+
330
+ // Get customer ID token
331
+ /** @var CustomerTokenServiceInterface $customerTokenService */
332
+ $ customerTokenService = $ this ->objectManager ->create (CustomerTokenServiceInterface::class);
333
+ $ token = $ customerTokenService ->createCustomerAccessToken (
334
+
335
+ 'password '
336
+ );
337
+
338
+ // Creating empty cart for registered customer.
339
+ $ serviceInfo = [
340
+ 'rest ' => [
341
+ 'resourcePath ' => '/V1/carts/mine ' ,
342
+ 'httpMethod ' => Request::HTTP_METHOD_POST ,
343
+ 'token ' => $ token
344
+ ]
345
+ ];
346
+ $ quoteId = $ this ->_webApiCall ($ serviceInfo );
347
+ $ this ->assertGreaterThan (0 , $ quoteId );
348
+
349
+ // Add product to cart
350
+ $ requestData = [
351
+ 'cartItem ' => [
352
+ 'quote_id ' => $ quoteId ,
353
+ 'sku ' => 'simple ' ,
354
+ 'qty ' => 1
355
+ ]
356
+ ];
357
+ $ this ->_webApiCall ($ this ->getServiceInfoAddToCart ($ token ), $ requestData );
358
+
359
+ // Fetch Cart info
360
+ $ serviceInfo = [
361
+ 'rest ' => [
362
+ 'resourcePath ' => '/V1/carts/mine ' ,
363
+ 'httpMethod ' => \Magento \Framework \Webapi \Rest \Request::HTTP_METHOD_GET ,
364
+ 'token ' => $ token
365
+ ]
366
+ ];
367
+ /** @var \Magento\Quote\Api\Data\CartInterface $cart */
368
+ $ cart = $ this ->_webApiCall ($ serviceInfo , [], null , $ storeCode );
369
+
370
+ $ actualProductName = '' ;
371
+ $ carts = $ cart ['items ' ];
372
+ foreach ($ carts as $ item ) {
373
+ $ actualProductName = $ item ['name ' ];
374
+ break ;
375
+ }
376
+ $ this ->assertEquals ($ expectedProductName , $ actualProductName );
377
+ }
378
+
379
+ /**
380
+ * @return array
381
+ */
382
+ public function dataProviderForMultiStoreView (): array
383
+ {
384
+ return [
385
+ 'defaultStoreView ' => [
386
+ 'default ' ,
387
+ 'Simple Product One '
388
+ ],
389
+ 'secondStoreView ' => [
390
+ 'fixturestore ' ,
391
+ 'StoreTitle '
392
+ ],
393
+ ];
394
+ }
311
395
}
0 commit comments