Skip to content

Commit 717cf74

Browse files
committed
AC-2457: Checkout Improvements
* Message changes
1 parent 609c939 commit 717cf74

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

app/code/Magento/Checkout/Controller/Sidebar/UpdateItemQty.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function execute()
7474
$itemQty = (int)$this->getRequest()->getParam('item_qty');
7575

7676
if ($itemQty <= 0) {
77-
return $this->jsonResponse(__('A non-numeric value found'));
77+
return $this->jsonResponse(__('Invalid Item Quantity Requested.'));
7878
}
7979
$itemQty = $this->quantityProcessor->prepareQuantity($itemQty);
8080

@@ -98,6 +98,7 @@ public function execute()
9898
*/
9999
protected function jsonResponse($error = '')
100100
{
101+
101102
return $this->getResponse()->representJson(
102103
$this->jsonHelper->jsonEncode($this->sidebar->getResponseData($error))
103104
);

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

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -250,36 +250,30 @@ public function testExecuteWithException(): void
250250
*/
251251
public function testExecuteWithNonNumericItemQty(): void
252252
{
253+
$error = [
254+
'success' => false,
255+
'error_message' => 'Invalid Item Quantity Requested.'
256+
];
257+
$jsonResult = json_encode($error);
253258
$this->requestMock
254259
->method('getParam')
255260
->withConsecutive(['item_id', null], ['item_qty', null])
256261
->willReturnOnConsecutiveCalls('1', '{{7+2}}');
257262

258263
$this->sidebarMock->expects($this->once())
259264
->method('getResponseData')
260-
->with('A non-numeric value found')
261-
->willReturn(
262-
[
263-
'success' => false,
264-
'error_message' => 'A non-numeric value found'
265-
]
266-
);
265+
->with('Invalid Item Quantity Requested.')
266+
->willReturn($error);
267267

268268
$this->jsonHelperMock->expects($this->once())
269269
->method('jsonEncode')
270-
->with(
271-
[
272-
'success' => false,
273-
'error_message' => 'A non-numeric value found'
274-
]
275-
)
276-
->willReturn('json encoded');
270+
->with($error)
271+
->willReturn($jsonResult);
277272

278273
$this->responseMock->expects($this->once())
279274
->method('representJson')
280-
->with('json encoded')
281-
->willReturn('json represented');
275+
->willReturn($jsonResult);
282276

283-
$this->assertEquals('json represented', $this->updateItemQty->execute());
277+
$this->assertEquals($jsonResult, $this->updateItemQty->execute());
284278
}
285279
}

app/code/Magento/Checkout/i18n/en_US.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,4 @@ Payment,Payment
186186
"Show Cross-sell Items in the Shopping Cart","Show Cross-sell Items in the Shopping Cart"
187187
"You added %1 to your <a href=""%2"">shopping cart</a>.","You added %1 to your <a href=""%2"">shopping cart</a>."
188188
"The shipping method is missing. Select the shipping method and try again.","The shipping method is missing. Select the shipping method and try again."
189+
"Invalid Item Quantity Requested.","Invalid Item Quantity Requested."

0 commit comments

Comments
 (0)