diff --git a/app/bootstrap.php b/app/bootstrap.php index 70b632537a75b..8e901cac9bfb8 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -31,8 +31,6 @@ // Sets default autoload mappings, may be overridden in Bootstrap::create \Magento\Framework\App\Bootstrap::populateAutoloader(BP, []); -require_once BP . '/app/functions.php'; - /* Custom umask value may be provided in optional mage_umask file in root */ $umaskFile = BP . '/magento_umask'; $mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002; diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php index af1ded6987196..196b4df5b47c0 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/DeleteTest.php @@ -71,7 +71,7 @@ protected function setUp() false, true, true, - ['addSuccess'] + ['addSuccessMessage'] ); $this->categoryRepository = $this->createMock(\Magento\Catalog\Api\CategoryRepositoryInterface::class); $context->expects($this->any()) diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php index 53f7fa0ed7e63..74173dc926d97 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/SaveTest.php @@ -102,7 +102,7 @@ protected function setUp() false, true, true, - ['addSuccess', 'getMessages'] + ['addSuccessMessage', 'getMessages'] ); $this->save = $this->objectManager->getObject( @@ -392,7 +392,7 @@ public function testExecute($categoryId, $storeId, $parentId) $categoryMock->expects($this->once()) ->method('save'); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with(__('You saved the category.')); $categoryMock->expects($this->at(1)) ->method('getId') diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php index 5a977b7934670..0ddd89afeac22 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/EditTest.php @@ -94,7 +94,7 @@ private function prepareContext() $messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->setMethods([]) ->disableOriginalConstructor()->getMock(); - $messageManager->expects($this->any())->method('addError')->willReturn(true); + $messageManager->expects($this->any())->method('addErrorMessage')->willReturn(true); $this->context = $this->getMockBuilder(\Magento\Backend\App\Action\Context::class) ->setMethods(['getRequest', 'getObjectManager', 'getMessageManager', 'getResultRedirectFactory']) ->disableOriginalConstructor()->getMock(); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php index c88a008efb19b..de44af7f58afc 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/Action/Attribute/SaveTest.php @@ -250,8 +250,8 @@ public function testExecuteThatProductIdsAreObtainedFromAttributeHelper() ['inventory', [], [7]], ])); - $this->messageManager->expects($this->never())->method('addError'); - $this->messageManager->expects($this->never())->method('addException'); + $this->messageManager->expects($this->never())->method('addErrorMessage'); + $this->messageManager->expects($this->never())->method('addExceptionMessage'); $this->object->execute(); } diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Delete.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Delete.php index 9f248f2cebc3d..eedcf5009ccfa 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Delete.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Delete.php @@ -22,21 +22,21 @@ public function execute() if (count($template->getSystemConfigPathsWhereCurrentlyUsed()) == 0) { $template->delete(); // display success message - $this->messageManager->addSuccess(__('You deleted the email template.')); + $this->messageManager->addSuccessMessage(__('You deleted the email template.')); $this->_objectManager->get(\Magento\Framework\App\ReinitableConfig::class)->reinit(); // go to grid $this->_redirect('adminhtml/*/'); return; } // display error message - $this->messageManager->addError(__('The email template is currently being used.')); + $this->messageManager->addErrorMessage(__('The email template is currently being used.')); // redirect to edit form $this->_redirect('adminhtml/*/edit', ['id' => $template->getId()]); return; } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addError( + $this->messageManager->addErrorMessage( __('We can\'t delete email template data right now. Please review log and try again.') ); $this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e); @@ -52,7 +52,7 @@ public function execute() } } // display error message - $this->messageManager->addError(__('We can\'t find an email template to delete.')); + $this->messageManager->addErrorMessage(__('We can\'t find an email template to delete.')); // go to grid $this->_redirect('adminhtml/*/'); } diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php index e23cd6cf17eb2..404f97c937167 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php @@ -21,7 +21,9 @@ public function execute() $this->_view->renderLayout(); $this->getResponse()->setHeader('Content-Security-Policy', "script-src 'none'"); } catch (\Exception $e) { - $this->messageManager->addError(__('An error occurred. The email template can not be opened for preview.')); + $this->messageManager->addErrorMessage( + __('An error occurred. The email template can not be opened for preview.') + ); $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php index cf31259b7885d..135506f4068a8 100644 --- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php +++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php @@ -22,7 +22,7 @@ public function execute() $template = $this->_initTemplate('id'); if (!$template->getId() && $id) { - $this->messageManager->addError(__('This email template no longer exists.')); + $this->messageManager->addErrorMessage(__('This email template no longer exists.')); $this->_redirect('adminhtml/*/'); return; } @@ -55,7 +55,7 @@ public function execute() $template->save(); $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false); - $this->messageManager->addSuccess(__('You saved the email template.')); + $this->messageManager->addSuccessMessage(__('You saved the email template.')); $this->_redirect('adminhtml/*'); } catch (\Exception $e) { $this->_objectManager->get( @@ -64,7 +64,7 @@ public function execute() 'email_template_form_data', $request->getParams() ); - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $this->_forward('new'); } } diff --git a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php index bb476423692d1..9d8b612cefadf 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Delete.php @@ -60,16 +60,18 @@ public function execute() /** @var \Magento\Search\Model\SynonymGroup $synGroupModel */ $synGroupModel = $this->synGroupRepository->get($id); $this->synGroupRepository->delete($synGroupModel); - $this->messageManager->addSuccess(__('The synonym group has been deleted.')); + $this->messageManager->addSuccessMessage(__('The synonym group has been deleted.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $this->logger->error($e); } catch (\Exception $e) { - $this->messageManager->addError(__('An error was encountered while performing delete operation.')); + $this->messageManager->addErrorMessage( + __('An error was encountered while performing delete operation.') + ); $this->logger->error($e); } } else { - $this->messageManager->addError(__('We can\'t find a synonym group to delete.')); + $this->messageManager->addErrorMessage(__('We can\'t find a synonym group to delete.')); } return $resultRedirect->setPath('*/*/'); diff --git a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Edit.php b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Edit.php index 506976247327f..3e6ac0abf2126 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Edit.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Edit.php @@ -66,7 +66,7 @@ public function execute() // 2. Initial checking if ($groupId && (!$synGroup->getGroupId())) { - $this->messageManager->addError(__('This synonyms group no longer exists.')); + $this->messageManager->addErrorMessage(__('This synonyms group no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('*/*/'); diff --git a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/MassDelete.php b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/MassDelete.php index 4add418d95325..f2770f77cc533 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/MassDelete.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/MassDelete.php @@ -72,17 +72,17 @@ public function execute() $this->synGroupRepository->delete($synonymGroup); $deletedItems++; } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } } if ($deletedItems != 0) { if ($collectionSize != $deletedItems) { - $this->messageManager->addError( + $this->messageManager->addErrorMessage( __('Failed to delete %1 synonym group(s).', $collectionSize - $deletedItems) ); } - $this->messageManager->addSuccess( + $this->messageManager->addSuccessMessage( __('A total of %1 synonym group(s) have been deleted.', $deletedItems) ); } diff --git a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Save.php b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Save.php index ffa97ceb3e0e1..0ed73fd0cee32 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Save.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Synonyms/Save.php @@ -59,7 +59,7 @@ public function execute() $synGroup = $this->synGroupRepository->get($synGroupId); if (!$synGroup->getGroupId() && $synGroupId) { - $this->messageManager->addError(__('This synonym group no longer exists.')); + $this->messageManager->addErrorMessage(__('This synonym group no longer exists.')); return $resultRedirect->setPath('*/*/'); } diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php index 3a1b80df2ea7e..c7adf32da0fb0 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Delete.php @@ -23,16 +23,16 @@ public function execute() $model = $this->_objectManager->create(\Magento\Search\Model\Query::class); $model->setId($id); $model->delete(); - $this->messageManager->addSuccess(__('You deleted the search.')); + $this->messageManager->addSuccessMessage(__('You deleted the search.')); $resultRedirect->setPath('search/*/'); return $resultRedirect; } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $resultRedirect->setPath('search/*/edit', ['id' => $this->getRequest()->getParam('id')]); return $resultRedirect; } } - $this->messageManager->addError(__('We can\'t find a search term to delete.')); + $this->messageManager->addErrorMessage(__('We can\'t find a search term to delete.')); $resultRedirect->setPath('search/*/'); return $resultRedirect; } diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php index 85e14ae9fe0b0..3ee0ea240377f 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Edit.php @@ -43,7 +43,7 @@ public function execute() if ($id) { $model->load($id); if (!$model->getId()) { - $this->messageManager->addError(__('This search no longer exists.')); + $this->messageManager->addErrorMessage(__('This search no longer exists.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $resultRedirect->setPath('search/*'); diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php b/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php index b38d883b8faae..f6874078f2f64 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/MassDelete.php @@ -17,16 +17,16 @@ public function execute() { $searchIds = $this->getRequest()->getParam('search'); if (!is_array($searchIds)) { - $this->messageManager->addError(__('Please select searches.')); + $this->messageManager->addErrorMessage(__('Please select searches.')); } else { try { foreach ($searchIds as $searchId) { $model = $this->_objectManager->create(\Magento\Search\Model\Query::class)->load($searchId); $model->delete(); } - $this->messageManager->addSuccess(__('Total of %1 record(s) were deleted.', count($searchIds))); + $this->messageManager->addSuccessMessage(__('Total of %1 record(s) were deleted.', count($searchIds))); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php index 42e9373a20fe2..cd9b1347ed1ed 100644 --- a/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php +++ b/app/code/Magento/Search/Controller/Adminhtml/Term/Save.php @@ -45,12 +45,15 @@ public function execute() $model->addData($data); $model->setIsProcessed(0); $model->save(); - $this->messageManager->addSuccess(__('You saved the search term.')); + $this->messageManager->addSuccessMessage(__('You saved the search term.')); } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); return $this->proceedToEdit($data); } catch (\Exception $e) { - $this->messageManager->addException($e, __('Something went wrong while saving the search query.')); + $this->messageManager->addExceptionMessage( + $e, + __('Something went wrong while saving the search query.') + ); return $this->proceedToEdit($data); } } diff --git a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Synonyms/DeleteTest.php b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Synonyms/DeleteTest.php index a7f71941dc6b2..38c78b986faf4 100644 --- a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Synonyms/DeleteTest.php +++ b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Synonyms/DeleteTest.php @@ -107,10 +107,10 @@ public function testDeleteAction() $this->repository->expects($this->once())->method('get')->with(10)->willReturn($this->synonymGroupMock); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with(__('The synonym group has been deleted.')); - $this->messageManagerMock->expects($this->never())->method('addError'); + $this->messageManagerMock->expects($this->never())->method('addErrorMessage'); $this->resultRedirectMock->expects($this->once())->method('setPath')->with('*/*/')->willReturnSelf(); @@ -124,10 +124,10 @@ public function testDeleteActionNoId() ->willReturn(null); $this->messageManagerMock->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with(__('We can\'t find a synonym group to delete.')); $this->messageManagerMock->expects($this->never()) - ->method('addSuccess'); + ->method('addSuccessMessage'); $this->resultRedirectMock->expects($this->once()) ->method('setPath') diff --git a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/MassDeleteTest.php b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/MassDeleteTest.php index efda8f52fcfe9..60cc958a6187c 100644 --- a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/MassDeleteTest.php +++ b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/MassDeleteTest.php @@ -54,7 +54,7 @@ protected function setUp() ->getMockForAbstractClass(); $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() - ->setMethods(['addSuccess', 'addError']) + ->setMethods(['addSuccessMessage', 'addErrorMessage']) ->getMockForAbstractClass(); $this->pageFactory = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class) ->setMethods([]) @@ -107,7 +107,7 @@ public function testExecute() $this->createQuery(0, 1); $this->createQuery(1, 2); $this->messageManager->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->will($this->returnSelf()); $this->resultRedirectMock->expects($this->once()) ->method('setPath') diff --git a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php index 09ae2c38fe525..28f4b65cd412f 100644 --- a/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php +++ b/app/code/Magento/Search/Test/Unit/Controller/Adminhtml/Term/SaveTest.php @@ -75,7 +75,7 @@ protected function setUp() $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() - ->setMethods(['addSuccess', 'addError', 'addException']) + ->setMethods(['addSuccessMessage', 'addErrorMessage', 'addExceptionMessage']) ->getMockForAbstractClass(); $this->context->expects($this->any()) ->method('getMessageManager') @@ -143,7 +143,7 @@ public function testExecuteLoadQueryQueryId() $this->query->expects($this->once())->method('getId')->willReturn(false); $this->query->expects($this->once())->method('load')->with($queryId); - $this->messageManager->expects($this->once())->method('addSuccess'); + $this->messageManager->expects($this->once())->method('addSuccessMessage'); $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); $this->assertSame($this->redirect, $this->controller->execute()); @@ -161,7 +161,7 @@ public function testExecuteLoadQueryQueryIdQueryText() $this->query->expects($this->once())->method('loadByQueryText')->with($queryText); $this->query->expects($this->any())->method('getId')->willReturn($queryId); - $this->messageManager->expects($this->once())->method('addSuccess'); + $this->messageManager->expects($this->once())->method('addSuccessMessage'); $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); $this->assertSame($this->redirect, $this->controller->execute()); @@ -180,7 +180,7 @@ public function testExecuteLoadQueryQueryIdQueryText2() $this->query->expects($this->any())->method('getId')->willReturn(false); $this->query->expects($this->once())->method('load')->with($queryId); - $this->messageManager->expects($this->once())->method('addSuccess'); + $this->messageManager->expects($this->once())->method('addSuccessMessage'); $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); $this->assertSame($this->redirect, $this->controller->execute()); @@ -199,7 +199,7 @@ public function testExecuteLoadQueryQueryIdQueryTextException() $this->query->expects($this->once())->method('loadByQueryText')->with($queryText); $this->query->expects($this->any())->method('getId')->willReturn($anotherQueryId); - $this->messageManager->expects($this->once())->method('addError'); + $this->messageManager->expects($this->once())->method('addErrorMessage'); $this->session->expects($this->once())->method('setPageData'); $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); $this->assertSame($this->redirect, $this->controller->execute()); @@ -216,7 +216,7 @@ public function testExecuteException() $this->query->expects($this->once())->method('setStoreId'); $this->query->expects($this->once())->method('loadByQueryText')->willThrowException(new \Exception()); - $this->messageManager->expects($this->once())->method('addException'); + $this->messageManager->expects($this->once())->method('addExceptionMessage'); $this->session->expects($this->once())->method('setPageData'); $this->redirect->expects($this->once())->method('setPath')->willReturnSelf(); $this->assertSame($this->redirect, $this->controller->execute()); diff --git a/app/code/Magento/Security/Controller/Adminhtml/Session/LogoutAll.php b/app/code/Magento/Security/Controller/Adminhtml/Session/LogoutAll.php index c533e740b2251..35d8f22d84d51 100644 --- a/app/code/Magento/Security/Controller/Adminhtml/Session/LogoutAll.php +++ b/app/code/Magento/Security/Controller/Adminhtml/Session/LogoutAll.php @@ -38,11 +38,11 @@ public function execute() { try { $this->sessionsManager->logoutOtherUserSessions(); - $this->messageManager->addSuccess(__('All other open sessions for this account were terminated.')); + $this->messageManager->addSuccessMessage(__('All other open sessions for this account were terminated.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __("We couldn't logout because of an error.")); + $this->messageManager->addExceptionMessage($e, __("We couldn't logout because of an error.")); } $this->_redirect('*/*/activity'); } diff --git a/app/code/Magento/Security/Model/Plugin/AuthSession.php b/app/code/Magento/Security/Model/Plugin/AuthSession.php index 64645396dceb6..08a81f12d9cfc 100644 --- a/app/code/Magento/Security/Model/Plugin/AuthSession.php +++ b/app/code/Magento/Security/Model/Plugin/AuthSession.php @@ -82,7 +82,7 @@ private function addUserLogoutNotification() $this->sessionsManager->getCurrentSession()->getStatus() ); } elseif ($message = $this->sessionsManager->getLogoutReasonMessage()) { - $this->messageManager->addError($message); + $this->messageManager->addErrorMessage($message); } return $this; diff --git a/app/code/Magento/Security/Model/Plugin/LoginController.php b/app/code/Magento/Security/Model/Plugin/LoginController.php index ab9c6e2857bce..ba1a18c4f0c06 100644 --- a/app/code/Magento/Security/Model/Plugin/LoginController.php +++ b/app/code/Magento/Security/Model/Plugin/LoginController.php @@ -53,7 +53,7 @@ public function beforeExecute(Login $login) { $logoutReasonCode = $this->securityCookie->getLogoutReasonCookie(); if ($this->isLoginForm($login) && $logoutReasonCode >= 0) { - $this->messageManager->addError( + $this->messageManager->addErrorMessage( $this->sessionsManager->getLogoutReasonMessageByStatus($logoutReasonCode) ); $this->securityCookie->deleteLogoutReasonCookie(); diff --git a/app/code/Magento/Security/Test/Unit/Controller/Adminhtml/Session/LogoutAllTest.php b/app/code/Magento/Security/Test/Unit/Controller/Adminhtml/Session/LogoutAllTest.php index 8c2119bde667e..02335ef55aa93 100644 --- a/app/code/Magento/Security/Test/Unit/Controller/Adminhtml/Session/LogoutAllTest.php +++ b/app/code/Magento/Security/Test/Unit/Controller/Adminhtml/Session/LogoutAllTest.php @@ -74,7 +74,7 @@ public function setUp() $this->messageManager = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class) ->disableOriginalConstructor() - ->setMethods(['addSuccess', 'addError', 'addException']) + ->setMethods(['addSuccessMessage', 'addErrorMessage', 'addExceptionMessage']) ->getMockForAbstractClass(); $this->contextMock->expects($this->any()) ->method('getMessageManager') @@ -132,12 +132,12 @@ public function testExecute() $this->sessionsManager->expects($this->once()) ->method('logoutOtherUserSessions'); $this->messageManager->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with($successMessage); $this->messageManager->expects($this->never()) - ->method('addError'); + ->method('addErrorMessage'); $this->messageManager->expects($this->never()) - ->method('addException'); + ->method('addExceptionMessage'); $this->responseMock->expects($this->once()) ->method('setRedirect'); $this->actionFlagMock->expects($this->once()) @@ -158,7 +158,7 @@ public function testExecuteLocalizedException() ->method('logoutOtherUserSessions') ->willThrowException(new LocalizedException($phrase)); $this->messageManager->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with($phrase); $this->controller->execute(); } @@ -173,7 +173,7 @@ public function testExecuteException() ->method('logoutOtherUserSessions') ->willThrowException(new \Exception()); $this->messageManager->expects($this->once()) - ->method('addException') + ->method('addExceptionMessage') ->with(new \Exception(), $phrase); $this->controller->execute(); } diff --git a/app/code/Magento/Security/Test/Unit/Model/Plugin/AuthSessionTest.php b/app/code/Magento/Security/Test/Unit/Model/Plugin/AuthSessionTest.php index 5cb06d6143023..0f7f590b71de4 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Plugin/AuthSessionTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Plugin/AuthSessionTest.php @@ -112,7 +112,7 @@ public function testAroundProlongSessionIsNotActiveAndIsNotAjaxRequest() ->willReturn($errorMessage); $this->messageManagerMock->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with($errorMessage); $this->model->aroundProlong($this->authSessionMock, $proceed); diff --git a/app/code/Magento/Security/Test/Unit/Model/Plugin/LoginControllerTest.php b/app/code/Magento/Security/Test/Unit/Model/Plugin/LoginControllerTest.php index 2bb2bc3cafac7..aa066e23f67cb 100644 --- a/app/code/Magento/Security/Test/Unit/Model/Plugin/LoginControllerTest.php +++ b/app/code/Magento/Security/Test/Unit/Model/Plugin/LoginControllerTest.php @@ -103,7 +103,7 @@ public function testBeforeExecute() ->willReturn($errorMessage); $this->messageManagerMock->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with($errorMessage); $this->securityCookieMock->expects($this->once()) diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Delete.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Delete.php index f0be0fe7ab682..a885aa30dae5e 100644 --- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Delete.php +++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Delete.php @@ -61,20 +61,20 @@ public function execute() } $sitemap->delete(); // display success message - $this->messageManager->addSuccess(__('You deleted the sitemap.')); + $this->messageManager->addSuccessMessage(__('You deleted the sitemap.')); // go to grid $this->_redirect('adminhtml/*/'); return; } catch (\Exception $e) { // display error message - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); // go back to edit form $this->_redirect('adminhtml/*/edit', ['sitemap_id' => $id]); return; } } // display error message - $this->messageManager->addError(__('We can\'t find a sitemap to delete.')); + $this->messageManager->addErrorMessage(__('We can\'t find a sitemap to delete.')); // go to grid $this->_redirect('adminhtml/*/'); } diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Edit.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Edit.php index 04ab4f8725e0e..111353550b9cd 100644 --- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Edit.php +++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Edit.php @@ -41,7 +41,7 @@ public function execute() if ($id) { $model->load($id); if (!$model->getId()) { - $this->messageManager->addError(__('This sitemap no longer exists.')); + $this->messageManager->addErrorMessage(__('This sitemap no longer exists.')); $this->_redirect('adminhtml/*/'); return; } diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php index d19b248c8008f..9592ab6f57c55 100644 --- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php +++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Generate.php @@ -52,18 +52,18 @@ public function execute() ); $sitemap->generateXml(); - $this->messageManager->addSuccess( + $this->messageManager->addSuccessMessage( __('The sitemap "%1" has been generated.', $sitemap->getSitemapFilename()) ); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('We can\'t generate the sitemap right now.')); + $this->messageManager->addExceptionMessage($e, __('We can\'t generate the sitemap right now.')); } finally { $this->appEmulation->stopEnvironmentEmulation(); } } else { - $this->messageManager->addError(__('We can\'t find a sitemap to generate.')); + $this->messageManager->addErrorMessage(__('We can\'t find a sitemap to generate.')); } // go to grid diff --git a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Save.php b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Save.php index 5c38cc68e6ef7..1e0d1cb248f00 100644 --- a/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Save.php +++ b/app/code/Magento/Sitemap/Controller/Adminhtml/Sitemap/Save.php @@ -30,7 +30,7 @@ protected function validatePath(array $data) $validator->setPaths($helper->getValidPaths()); if (!$validator->isValid($path)) { foreach ($validator->getMessages() as $message) { - $this->messageManager->addError($message); + $this->messageManager->addErrorMessage($message); } // save data in session $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData($data); @@ -83,13 +83,13 @@ protected function saveData($data) // save the data $model->save(); // display success message - $this->messageManager->addSuccess(__('You saved the sitemap.')); + $this->messageManager->addSuccessMessage(__('You saved the sitemap.')); // clear previously saved data from session $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false); return $model->getId(); } catch (\Exception $e) { // display error message - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); // save data in session $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData($data); } diff --git a/app/code/Magento/Sitemap/Test/Unit/Controller/Adminhtml/Sitemap/SaveTest.php b/app/code/Magento/Sitemap/Test/Unit/Controller/Adminhtml/Sitemap/SaveTest.php index 36e3aa0312627..f77954101df7c 100644 --- a/app/code/Magento/Sitemap/Test/Unit/Controller/Adminhtml/Sitemap/SaveTest.php +++ b/app/code/Magento/Sitemap/Test/Unit/Controller/Adminhtml/Sitemap/SaveTest.php @@ -154,7 +154,7 @@ public function testTryToSaveInvalidDataShouldFailWithErrors() ->willReturnMap([[$helperClass, $helper], [$sessionClass, $session]]); $this->messageManagerMock->expects($this->at(0)) - ->method('addError') + ->method('addErrorMessage') ->withConsecutive( [$messages[0]], [$messages[1]] diff --git a/app/functions.php b/app/functions.php index 0b5fa4de4100e..4b00d01819f70 100644 --- a/app/functions.php +++ b/app/functions.php @@ -6,17 +6,22 @@ /** * Create value-object \Magento\Framework\Phrase - * + * @deprecated The global function __() is now loaded via Magento Framework, the below require is only + * for backwards compatibility reasons and this file will be removed in a future version + * @see Magento\Framework\Phrase\__.php + * @SuppressWarnings(PHPMD.ShortMethodName) * @return \Magento\Framework\Phrase */ -function __() -{ - $argc = func_get_args(); +if (!function_exists('__')) { + function __() + { + $argc = func_get_args(); - $text = array_shift($argc); - if (!empty($argc) && is_array($argc[0])) { - $argc = $argc[0]; - } + $text = array_shift($argc); + if (!empty($argc) && is_array($argc[0])) { + $argc = $argc[0]; + } - return new \Magento\Framework\Phrase($text, $argc); + return new \Magento\Framework\Phrase($text, $argc); + } } diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index 68dba4e2ce00c..06aee53dafb14 100644 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -11,7 +11,6 @@ } require_once __DIR__ . '/autoload.php'; -require BP . '/app/functions.php'; setCustomErrorHandler(); diff --git a/lib/internal/Magento/Framework/Phrase/__.php b/lib/internal/Magento/Framework/Phrase/__.php new file mode 100644 index 0000000000000..a8d69ec622e90 --- /dev/null +++ b/lib/internal/Magento/Framework/Phrase/__.php @@ -0,0 +1,22 @@ +