Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Replacing deprecated methods for tests. #17872

Merged
merged 7 commits into from
Sep 6, 2018
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ protected function setUp()
false,
true,
true,
['addSuccess', 'getMessages']
['addSuccessMessage', 'getMessages']
);

$this->save = $this->objectManager->getObject(
Expand Down Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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/*/');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/*/');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(
Expand All @@ -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');
}
}
Expand Down