Skip to content

Commit 3fdeb7f

Browse files
committed
fix Unit test case and add throw exception into method declaration
1 parent f686865 commit 3fdeb7f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/code/Magento/Catalog/Api/CategoryListDeleteBySkuInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ interface CategoryListDeleteBySkuInterface
1616
* Delete by skus list
1717
*
1818
* @param int $categoryId
19-
* @param array $productSkuList
19+
* @param string[] $productSkuList
2020
* @return bool
2121
*
2222
* @throws \Magento\Framework\Exception\CouldNotSaveException
23+
* @throws \Magento\Framework\Exception\NoSuchEntityException
2324
* @throws \Magento\Framework\Exception\InputException
2425
*/
2526
public function deleteBySkus(int $categoryId, array $productSkuList): bool;

app/code/Magento/Catalog/Test/Unit/Model/CategoryLinkRepositoryTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,22 +261,21 @@ public function testDelete(): void
261261
public function testDeleteBySkus(): void
262262
{
263263
$categoryId = 42;
264-
$productSku = 'testSku';
265-
$productId = 55;
266-
$productPositions = [55 => 1];
264+
$productSkus = ['testSku', 'testSku1', 'testSku2', 'testSku3'];
265+
$productPositions = [55 => 1, 56 => 2, 57 => 3, 58 => 4];
267266
$categoryMock = $this->createPartialMock(
268267
Category::class,
269268
['getProductsPosition', 'setPostedProducts', 'save', 'getId']
270269
);
271270
$this->categoryRepositoryMock->expects($this->once())->method('get')->with($categoryId)
272271
->willReturn($categoryMock);
273272
$this->productResourceMock->expects($this->once())->method('getProductsIdsBySkus')
274-
->willReturn(['testSku' => $productId]);
273+
->willReturn(['testSku' => 55, 'testSku1' => 56, 'testSku2' => 57, 'testSku3' => 58]);
275274
$categoryMock->expects($this->once())->method('getProductsPosition')->willReturn($productPositions);
276275
$categoryMock->expects($this->once())->method('setPostedProducts')->with([]);
277276
$categoryMock->expects($this->once())->method('save');
278277

279-
$this->assertTrue($this->model->deleteBySkus($categoryId, [$productSku]));
278+
$this->assertTrue($this->model->deleteBySkus($categoryId, $productSkus));
280279
}
281280

282281
/**

0 commit comments

Comments
 (0)