File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Controller/Adminhtml/User/Role
Test/Unit/Controller/Adminhtml/User/Role Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,14 @@ public function execute()
36
36
37
37
return $ resultRedirect ->setPath ('adminhtml/*/editrole ' , ['rid ' => $ rid ]);
38
38
}
39
+ $ role = $ this ->_initRole ();
40
+ if (!$ role ->getId ()) {
41
+ $ this ->messageManager ->addError (__ ('We can \'t find a role to delete. ' ));
42
+
43
+ return $ resultRedirect ->setPath ("*/*/ " );
44
+ }
39
45
40
46
try {
41
- $ role = $ this ->_initRole ();
42
- if (!$ role ->getId ()) {
43
- throw new \Exception ();
44
- }
45
47
$ role ->delete ();
46
48
$ this ->messageManager ->addSuccess (__ ('You deleted the role. ' ));
47
49
} catch (\Exception $ e ) {
Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ public function testExecuteWithoutRole()
289
289
290
290
$ this ->messageManagerMock ->expects ($ this ->once ())
291
291
->method ('addError ' )
292
- ->with (__ ('An error occurred while deleting this role . ' ))
292
+ ->with (__ ('We can \' t find a role to delete . ' ))
293
293
->willReturnSelf ();
294
294
295
295
$ this ->resultRedirectMock ->expects ($ this ->once ())
You can’t perform that action at this time.
0 commit comments