Skip to content

Commit 7135be5

Browse files
Github issue 34380: Automated test method for controller "UpdateItemQty"
1 parent d524c1c commit 7135be5

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

app/code/Magento/Checkout/Test/Unit/Controller/Sidebar/UpdateItemQtyTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,47 @@ public function testExecuteWithException(): void
244244

245245
$this->assertEquals('json represented', $this->updateItemQty->execute());
246246
}
247+
248+
/**
249+
* @return void
250+
*/
251+
public function testExecuteWithWrongRequestParams(): void
252+
{
253+
$this->requestMock
254+
->method('getParam')
255+
->withConsecutive(['item_id'], ['item_qty'])
256+
->willReturnOnConsecutiveCalls(0, 'error');
257+
258+
$this->sidebarMock->expects($this->once())
259+
->method('checkQuoteItem')
260+
->with(0)
261+
->willThrowException(new LocalizedException(__('Error!')));
262+
263+
$this->sidebarMock->expects($this->once())
264+
->method('getResponseData')
265+
->with('Error!')
266+
->willReturn(
267+
[
268+
'success' => false,
269+
'error_message' => 'Error!'
270+
]
271+
);
272+
273+
$this->jsonHelperMock->expects($this->once())
274+
->method('jsonEncode')
275+
->with(
276+
[
277+
'success' => false,
278+
'error_message' => 'Error!'
279+
]
280+
)
281+
->willReturn('json encoded');
282+
283+
$this->responseMock->expects($this->once())
284+
->method('representJson')
285+
->with('json encoded')
286+
->willReturn('json represented');
287+
288+
$this->assertEquals('json represented', $this->updateItemQty->execute());
289+
}
247290
}

0 commit comments

Comments
 (0)