Skip to content

Commit

Permalink
ENGCOM-6168: Fixed deprecated method usages of MessageManager #25281
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirZaets committed Oct 30, 2019
2 parents 2baad7a + b4a822c commit 17740d7
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 53 deletions.
Expand Up @@ -157,6 +157,7 @@
<element name="FolderName" type="button" selector="input[data-role='promptField']" />
<element name="AcceptFolderName" type="button" selector=".action-primary.action-accept" timeout="30"/>
<element name="StorageRootArrow" type="button" selector="#root > .jstree-icon" />
<element name="FolderContainer" type="button" selector="div[data-role='tree']" />
<element name="checkIfArrowExpand" type="button" selector="//li[@id='root' and contains(@class,'jstree-closed')]" />
<element name="WysiwygArrow" type="button" selector="#d3lzaXd5Zw-- > .jstree-icon" />
<element name="checkIfWysiwygArrowExpand" type="button" selector="//li[@id='d3lzaXd5Zw--' and contains(@class,'jstree-closed')]" />
Expand Down
Expand Up @@ -70,11 +70,12 @@
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="scrollToTinyMCE4" />
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon2" />
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CancelBtn}}" stepKey="waitForCancelButton2"/>
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CancelBtn}}" userInput="Cancel" stepKey="seeCancelBtn2" />
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CreateFolder}}" stepKey="waitForCreateFolderBtn2"/>
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CreateFolder}}" userInput="Create Folder" stepKey="seeCreateFolderBtn2" />
<waitForLoadingMaskToDisappear stepKey="waitForLoading14"/>
<see selector="{{ProductDescriptionWYSIWYGToolbarSection.FolderContainer}}" userInput="Storage Root" stepKey="seeFolderContainer" />
<click userInput="Storage Root" stepKey="clickOnRootFolder" />
<waitForLoadingMaskToDisappear stepKey="waitForLoading15"/>
<dontSeeElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn3" />
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Wishlist/Controller/Index/Cart.php
Expand Up @@ -186,7 +186,7 @@ public function execute()
'You added %1 to your shopping cart.',
$this->escaper->escapeHtml($item->getProduct()->getName())
);
$this->messageManager->addSuccess($message);
$this->messageManager->addSuccessMessage($message);
}

if ($this->cartHelper->getShouldRedirectToCart()) {
Expand Down Expand Up @@ -214,7 +214,7 @@ public function execute()
$resultJson->setData(['backUrl' => $redirectUrl]);
return $resultJson;
}

$resultRedirect->setUrl($redirectUrl);
return $resultRedirect;
}
Expand Down
8 changes: 5 additions & 3 deletions app/code/Magento/Wishlist/Controller/Index/Configure.php
Expand Up @@ -11,9 +11,11 @@
use Magento\Framework\Controller\ResultFactory;

/**
* Wishlist Configure Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Configure extends \Magento\Wishlist\Controller\AbstractIndex
class Configure extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpGetActionInterface
{
/**
* Core registry
Expand Down Expand Up @@ -102,11 +104,11 @@ public function execute()

return $resultPage;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$resultRedirect->setPath('*');
return $resultRedirect;
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t configure the product right now.'));
$this->messageManager->addErrorMessage(__('We can\'t configure the product right now.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$resultRedirect->setPath('*');
return $resultRedirect;
Expand Down
8 changes: 5 additions & 3 deletions app/code/Magento/Wishlist/Controller/Index/Remove.php
Expand Up @@ -14,9 +14,11 @@
use Magento\Wishlist\Model\Product\AttributeValueProvider;

/**
* Wishlist Remove Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Remove extends \Magento\Wishlist\Controller\AbstractIndex
class Remove extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpPostActionInterface
{
/**
* @var WishlistProviderInterface
Expand Down Expand Up @@ -88,11 +90,11 @@ public function execute()
]
);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
__('We can\'t delete the item from Wish List right now because of an error: %1.', $e->getMessage())
);
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t delete the item from the Wish List right now.'));
$this->messageManager->addErrorMessage(__('We can\'t delete the item from the Wish List right now.'));
}

$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Wishlist/Controller/Index/Send.php
Expand Up @@ -219,7 +219,7 @@ public function execute()
}

if ($error) {
$this->messageManager->addError($error);
$this->messageManager->addErrorMessage($error);
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
$resultRedirect->setPath('*/*/share');
return $resultRedirect;
Expand Down Expand Up @@ -285,12 +285,12 @@ public function execute()
$this->inlineTranslation->resume();

$this->_eventManager->dispatch('wishlist_share', ['wishlist' => $wishlist]);
$this->messageManager->addSuccess(__('Your wish list has been shared.'));
$this->messageManager->addSuccessMessage(__('Your wish list has been shared.'));
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);
return $resultRedirect;
} catch (\Exception $e) {
$this->inlineTranslation->resume();
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
$resultRedirect->setPath('*/*/share');
return $resultRedirect;
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Wishlist/Controller/Index/Update.php
Expand Up @@ -103,7 +103,7 @@ public function execute()
$item->delete();
} catch (\Exception $e) {
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->messageManager->addError(__('We can\'t delete item from Wish List right now.'));
$this->messageManager->addErrorMessage(__('We can\'t delete item from Wish List right now.'));
}
}

Expand All @@ -118,7 +118,7 @@ public function execute()
);
$updatedItems++;
} catch (\Exception $e) {
$this->messageManager->addError(
$this->messageManager->addErrorMessage(
__(
'Can\'t save description %1',
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($description)
Expand All @@ -133,7 +133,7 @@ public function execute()
$wishlist->save();
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
} catch (\Exception $e) {
$this->messageManager->addError(__('Can\'t update wish list'));
$this->messageManager->addErrorMessage(__('Can\'t update wish list'));
}
}

Expand Down
12 changes: 7 additions & 5 deletions app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php
Expand Up @@ -14,9 +14,11 @@
use Magento\Wishlist\Controller\WishlistProviderInterface;

/**
* Wishlist UpdateItemOptions Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UpdateItemOptions extends \Magento\Wishlist\Controller\AbstractIndex
class UpdateItemOptions extends \Magento\Wishlist\Controller\AbstractIndex implements Action\HttpPostActionInterface
{
/**
* @var WishlistProviderInterface
Expand Down Expand Up @@ -85,7 +87,7 @@ public function execute()
}

if (!$product || !$product->isVisibleInCatalog()) {
$this->messageManager->addError(__('We can\'t specify a product.'));
$this->messageManager->addErrorMessage(__('We can\'t specify a product.'));
$resultRedirect->setPath('*/');
return $resultRedirect;
}
Expand Down Expand Up @@ -114,11 +116,11 @@ public function execute()
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();

$message = __('%1 has been updated in your Wish List.', $product->getName());
$this->messageManager->addSuccess($message);
$this->messageManager->addSuccessMessage($message);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t update your Wish List right now.'));
$this->messageManager->addErrorMessage(__('We can\'t update your Wish List right now.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
}
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);
Expand Down
13 changes: 8 additions & 5 deletions app/code/Magento/Wishlist/Controller/Shared/Cart.php
Expand Up @@ -9,6 +9,7 @@
use Magento\Checkout\Helper\Cart as CartHelper;
use Magento\Checkout\Model\Cart as CustomerCart;
use Magento\Framework\App\Action\Context as ActionContext;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Escaper;
use Magento\Framework\Exception\LocalizedException;
Expand All @@ -18,9 +19,11 @@
use Magento\Wishlist\Model\ResourceModel\Item\Option\Collection as OptionCollection;

/**
* Wishlist Cart Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Cart extends \Magento\Framework\App\Action\Action
class Cart extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface
{
/**
* @var CustomerCart
Expand Down Expand Up @@ -103,19 +106,19 @@ public function execute()
'You added %1 to your shopping cart.',
$this->escaper->escapeHtml($item->getProduct()->getName())
);
$this->messageManager->addSuccess($message);
$this->messageManager->addSuccessMessage($message);
}

if ($this->cartHelper->getShouldRedirectToCart()) {
$redirectUrl = $this->cartHelper->getCartUrl();
}
} catch (ProductException $e) {
$this->messageManager->addError(__('This product(s) is out of stock.'));
$this->messageManager->addErrorMessage(__('This product(s) is out of stock.'));
} catch (LocalizedException $e) {
$this->messageManager->addNotice($e->getMessage());
$this->messageManager->addNoticeMessage($e->getMessage());
$redirectUrl = $item->getProductUrl();
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t add the item to the cart right now.'));
$this->messageManager->addExceptionMessage($e, __('We can\'t add the item to the cart right now.'));
}
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
Expand Down
14 changes: 10 additions & 4 deletions app/code/Magento/Wishlist/Controller/WishlistProvider.php
@@ -1,13 +1,18 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Wishlist\Controller;

use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\RequestInterface;

/**
* WishlistProvider Controller
*
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class WishlistProvider implements WishlistProviderInterface
{
/**
Expand Down Expand Up @@ -54,7 +59,8 @@ public function __construct(
}

/**
* {@inheritdoc}
* @inheritdoc
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getWishlist($wishlistId = null)
Expand Down Expand Up @@ -85,10 +91,10 @@ public function getWishlist($wishlistId = null)
);
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
$this->messageManager->addError($e->getMessage());
$this->messageManager->addErrorMessage($e->getMessage());
return false;
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
$this->messageManager->addExceptionMessage($e, __('We can\'t create the Wish List right now.'));
return false;
}
$this->wishlist = $wishlist;
Expand Down
10 changes: 7 additions & 3 deletions app/code/Magento/Wishlist/Model/ItemCarrier.php
Expand Up @@ -10,6 +10,7 @@
use Magento\Checkout\Helper\Cart as CartHelper;
use Magento\Checkout\Model\Cart;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\App\Response\RedirectInterface;
use Magento\Framework\Exception\LocalizedException;
use Psr\Log\LoggerInterface as Logger;
Expand All @@ -18,7 +19,10 @@
use Magento\Wishlist\Helper\Data as WishlistHelper;

/**
* Wishlist ItemCarrier Controller
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
*/
class ItemCarrier
{
Expand Down Expand Up @@ -182,7 +186,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)

if ($messages) {
foreach ($messages as $message) {
$this->messageManager->addError($message);
$this->messageManager->addErrorMessage($message);
}
$redirectUrl = $indexUrl;
}
Expand All @@ -192,7 +196,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)
try {
$wishlist->save();
} catch (\Exception $e) {
$this->messageManager->addError(__('We can\'t update the Wish List right now.'));
$this->messageManager->addErrorMessage(__('We can\'t update the Wish List right now.'));
$redirectUrl = $indexUrl;
}

Expand All @@ -202,7 +206,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)
$products[] = '"' . $product->getName() . '"';
}

$this->messageManager->addSuccess(
$this->messageManager->addSuccessMessage(
__('%1 product(s) have been added to shopping cart: %2.', count($addedProducts), join(', ', $products))
);

Expand Down
Expand Up @@ -172,7 +172,7 @@ protected function setUp()

$this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
->disableOriginalConstructor()
->setMethods(['addSuccess'])
->setMethods(['addSuccessMessage'])
->getMockForAbstractClass();

$this->urlMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
Expand Down Expand Up @@ -566,7 +566,7 @@ protected function prepareExecuteWithQuantityArray($isAjax = false)
->willReturn($productName);

$this->messageManagerMock->expects($this->once())
->method('addSuccess')
->method('addSuccessMessage')
->with('You added ' . $productName . ' to your shopping cart.', null)
->willReturnSelf();

Expand All @@ -581,7 +581,7 @@ protected function prepareExecuteWithQuantityArray($isAjax = false)
$this->helperMock->expects($this->once())
->method('calculate')
->willReturnSelf();

return $refererUrl;
}

Expand Down
Expand Up @@ -244,7 +244,7 @@ public function testExecuteWithoutWishlist()
->method('create')
->with(\Magento\Wishlist\Model\Item::class)
->willReturn($item);

$this->wishlistProvider
->expects($this->once())
->method('getWishlist')
Expand Down Expand Up @@ -273,7 +273,7 @@ public function testExecuteCanNotSaveWishlist()

$this->messageManager
->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with('We can\'t delete the item from Wish List right now because of an error: Message.')
->willReturn(true);

Expand Down Expand Up @@ -356,7 +356,7 @@ public function testExecuteCanNotSaveWishlistAndWithRedirect()

$this->messageManager
->expects($this->once())
->method('addError')
->method('addErrorMessage')
->with('We can\'t delete the item from the Wish List right now.')
->willReturn(true);

Expand Down

0 comments on commit 17740d7

Please sign in to comment.