From d359cdf8037187c53441965920c555a3bf95985a Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Thu, 20 Feb 2020 10:09:49 +0200 Subject: [PATCH 1/5] ObjectManager cleanup - Remove usage from AdminNotification module --- .../Block/System/Messages.php | 54 +++++++++---------- .../Adminhtml/Notification/AjaxMarkAsRead.php | 18 +++---- .../Adminhtml/Notification/MarkAsRead.php | 23 +++++--- .../Adminhtml/Notification/MassMarkAsRead.php | 20 +++++-- .../Adminhtml/Notification/MassRemove.php | 18 ++++++- .../Adminhtml/Notification/Remove.php | 20 +++++-- 6 files changed, 102 insertions(+), 51 deletions(-) diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index b950f5583e599..2fbd918c2d824 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -5,45 +5,51 @@ */ namespace Magento\AdminNotification\Block\System; -class Messages extends \Magento\Backend\Block\Template +use Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized; +use Magento\Backend\Block\Template; +use Magento\Backend\Block\Template\Context as TemplateContext; +use Magento\Framework\Json\Helper\Data as JsonDataHelper; +use Magento\Framework\Notification\MessageInterface; +use Magento\Framework\Serialize\Serializer\Json as JsonSerializer; + +class Messages extends Template { /** - * Message list + * Synchronized Message collection * - * @var \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized + * @var Synchronized */ protected $_messages; /** - * @var \Magento\Framework\Json\Helper\Data + * @var JsonDataHelper * @deprecated */ protected $jsonHelper; /** - * @var \Magento\Framework\Serialize\Serializer\Json + * @var JsonSerializer */ private $serializer; /** - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages - * @param \Magento\Framework\Json\Helper\Data $jsonHelper + * @param TemplateContext $context + * @param Synchronized $messages + * @param JsonDataHelper $jsonHelper + * @param JsonSerializer $serializer * @param array $data - * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\AdminNotification\Model\ResourceModel\System\Message\Collection\Synchronized $messages, - \Magento\Framework\Json\Helper\Data $jsonHelper, - array $data = [], - \Magento\Framework\Serialize\Serializer\Json $serializer = null + TemplateContext $context, + Synchronized $messages, + JsonDataHelper $jsonHelper, + JsonSerializer $serializer, + array $data = [] ) { $this->jsonHelper = $jsonHelper; parent::__construct($context, $data); $this->_messages = $messages; - $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\Framework\Serialize\Serializer\Json::class); + $this->serializer = $serializer; } /** @@ -62,15 +68,13 @@ protected function _toHtml() /** * Retrieve message list * - * @return \Magento\Framework\Notification\MessageInterface[] + * @return MessageInterface[]|null */ public function getLastCritical() { $items = array_values($this->_messages->getItems()); - if (isset( - $items[0] - ) && $items[0]->getSeverity() == \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL - ) { + + if (isset($items[0]) && (int)$items[0]->getSeverity() === MessageInterface::SEVERITY_CRITICAL) { return $items[0]; } return null; @@ -83,9 +87,7 @@ public function getLastCritical() */ public function getCriticalCount() { - return $this->_messages->getCountBySeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_CRITICAL - ); + return $this->_messages->getCountBySeverity(MessageInterface::SEVERITY_CRITICAL); } /** @@ -95,9 +97,7 @@ public function getCriticalCount() */ public function getMajorCount() { - return $this->_messages->getCountBySeverity( - \Magento\Framework\Notification\MessageInterface::SEVERITY_MAJOR - ); + return $this->_messages->getCountBySeverity(MessageInterface::SEVERITY_MAJOR); } /** diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php index da797fe12e75a..e05de78c92356 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php @@ -6,28 +6,26 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Model\NotificationService; use Magento\Backend\App\Action; use Magento\Framework\Controller\ResultFactory; -class AjaxMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notification +class AjaxMarkAsRead extends Notification { /** - * @var \Magento\AdminNotification\Model\NotificationService + * @var NotificationService */ private $notificationService; /** * @param Action\Context $context - * @param \Magento\AdminNotification\Model\NotificationService|null $notificationService - * @throws \RuntimeException + * @param NotificationService $notificationService */ - public function __construct( - Action\Context $context, - \Magento\AdminNotification\Model\NotificationService $notificationService = null - ) { + public function __construct(Action\Context $context, NotificationService $notificationService) + { parent::__construct($context); - $this->notificationService = $notificationService?: \Magento\Framework\App\ObjectManager::getInstance() - ->get(\Magento\AdminNotification\Model\NotificationService::class); + $this->notificationService = $notificationService; } /** diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php index 6b5e0681139cf..edc6c702abe26 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php @@ -6,7 +6,11 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; -class MarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notification +use Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Model\NotificationService; +use Magento\Backend\App\Action; + +class MarkAsRead extends Notification { /** * Authorization level of a basic admin session @@ -15,6 +19,17 @@ class MarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notific */ const ADMIN_RESOURCE = 'Magento_AdminNotification::mark_as_read'; + /** + * @var NotificationService + */ + private $notificationService; + + public function __construct(Action\Context $context, NotificationService $notificationService) + { + parent::__construct($context); + $this->notificationService = $notificationService; + } + /** * @return void */ @@ -23,11 +38,7 @@ public function execute() $notificationId = (int)$this->getRequest()->getParam('id'); if ($notificationId) { try { - $this->_objectManager->create( - \Magento\AdminNotification\Model\NotificationService::class - )->markAsRead( - $notificationId - ); + $this->notificationService->markAsRead($notificationId); $this->messageManager->addSuccessMessage(__('The message has been marked as Read.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php index 9ae4a7cdac0b9..e73f4219b7333 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php @@ -6,9 +6,12 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; -class MassMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Notification -{ +use Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Model\InboxFactory as InboxModelFactory; +use Magento\Backend\App\Action; +class MassMarkAsRead extends Notification +{ /** * Authorization level of a basic admin session * @@ -16,6 +19,17 @@ class MassMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Not */ const ADMIN_RESOURCE = 'Magento_AdminNotification::mark_as_read'; + /** + * @var InboxModelFactory + */ + private $inboxModelFactory; + + public function __construct(Action\Context $context, InboxModelFactory $inboxModelFactory) + { + parent::__construct($context); + $this->inboxModelFactory = $inboxModelFactory; + } + /** * @return void */ @@ -27,7 +41,7 @@ public function execute() } else { try { foreach ($ids as $id) { - $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id); + $model = $this->inboxModelFactory->create()->load($id); if ($model->getId()) { $model->setIsRead(1)->save(); } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php index 06659b8452cab..a248430b5660c 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php @@ -6,7 +6,11 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; -class MassRemove extends \Magento\AdminNotification\Controller\Adminhtml\Notification +use Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Model\InboxFactory as InboxModelFactory; +use Magento\Backend\App\Action; + +class MassRemove extends Notification { /** @@ -15,6 +19,16 @@ class MassRemove extends \Magento\AdminNotification\Controller\Adminhtml\Notific * @see _isAllowed() */ const ADMIN_RESOURCE = 'Magento_AdminNotification::adminnotification_remove'; + /** + * @var InboxModelFactory + */ + private $inboxModelFactory; + + public function __construct(Action\Context $context, InboxModelFactory $inboxModelFactory) + { + parent::__construct($context); + $this->inboxModelFactory = $inboxModelFactory; + } /** * @return void @@ -27,7 +41,7 @@ public function execute() } else { try { foreach ($ids as $id) { - $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id); + $model = $this->inboxModelFactory->create()->load($id); if ($model->getId()) { $model->setIsRemove(1)->save(); } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php index f0724a9587c50..0d74db43eef2b 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php @@ -6,9 +6,12 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; -class Remove extends \Magento\AdminNotification\Controller\Adminhtml\Notification -{ +use Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\AdminNotification\Model\InboxFactory as InboxModelFactory; +use Magento\Backend\App\Action; +class Remove extends Notification +{ /** * Authorization level of a basic admin session * @@ -16,13 +19,24 @@ class Remove extends \Magento\AdminNotification\Controller\Adminhtml\Notificatio */ const ADMIN_RESOURCE = 'Magento_AdminNotification::adminnotification_remove'; + /** + * @var InboxModelFactory + */ + private $inboxModelFactory; + + public function __construct(Action\Context $context, InboxModelFactory $inboxModelFactory) + { + parent::__construct($context); + $this->inboxModelFactory = $inboxModelFactory; + } + /** * @return void */ public function execute() { if ($id = $this->getRequest()->getParam('id')) { - $model = $this->_objectManager->create(\Magento\AdminNotification\Model\Inbox::class)->load($id); + $model = $this->inboxModelFactory->create()->load($id); if (!$model->getId()) { $this->_redirect('adminhtml/*/'); From 744b0f72ffcd5048c241381861cf5500e82f259a Mon Sep 17 00:00:00 2001 From: Ihor Sviziev Date: Wed, 26 Feb 2020 14:09:17 +0200 Subject: [PATCH 2/5] ObjectManager cleanup - Remove usage from AdminNotification module Fix small issues after code review --- app/code/Magento/AdminNotification/Block/System/Messages.php | 4 ++-- .../Controller/Adminhtml/Notification/MarkAsRead.php | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 2fbd918c2d824..318b8f8384e2e 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -74,8 +74,8 @@ public function getLastCritical() { $items = array_values($this->_messages->getItems()); - if (isset($items[0]) && (int)$items[0]->getSeverity() === MessageInterface::SEVERITY_CRITICAL) { - return $items[0]; + if (!empty($items) && current($items)->getSeverity() === MessageInterface::SEVERITY_CRITICAL) { + return current($items); } return null; } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php index edc6c702abe26..6dd40b56e0a24 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php @@ -9,6 +9,7 @@ use Magento\AdminNotification\Controller\Adminhtml\Notification; use Magento\AdminNotification\Model\NotificationService; use Magento\Backend\App\Action; +use Magento\Framework\Exception\LocalizedException; class MarkAsRead extends Notification { @@ -40,7 +41,7 @@ public function execute() try { $this->notificationService->markAsRead($notificationId); $this->messageManager->addSuccessMessage(__('The message has been marked as Read.')); - } catch (\Magento\Framework\Exception\LocalizedException $e) { + } catch (LocalizedException $e) { $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { $this->messageManager->addExceptionMessage( From 25989946b2a32204516a43ad491c69252e441ef2 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Thu, 27 Feb 2020 15:55:55 +0200 Subject: [PATCH 3/5] magento2/pull/26939: Fixed static test. --- .../Block/System/Messages.php | 3 +++ .../Adminhtml/Notification/AjaxMarkAsRead.php | 7 ++++-- .../Adminhtml/Notification/MarkAsRead.php | 20 +++++++++++----- .../Adminhtml/Notification/MassMarkAsRead.php | 17 ++++++++++---- .../Adminhtml/Notification/MassRemove.php | 17 ++++++++++---- .../Adminhtml/Notification/Remove.php | 23 ++++++++++++------- .../Notification/MassMarkAsReadTest.php | 3 +++ .../Adminhtml/Notification/MassRemoveTest.php | 3 +++ 8 files changed, 69 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 318b8f8384e2e..c9b3a0b8844cc 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -12,6 +12,9 @@ use Magento\Framework\Notification\MessageInterface; use Magento\Framework\Serialize\Serializer\Json as JsonSerializer; +/** + * AdminNotification Messages class + */ class Messages extends Template { /** diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php index e05de78c92356..be128435b62a1 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php @@ -1,6 +1,5 @@ getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); - return; + return $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); } - $this->_redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php index e73f4219b7333..9d052e8474dd9 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php @@ -1,6 +1,5 @@ _redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php index a248430b5660c..3f6575cdd4c67 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php @@ -1,6 +1,5 @@ _redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php index 0d74db43eef2b..39c563e8c1b29 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php @@ -1,6 +1,5 @@ inboxModelFactory->create()->load($id); if (!$model->getId()) { - $this->_redirect('adminhtml/*/'); - return; + return $this->_redirect('adminhtml/*/'); } try { @@ -55,9 +63,8 @@ public function execute() ); } - $this->_redirect('adminhtml/*/'); - return; + return $this->_redirect('adminhtml/*/'); } - $this->_redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php index c611d6fd7289f..04a69fe200dd1 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php @@ -5,12 +5,15 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\Framework\App\Request\Http as HttpRequest; + class MassMarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController { public function setUp() { $this->resource = 'Magento_AdminNotification::mark_as_read'; $this->uri = 'backend/admin/notification/massmarkasread'; + $this->httpMethod = HttpRequest::METHOD_POST; parent::setUp(); } } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php index f05985015833a..55ee6a58063a4 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php @@ -5,12 +5,15 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\Framework\App\Request\Http as HttpRequest; + class MassRemoveTest extends \Magento\TestFramework\TestCase\AbstractBackendController { public function setUp() { $this->resource = 'Magento_AdminNotification::adminnotification_remove'; $this->uri = 'backend/admin/notification/massremove'; + $this->httpMethod = HttpRequest::METHOD_POST; parent::setUp(); } } From 57af3d7395f1b2dbea7aa33758040f9cf25566ce Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Thu, 27 Feb 2020 15:55:55 +0200 Subject: [PATCH 4/5] magento2/pull/26939: Fixed static test. --- .../Block/System/Messages.php | 3 +++ .../Adminhtml/Notification/AjaxMarkAsRead.php | 7 +++++-- .../Adminhtml/Notification/MarkAsRead.php | 18 ++++++++++------ .../Adminhtml/Notification/MassMarkAsRead.php | 15 +++++++++---- .../Adminhtml/Notification/MassRemove.php | 15 +++++++++---- .../Adminhtml/Notification/Remove.php | 21 ++++++++++++------- .../Notification/MassMarkAsReadTest.php | 3 +++ .../Adminhtml/Notification/MassRemoveTest.php | 3 +++ 8 files changed, 61 insertions(+), 24 deletions(-) diff --git a/app/code/Magento/AdminNotification/Block/System/Messages.php b/app/code/Magento/AdminNotification/Block/System/Messages.php index 318b8f8384e2e..c9b3a0b8844cc 100644 --- a/app/code/Magento/AdminNotification/Block/System/Messages.php +++ b/app/code/Magento/AdminNotification/Block/System/Messages.php @@ -12,6 +12,9 @@ use Magento\Framework\Notification\MessageInterface; use Magento\Framework\Serialize\Serializer\Json as JsonSerializer; +/** + * AdminNotification Messages class + */ class Messages extends Template { /** diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php index e05de78c92356..be128435b62a1 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/AjaxMarkAsRead.php @@ -1,6 +1,5 @@ getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); - return; + return $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl($this->getUrl('*'))); } - $this->_redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php index e73f4219b7333..12198d05f6ae7 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php @@ -1,6 +1,5 @@ _redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php index a248430b5660c..0ca114ac4021c 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php @@ -1,6 +1,5 @@ _redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php index 0d74db43eef2b..fe699cd692160 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php @@ -1,6 +1,5 @@ inboxModelFactory->create()->load($id); if (!$model->getId()) { - $this->_redirect('adminhtml/*/'); - return; + return $this->_redirect('adminhtml/*/'); } try { @@ -55,9 +61,8 @@ public function execute() ); } - $this->_redirect('adminhtml/*/'); - return; + return $this->_redirect('adminhtml/*/'); } - $this->_redirect('adminhtml/*/'); + return $this->_redirect('adminhtml/*/'); } } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php index c611d6fd7289f..04a69fe200dd1 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsReadTest.php @@ -5,12 +5,15 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\Framework\App\Request\Http as HttpRequest; + class MassMarkAsReadTest extends \Magento\TestFramework\TestCase\AbstractBackendController { public function setUp() { $this->resource = 'Magento_AdminNotification::mark_as_read'; $this->uri = 'backend/admin/notification/massmarkasread'; + $this->httpMethod = HttpRequest::METHOD_POST; parent::setUp(); } } diff --git a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php index f05985015833a..55ee6a58063a4 100644 --- a/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php +++ b/dev/tests/integration/testsuite/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemoveTest.php @@ -5,12 +5,15 @@ */ namespace Magento\AdminNotification\Controller\Adminhtml\Notification; +use Magento\Framework\App\Request\Http as HttpRequest; + class MassRemoveTest extends \Magento\TestFramework\TestCase\AbstractBackendController { public function setUp() { $this->resource = 'Magento_AdminNotification::adminnotification_remove'; $this->uri = 'backend/admin/notification/massremove'; + $this->httpMethod = HttpRequest::METHOD_POST; parent::setUp(); } } From b7c1d0467cee29fa80b81d6cd20307a3dc8eed78 Mon Sep 17 00:00:00 2001 From: Alexander Steshuk Date: Tue, 3 Mar 2020 16:42:06 +0200 Subject: [PATCH 5/5] magento2/pull/26939: Fixed static test. --- .../Controller/Adminhtml/Notification/MarkAsRead.php | 2 -- .../Controller/Adminhtml/Notification/MassMarkAsRead.php | 2 -- .../Controller/Adminhtml/Notification/MassRemove.php | 2 -- .../Controller/Adminhtml/Notification/Remove.php | 2 -- 4 files changed, 8 deletions(-) diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php index b1bfddc2ea67f..7b3f99ae8e2c1 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MarkAsRead.php @@ -40,8 +40,6 @@ public function __construct(Action\Context $context, NotificationService $notifi /** * @inheritdoc - * - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface */ public function execute() { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php index 9d052e8474dd9..12198d05f6ae7 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassMarkAsRead.php @@ -39,8 +39,6 @@ public function __construct(Action\Context $context, InboxModelFactory $inboxMod /** * @inheritdoc - * - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface */ public function execute() { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php index 3f6575cdd4c67..0ca114ac4021c 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/MassRemove.php @@ -39,8 +39,6 @@ public function __construct(Action\Context $context, InboxModelFactory $inboxMod /** * @inheritdoc - * - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface */ public function execute() { diff --git a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php index 39c563e8c1b29..fe699cd692160 100644 --- a/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php +++ b/app/code/Magento/AdminNotification/Controller/Adminhtml/Notification/Remove.php @@ -39,8 +39,6 @@ public function __construct(Action\Context $context, InboxModelFactory $inboxMod /** * @inheritdoc - * - * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface */ public function execute() {