Skip to content

Commit f4f04df

Browse files
committed
AC-15054: Product Add to Cart issue in Rest API
1 parent c31fdcd commit f4f04df

File tree

1 file changed

+6
-32
lines changed

1 file changed

+6
-32
lines changed

app/code/Magento/Quote/Test/Unit/Plugin/Webapi/ValidateProductWebsiteAssignmentTest.php

Lines changed: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ public function testBeforeSaveSuccessful()
160160
->with($productId, false, $storeId)
161161
->willReturn($this->productMock);
162162

163-
$this->productMock->expects($this->once())
163+
$this->productMock->expects($this->exactly(2))
164164
->method('getWebsiteIds')
165165
->willReturn($productWebsiteIds);
166166

@@ -226,7 +226,7 @@ public function testBeforeSaveProductNotAssignedToWebsite()
226226
->with($productId, false, $storeId)
227227
->willReturn($this->productMock);
228228

229-
$this->productMock->expects($this->once())
229+
$this->productMock->expects($this->exactly(2))
230230
->method('getWebsiteIds')
231231
->willReturn($productWebsiteIds);
232232

@@ -277,15 +277,6 @@ public function testBeforeSaveProductWebsiteIdsNotArray()
277277
->method('getProductId')
278278
->willReturn($productId);
279279

280-
$this->storeManagerMock->expects($this->once())
281-
->method('getStore')
282-
->with($storeId)
283-
->willReturn($this->storeMock);
284-
285-
$this->storeMock->expects($this->once())
286-
->method('getWebsiteId')
287-
->willReturn($websiteId);
288-
289280
$this->productRepositoryMock->expects($this->once())
290281
->method('getById')
291282
->with($productId, false, $storeId)
@@ -295,10 +286,8 @@ public function testBeforeSaveProductWebsiteIdsNotArray()
295286
->method('getWebsiteIds')
296287
->willReturn($productWebsiteIds);
297288

298-
$this->expectException(LocalizedException::class);
299-
$this->expectExceptionMessage('Product that you are trying to add is not available.');
300-
301289
$this->plugin->beforeSave($this->cartItemRepositoryMock, $this->cartItemMock);
290+
$this->assertTrue(true);
302291
}
303292

304293
/**
@@ -390,7 +379,7 @@ public function testBeforeSaveMultipleWebsitesIncludingCurrent()
390379
->with($productId, false, $storeId)
391380
->willReturn($this->productMock);
392381

393-
$this->productMock->expects($this->once())
382+
$this->productMock->expects($this->exactly(2))
394383
->method('getWebsiteIds')
395384
->willReturn($productWebsiteIds);
396385

@@ -442,28 +431,13 @@ public function testBeforeSaveEmptyWebsiteIds()
442431
->method('getProductId')
443432
->willReturn($productId);
444433

445-
$this->storeManagerMock->expects($this->once())
446-
->method('getStore')
447-
->with($storeId)
448-
->willReturn($this->storeMock);
449-
450-
$this->storeMock->expects($this->once())
451-
->method('getWebsiteId')
452-
->willReturn($websiteId);
453-
454434
$this->productRepositoryMock->expects($this->once())
455435
->method('getById')
456436
->with($productId, false, $storeId)
457437
->willReturn($this->productMock);
458438

459-
$this->productMock->expects($this->once())
460-
->method('getWebsiteIds')
461-
->willReturn($productWebsiteIds);
462-
463-
$this->expectException(LocalizedException::class);
464-
$this->expectExceptionMessage('Product that you are trying to add is not available.');
465-
466439
$this->plugin->beforeSave($this->cartItemRepositoryMock, $this->cartItemMock);
440+
$this->assertTrue(true);
467441
}
468442

469443
/**
@@ -521,7 +495,7 @@ public function testBeforeSaveWebsiteIdZero()
521495
->with($productId, false, $storeId)
522496
->willReturn($this->productMock);
523497

524-
$this->productMock->expects($this->once())
498+
$this->productMock->expects($this->exactly(2))
525499
->method('getWebsiteIds')
526500
->willReturn($productWebsiteIds);
527501

0 commit comments

Comments
 (0)