File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed
app/code/Magento/Customer/Controller/Adminhtml/Index
dev/tests/integration/testsuite/Magento/Customer/Controller/Adminhtml/Index Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,12 @@ public function execute()
380
380
$ this ->_coreRegistry ->register (RegistryConstants::CURRENT_CUSTOMER_ID , $ customerId );
381
381
$ this ->messageManager ->addSuccessMessage (__ ('You saved the customer. ' ));
382
382
$ returnToEdit = (bool )$ this ->getRequest ()->getParam ('back ' , false );
383
+ } catch (NoSuchEntityException $ exception ) {
384
+ $ this ->messageManager ->addExceptionMessage (
385
+ $ exception ,
386
+ __ ('Something went wrong while saving the customer. ' )
387
+ );
388
+ $ returnToEdit = false ;
383
389
} catch (\Magento \Framework \Validator \Exception $ exception ) {
384
390
$ messages = $ exception ->getMessages ();
385
391
if (empty ($ messages )) {
Original file line number Diff line number Diff line change @@ -222,6 +222,32 @@ public function createCustomerErrorsProvider(): array
222
222
];
223
223
}
224
224
225
+ /**
226
+ * Update customer with exceptions
227
+ *
228
+ * @magentoDbIsolation enabled
229
+ *
230
+ * @return void
231
+ */
232
+ public function testUpdateCustomerErrors (): void
233
+ {
234
+ $ postData = [
235
+ 'customer ' => [
236
+ CustomerData::FIRSTNAME => 'John ' ,
237
+ CustomerData::LASTNAME => 'Doe ' ,
238
+ ],
239
+ 'subscription ' => '1 ' ,
240
+ ];
241
+ $ expectedMessages = [(string )__ ('Something went wrong while saving the customer. ' )];
242
+ $ postData ['customer ' ]['entity_id ' ] = -1 ;
243
+ $ params = ['back ' => true ];
244
+ $ this ->dispatchCustomerSave ($ postData , $ params );
245
+ $ this ->assertSessionMessages (
246
+ $ this ->equalTo ($ expectedMessages ),
247
+ MessageInterface::TYPE_ERROR
248
+ );
249
+ }
250
+
225
251
/**
226
252
* Update customer with subscription and redirect to edit page.
227
253
*
You can’t perform that action at this time.
0 commit comments