From 2eeb65ccd6201d95a667e5ccaf348b30d46317fe Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Fri, 28 Sep 2018 19:22:03 +0300 Subject: [PATCH 1/2] Fix the issue with customer inline edit when password is expired #18162 --- .../Controller/Adminhtml/Index/InlineEdit.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php index 98db7be559cdf..3c3808d0a1ee6 100644 --- a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php +++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php @@ -6,14 +6,16 @@ namespace Magento\Customer\Controller\Adminhtml\Index; use Magento\Backend\App\Action; +use Magento\Customer\Api\CustomerRepositoryInterface; +use Magento\Customer\Api\Data\CustomerInterface; use Magento\Customer\Model\EmailNotificationInterface; -use Magento\Customer\Test\Block\Form\Login; use Magento\Customer\Ui\Component\Listing\AttributeRepository; -use Magento\Customer\Api\Data\CustomerInterface; -use Magento\Customer\Api\CustomerRepositoryInterface; use Magento\Framework\App\Action\HttpPostActionInterface; +use Magento\Framework\Message\MessageInterface; /** + * Customer inline edit action + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class InlineEdit extends \Magento\Backend\App\Action implements HttpPostActionInterface @@ -102,7 +104,11 @@ private function getEmailNotification() } /** + * Inline edit action execute + * * @return \Magento\Framework\Controller\Result\Json + * @throws \Magento\Framework\Exception\LocalizedException + * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function execute() { @@ -250,7 +256,7 @@ protected function processAddressData(array $data) protected function getErrorMessages() { $messages = []; - foreach ($this->getMessageManager()->getMessages()->getItems() as $error) { + foreach ($this->getMessageManager()->getMessages()->getErrors() as $error) { $messages[] = $error->getText(); } return $messages; @@ -263,7 +269,7 @@ protected function getErrorMessages() */ protected function isErrorExists() { - return (bool)$this->getMessageManager()->getMessages(true)->getCount(); + return (bool)$this->getMessageManager()->getMessages(true)->getCountByType(MessageInterface::TYPE_ERROR); } /** From 34830c61154ae4b199eef531901164a417ef6c7d Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Fri, 28 Sep 2018 19:29:28 +0300 Subject: [PATCH 2/2] Updated the unit tests #18162 --- .../Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php index 913c41070856e..78d9dd7003522 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php @@ -6,6 +6,7 @@ namespace Magento\Customer\Test\Unit\Controller\Adminhtml\Index; use Magento\Customer\Model\EmailNotificationInterface; +use Magento\Framework\Message\MessageInterface; /** * @SuppressWarnings(PHPMD.TooManyFields) @@ -242,10 +243,11 @@ protected function prepareMocksForErrorMessagesProcessing() ->method('getMessages') ->willReturn($this->messageCollection); $this->messageCollection->expects($this->once()) - ->method('getItems') + ->method('getErrors') ->willReturn([$this->message]); $this->messageCollection->expects($this->once()) - ->method('getCount') + ->method('getCountByType') + ->with(MessageInterface::TYPE_ERROR) ->willReturn(1); $this->message->expects($this->once()) ->method('getText')