From d4b5e99daa10a83de61105ea87216b42d17f9d8a Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Sat, 18 Aug 2018 22:46:40 -0300 Subject: [PATCH 01/27] Replacing deprecated methods from Magento_Backend module. --- .../Backend/App/Action/Plugin/Authentication.php | 4 ++-- .../Backend/Controller/Adminhtml/Auth/Logout.php | 2 +- .../Backend/Controller/Adminhtml/Cache/CleanImages.php | 6 +++--- .../Backend/Controller/Adminhtml/Cache/CleanMedia.php | 6 +++--- .../Controller/Adminhtml/Cache/CleanStaticFiles.php | 2 +- .../Backend/Controller/Adminhtml/Cache/FlushAll.php | 2 +- .../Backend/Controller/Adminhtml/Cache/FlushSystem.php | 2 +- .../Backend/Controller/Adminhtml/Cache/MassDisable.php | 6 +++--- .../Backend/Controller/Adminhtml/Cache/MassEnable.php | 6 +++--- .../Backend/Controller/Adminhtml/Cache/MassRefresh.php | 6 +++--- .../Adminhtml/Dashboard/RefreshStatistics.php | 4 ++-- .../Controller/Adminhtml/System/Account/Save.php | 10 +++++----- .../Controller/Adminhtml/System/Design/Delete.php | 6 +++--- .../Controller/Adminhtml/System/Design/Save.php | 4 ++-- .../Backend/Controller/Adminhtml/System/Store.php | 8 ++++---- .../Controller/Adminhtml/System/Store/DeleteGroup.php | 4 ++-- .../Adminhtml/System/Store/DeleteGroupPost.php | 10 +++++----- .../Controller/Adminhtml/System/Store/DeleteStore.php | 4 ++-- .../Adminhtml/System/Store/DeleteStorePost.php | 10 +++++----- .../Adminhtml/System/Store/DeleteWebsite.php | 4 ++-- .../Adminhtml/System/Store/DeleteWebsitePost.php | 10 +++++----- .../Controller/Adminhtml/System/Store/EditStore.php | 4 ++-- .../Backend/Controller/Adminhtml/System/Store/Save.php | 10 +++++----- .../Unit/Controller/Adminhtml/Cache/CleanMediaTest.php | 4 ++-- .../Adminhtml/Cache/CleanStaticFilesTest.php | 2 +- .../Controller/Adminhtml/Cache/MassDisableTest.php | 6 +++--- .../Unit/Controller/Adminhtml/Cache/MassEnableTest.php | 6 +++--- .../Adminhtml/Dashboard/RefreshStatisticsTest.php | 2 +- .../Controller/Adminhtml/System/Account/SaveTest.php | 4 ++-- 29 files changed, 77 insertions(+), 77 deletions(-) diff --git a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php index 68506a521c1cf..4b25e9921e404 100644 --- a/app/code/Magento/Backend/App/Action/Plugin/Authentication.php +++ b/app/code/Magento/Backend/App/Action/Plugin/Authentication.php @@ -160,7 +160,7 @@ protected function _processNotLoggedInUser(\Magento\Framework\App\RequestInterfa } else { $this->_actionFlag->set('', \Magento\Framework\App\ActionInterface::FLAG_NO_DISPATCH, true); $this->_response->setRedirect($this->_url->getCurrentUrl()); - $this->messageManager->addError(__('Invalid Form Key. Please refresh the page.')); + $this->messageManager->addErrorMessage(__('Invalid Form Key. Please refresh the page.')); $isRedirectNeeded = true; } } @@ -205,7 +205,7 @@ protected function _performLogin(\Magento\Framework\App\RequestInterface $reques $this->_auth->login($username, $password); } catch (AuthenticationException $e) { if (!$request->getParam('messageSent')) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $request->setParam('messageSent', true); $outputValue = false; } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Auth/Logout.php b/app/code/Magento/Backend/Controller/Adminhtml/Auth/Logout.php index 41e32c929287a..e55c449a0e5bb 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Auth/Logout.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Auth/Logout.php @@ -16,7 +16,7 @@ class Logout extends \Magento\Backend\Controller\Adminhtml\Auth public function execute() { $this->_auth->logout(); - $this->messageManager->addSuccess(__('You have logged out.')); + $this->messageManager->addSuccessMessage(__('You have logged out.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php index 7a926b1c09c3e..888ce11313b8a 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanImages.php @@ -28,11 +28,11 @@ public function execute() try { $this->_objectManager->create(\Magento\Catalog\Model\Product\Image::class)->clearCache(); $this->_eventManager->dispatch('clean_catalog_images_cache_after'); - $this->messageManager->addSuccess(__('The image cache was cleaned.')); + $this->messageManager->addSuccessMessage(__('The image cache was cleaned.')); } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('An error occurred while clearing the image cache.')); + $this->messageManager->addExceptionMessage($e, __('An error occurred while clearing the image cache.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php index 72f23ab65cf8a..30aeb038ff9c2 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanMedia.php @@ -28,11 +28,11 @@ public function execute() try { $this->_objectManager->get(\Magento\Framework\View\Asset\MergeService::class)->cleanMergedJsCss(); $this->_eventManager->dispatch('clean_media_cache_after'); - $this->messageManager->addSuccess(__('The JavaScript/CSS cache has been cleaned.')); + $this->messageManager->addSuccessMessage(__('The JavaScript/CSS cache has been cleaned.')); } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('An error occurred while clearing the JavaScript/CSS cache.')); + $this->messageManager->addExceptionMessage($e, __('An error occurred while clearing the JavaScript/CSS cache.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php index 27ae2fc31e150..489eb5799a5e7 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/CleanStaticFiles.php @@ -26,7 +26,7 @@ public function execute() { $this->_objectManager->get(\Magento\Framework\App\State\CleanupFiles::class)->clearMaterializedViewFiles(); $this->_eventManager->dispatch('clean_static_files_cache_after'); - $this->messageManager->addSuccess(__('The static files cache has been cleaned.')); + $this->messageManager->addSuccessMessage(__('The static files cache has been cleaned.')); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php index ca89ea58fa6f3..a2f18b4baf53d 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushAll.php @@ -27,7 +27,7 @@ public function execute() foreach ($this->_cacheFrontendPool as $cacheFrontend) { $cacheFrontend->getBackend()->clean(); } - $this->messageManager->addSuccess(__("You flushed the cache storage.")); + $this->messageManager->addSuccessMessage(__("You flushed the cache storage.")); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('adminhtml/*'); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php index f0fed159e0f22..90ed3432fa87b 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/FlushSystem.php @@ -27,7 +27,7 @@ public function execute() $cacheFrontend->clean(); } $this->_eventManager->dispatch('adminhtml_cache_flush_system'); - $this->messageManager->addSuccess(__("The Magento cache storage has been flushed.")); + $this->messageManager->addSuccessMessage(__("The Magento cache storage has been flushed.")); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('adminhtml/*'); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php index 2bfa937b06b77..03b88ca1d3f47 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassDisable.php @@ -67,12 +67,12 @@ private function disableCache() } if ($updatedTypes > 0) { $this->_cacheState->persist(); - $this->messageManager->addSuccess(__("%1 cache type(s) disabled.", $updatedTypes)); + $this->messageManager->addSuccessMessage(__("%1 cache type(s) disabled.", $updatedTypes)); } } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('An error occurred while disabling cache.')); + $this->messageManager->addExceptionMessage($e, __('An error occurred while disabling cache.')); } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php index 113e0f2d8961b..1b98a00d4bf35 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassEnable.php @@ -66,12 +66,12 @@ private function enableCache() } if ($updatedTypes > 0) { $this->_cacheState->persist(); - $this->messageManager->addSuccess(__("%1 cache type(s) enabled.", $updatedTypes)); + $this->messageManager->addSuccessMessage(__("%1 cache type(s) enabled.", $updatedTypes)); } } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('An error occurred while enabling cache.')); + $this->messageManager->addExceptionMessage($e, __('An error occurred while enabling cache.')); } } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php index 3843b030afb3d..bde211debcf72 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Cache/MassRefresh.php @@ -37,12 +37,12 @@ public function execute() $updatedTypes++; } if ($updatedTypes > 0) { - $this->messageManager->addSuccess(__("%1 cache type(s) refreshed.", $updatedTypes)); + $this->messageManager->addSuccessMessage(__("%1 cache type(s) refreshed.", $updatedTypes)); } } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('An error occurred while refreshing cache.')); + $this->messageManager->addExceptionMessage($e, __('An error occurred while refreshing cache.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php b/app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php index f831fa67f4bb0..c10d1a77997b7 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/Dashboard/RefreshStatistics.php @@ -34,9 +34,9 @@ public function execute() foreach ($collectionsNames as $collectionName) { $this->_objectManager->create($collectionName)->aggregate(); } - $this->messageManager->addSuccess(__('We updated lifetime statistic.')); + $this->messageManager->addSuccessMessage(__('We updated lifetime statistic.')); } catch (\Exception $e) { - $this->messageManager->addError(__('We can\'t refresh lifetime statistics.')); + $this->messageManager->addErrorMessage(__('We can\'t refresh lifetime statistics.')); $this->logger->critical($e); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php index 1b10c151a9d21..d95b0541c2c76 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Account/Save.php @@ -76,12 +76,12 @@ public function execute() $errors = $user->validate(); if ($errors !== true && !empty($errors)) { foreach ($errors as $error) { - $this->messageManager->addError($error); + $this->messageManager->addErrorMessage($error); } } else { $user->save(); $user->sendNotificationEmailsIfRequired(); - $this->messageManager->addSuccess(__('You saved the account.')); + $this->messageManager->addSuccessMessage(__('You saved the account.')); } } catch (UserLockedException $e) { $this->_auth->logout(); @@ -91,12 +91,12 @@ public function execute() } catch (ValidatorException $e) { $this->messageManager->addMessages($e->getMessages()); if ($e->getMessage()) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } } catch (LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addError(__('An error occurred while saving account.')); + $this->messageManager->addErrorMessage(__('An error occurred while saving account.')); } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Delete.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Delete.php index 76402169f269e..21f28188cf874 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Delete.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Delete.php @@ -19,11 +19,11 @@ public function execute() try { $design->delete(); - $this->messageManager->addSuccess(__('You deleted the design change.')); + $this->messageManager->addSuccessMessage(__('You deleted the design change.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __("You can't delete the design change.")); + $this->messageManager->addExceptionMessage($e, __("You can't delete the design change.")); } } /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Save.php index 1f478604ced7d..0228b48f7f11e 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Design/Save.php @@ -50,9 +50,9 @@ public function execute() try { $design->save(); $this->_eventManager->dispatch('theme_save_after'); - $this->messageManager->addSuccess(__('You saved the design change.')); + $this->messageManager->addSuccessMessage(__('You saved the design change.')); } catch (\Exception $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setDesignData($data); return $resultRedirect->setPath('adminhtml/*/', ['id' => $design->getId()]); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php index 4fbae6abb423a..0beeb5168b6d1 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store.php @@ -103,12 +103,12 @@ protected function _backupDatabase() ->setType('db') ->setPath($filesystem->getDirectoryRead(DirectoryList::VAR_DIR)->getAbsolutePath('backups')); $backupDb->createBackup($backup); - $this->messageManager->addSuccess(__('The database was backed up.')); + $this->messageManager->addSuccessMessage(__('The database was backed up.')); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); return false; } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __('We can\'t create a backup right now. Please try again later.') ); @@ -125,7 +125,7 @@ protected function _backupDatabase() */ protected function _addDeletionNotice($typeTitle) { - $this->messageManager->addNotice( + $this->messageManager->addNoticeMessage( __( 'Deleting a %1 will not delete the information associated with the %1 (e.g. categories, products, etc.)' . ', but the %1 will not be able to be restored. It is suggested that you create a database backup ' diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroup.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroup.php index 925ae4c69ee8e..4e323be709ae1 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroup.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroup.php @@ -15,13 +15,13 @@ public function execute() { $itemId = $this->getRequest()->getParam('item_id', null); if (!($model = $this->_objectManager->create(\Magento\Store\Model\Group::class)->load($itemId))) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This store cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This store cannot be deleted.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $itemId]); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php index b6fbd88c7669c..23364aac1f0ab 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteGroupPost.php @@ -21,11 +21,11 @@ public function execute() $redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if (!($model = $this->_objectManager->create(\Magento\Store\Model\Group::class)->load($itemId))) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This store cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This store cannot be deleted.')); return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $model->getId()]); } @@ -35,12 +35,12 @@ public function execute() try { $model->delete(); - $this->messageManager->addSuccess(__('You deleted the store.')); + $this->messageManager->addSuccessMessage(__('You deleted the store.')); return $redirectResult->setPath('adminhtml/*/'); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('Unable to delete the store. Please try again later.')); + $this->messageManager->addExceptionMessage($e, __('Unable to delete the store. Please try again later.')); } return $redirectResult->setPath('adminhtml/*/editGroup', ['group_id' => $itemId]); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStore.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStore.php index b31de6cacc5ff..c340b1ec53aa5 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStore.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStore.php @@ -15,13 +15,13 @@ public function execute() { $itemId = $this->getRequest()->getParam('item_id', null); if (!($model = $this->_objectManager->create(\Magento\Store\Model\Store::class)->load($itemId))) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This store view cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This store view cannot be deleted.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $itemId]); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php index 13b104c5ec4c0..518e5e1d549a3 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteStorePost.php @@ -22,11 +22,11 @@ public function execute() /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if (!($model = $this->_objectManager->create(\Magento\Store\Model\Store::class)->load($itemId))) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This store view cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This store view cannot be deleted.')); return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $model->getId()]); } @@ -37,12 +37,12 @@ public function execute() try { $model->delete(); - $this->messageManager->addSuccess(__('You deleted the store view.')); + $this->messageManager->addSuccessMessage(__('You deleted the store view.')); return $redirectResult->setPath('adminhtml/*/'); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('Unable to delete the store view. Please try again later.')); + $this->messageManager->addExceptionMessage($e, __('Unable to delete the store view. Please try again later.')); } return $redirectResult->setPath('adminhtml/*/editStore', ['store_id' => $itemId]); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsite.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsite.php index 1f2ec4b2ba4b1..d86f57daa396c 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsite.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsite.php @@ -15,13 +15,13 @@ public function execute() { $itemId = $this->getRequest()->getParam('item_id', null); if (!($model = $this->_objectManager->create(\Magento\Store\Model\Website::class)->load($itemId))) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This website cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This website cannot be deleted.')); /** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */ $redirectResult = $this->resultRedirectFactory->create(); return $redirectResult->setPath('adminhtml/*/editWebsite', ['website_id' => $itemId]); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsitePost.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsitePost.php index c2d24b8c41a8c..1fca5a896e050 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsitePost.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/DeleteWebsitePost.php @@ -23,11 +23,11 @@ public function execute() $redirectResult = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); if (!$model) { - $this->messageManager->addError(__('Something went wrong. Please try again.')); + $this->messageManager->addErrorMessage(__('Something went wrong. Please try again.')); return $redirectResult->setPath('adminhtml/*/'); } if (!$model->isCanDelete()) { - $this->messageManager->addError(__('This website cannot be deleted.')); + $this->messageManager->addErrorMessage(__('This website cannot be deleted.')); return $redirectResult->setPath('adminhtml/*/editWebsite', ['website_id' => $model->getId()]); } @@ -37,12 +37,12 @@ public function execute() try { $model->delete(); - $this->messageManager->addSuccess(__('You deleted the website.')); + $this->messageManager->addSuccessMessage(__('You deleted the website.')); return $redirectResult->setPath('adminhtml/*/'); } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); } catch (\Exception $e) { - $this->messageManager->addException($e, __('Unable to delete the website. Please try again later.')); + $this->messageManager->addExceptionMessage($e, __('Unable to delete the website. Please try again later.')); } return $redirectResult->setPath('*/*/editWebsite', ['website_id' => $itemId]); } diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/EditStore.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/EditStore.php index cbc068a480865..a8651984cfa63 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/EditStore.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/EditStore.php @@ -57,7 +57,7 @@ public function execute() if ($model->getId() || $this->_coreRegistry->registry('store_action') == 'add') { $this->_coreRegistry->register('store_data', $model); if ($this->_coreRegistry->registry('store_action') == 'edit' && $codeBase && !$model->isReadOnly()) { - $this->messageManager->addNotice($codeBase); + $this->messageManager->addNoticeMessage($codeBase); } $resultPage = $this->createPage(); if ($this->_coreRegistry->registry('store_action') == 'add') { @@ -71,7 +71,7 @@ public function execute() )); return $resultPage; } else { - $this->messageManager->addError($notExists); + $this->messageManager->addErrorMessage($notExists); /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); return $resultRedirect->setPath('adminhtml/*/'); diff --git a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php index 8ca783f887ec4..910511c2b275e 100644 --- a/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php +++ b/app/code/Magento/Backend/Controller/Adminhtml/System/Store/Save.php @@ -32,7 +32,7 @@ private function processWebsiteSave($postData) } $websiteModel->save(); - $this->messageManager->addSuccess(__('You saved the website.')); + $this->messageManager->addSuccessMessage(__('You saved the website.')); return $postData; } @@ -68,7 +68,7 @@ private function processStoreSave($postData) ); } $storeModel->save(); - $this->messageManager->addSuccess(__('You saved the store view.')); + $this->messageManager->addSuccessMessage(__('You saved the store view.')); return $postData; } @@ -98,7 +98,7 @@ private function processGroupSave($postData) ); } $groupModel->save(); - $this->messageManager->addSuccess(__('You saved the store.')); + $this->messageManager->addSuccessMessage(__('You saved the store.')); return $postData; } @@ -134,10 +134,10 @@ public function execute() $redirectResult->setPath('adminhtml/*/'); return $redirectResult; } catch (\Magento\Framework\Exception\LocalizedException $e) { - $this->messageManager->addError($e->getMessage()); + $this->messageManager->addErrorMessage($e->getMessage()); $this->_getSession()->setPostData($postData); } catch (\Exception $e) { - $this->messageManager->addException( + $this->messageManager->addExceptionMessage( $e, __('Something went wrong while saving. Please review the error log.') ); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php index b1911da024227..ac0f4a2f467c8 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanMediaTest.php @@ -38,7 +38,7 @@ public function testExecute() $messageManagerParams = $helper->getConstructArguments(\Magento\Framework\Message\Manager::class); $messageManagerParams['exceptionMessageFactory'] = $exceptionMessageFactory; $messageManager = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) - ->setMethods(['addSuccess']) + ->setMethods(['addSuccessMessage']) ->setConstructorArgs($messageManagerParams) ->getMock(); @@ -86,7 +86,7 @@ public function testExecute() $mergeService->expects($this->once())->method('cleanMergedJsCss'); $messageManager->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with('The JavaScript/CSS cache has been cleaned.'); $valueMap = [ diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php index 40d9ca1aa8996..fc457cd9681e6 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/CleanStaticFilesTest.php @@ -76,7 +76,7 @@ public function testExecute() ->with('clean_static_files_cache_after'); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with('The static files cache has been cleaned.'); $resultRedirect = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class) diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php index 197b46acc61bc..a8b248c611e07 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassDisableTest.php @@ -156,7 +156,7 @@ public function testExecuteInvalidTypeCache() ->willReturn(['someCache']); $this->messageManagerMock->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with('These cache type(s) don\'t exist: someCache') ->willReturnSelf(); @@ -176,7 +176,7 @@ public function testExecuteWithException() ->willThrowException($exception); $this->messageManagerMock->expects($this->once()) - ->method('addException') + ->method('addExceptionMessage') ->with($exception, 'An error occurred while disabling cache.') ->willReturnSelf(); @@ -216,7 +216,7 @@ public function testExecuteSuccess() ->method('persist'); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with('1 cache type(s) disabled.') ->willReturnSelf(); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php index 9b3640193154a..6eac44a564f6d 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Cache/MassEnableTest.php @@ -156,7 +156,7 @@ public function testExecuteInvalidTypeCache() ->willReturn(['someCache']); $this->messageManagerMock->expects($this->once()) - ->method('addError') + ->method('addErrorMessage') ->with('These cache type(s) don\'t exist: someCache') ->willReturnSelf(); @@ -176,7 +176,7 @@ public function testExecuteWithException() ->willThrowException($exception); $this->messageManagerMock->expects($this->once()) - ->method('addException') + ->method('addExceptionMessage') ->with($exception, 'An error occurred while enabling cache.') ->willReturnSelf(); @@ -216,7 +216,7 @@ public function testExecuteSuccess() ->method('persist'); $this->messageManagerMock->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with('1 cache type(s) enabled.') ->willReturnSelf(); diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php index e8dcc00345fc6..a985681919f0b 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/Dashboard/RefreshStatisticsTest.php @@ -107,7 +107,7 @@ public function testExecute() $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); $this->messageManager->expects($this->once()) - ->method('addSuccess') + ->method('addSuccessMessage') ->with(__('We updated lifetime statistic.')); $this->objectManager->expects($this->any()) diff --git a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php index 844a821df1c20..a8490d6ba2e58 100644 --- a/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php +++ b/app/code/Magento/Backend/Test/Unit/Controller/Adminhtml/System/Account/SaveTest.php @@ -71,7 +71,7 @@ protected function setUp() ->getMock(); $this->_messagesMock = $this->getMockBuilder(\Magento\Framework\Message\Manager::class) ->disableOriginalConstructor() - ->setMethods(['addSuccess']) + ->setMethods(['addSuccessMessage']) ->getMockForAbstractClass(); $this->_authSessionMock = $this->getMockBuilder(\Magento\Backend\Model\Auth\Session::class) @@ -221,7 +221,7 @@ public function testSaveAction() $this->_requestMock->setParams($requestParams); - $this->_messagesMock->expects($this->once())->method('addSuccess')->with($this->equalTo($testedMessage)); + $this->_messagesMock->expects($this->once())->method('addSuccessMessage')->with($this->equalTo($testedMessage)); $this->_controller->execute(); } From b31a9cf194ae8d14630a3cd4753816811ec7c206 Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Sat, 18 Aug 2018 23:00:06 -0300 Subject: [PATCH 02/27] Replacing type in method name. --- app/code/Magento/Wishlist/Block/AbstractBlock.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/code/Magento/Wishlist/Block/AbstractBlock.php b/app/code/Magento/Wishlist/Block/AbstractBlock.php index 8b4a8df1bf99f..bb8138fb87a3e 100644 --- a/app/code/Magento/Wishlist/Block/AbstractBlock.php +++ b/app/code/Magento/Wishlist/Block/AbstractBlock.php @@ -231,9 +231,21 @@ public function hasDescription($item) * Retrieve formated Date * * @param string $date + * @deprecated * @return string */ public function getFormatedDate($date) + { + return $this->getFormattedDate($date); + } + + /** + * Retrieve formatted Date + * + * @param string $date + * @return string + */ + public function getFormattedDate($date) { return $this->formatDate($date, \IntlDateFormatter::MEDIUM); } From e4ac4a0fe9eab9f7b0e333e18d51699154df8120 Mon Sep 17 00:00:00 2001 From: Tiago Sampaio Date: Sat, 18 Aug 2018 23:05:44 -0300 Subject: [PATCH 03/27] Fixing typo in method name for Magento_Paypal method. --- app/code/Magento/Paypal/Model/AbstractConfig.php | 13 ++++++++++++- app/code/Magento/Paypal/Model/Config.php | 2 +- .../Paypal/Test/Unit/Model/AbstractConfigTest.php | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Paypal/Model/AbstractConfig.php b/app/code/Magento/Paypal/Model/AbstractConfig.php index 3b0f7b974829c..8d002a670a435 100644 --- a/app/code/Magento/Paypal/Model/AbstractConfig.php +++ b/app/code/Magento/Paypal/Model/AbstractConfig.php @@ -224,15 +224,26 @@ protected function _prepareValue($key, $value) */ public function shouldUseUnilateralPayments() { - return $this->getValue('business_account') && !$this->isWppApiAvailabe(); + return $this->getValue('business_account') && !$this->isWppApiAvailable(); } /** * Check whether WPP API credentials are available for this method * + * @deprecated * @return bool */ public function isWppApiAvailabe() + { + return $this->isWppApiAvailable(); + } + + /** + * Check whether WPP API credentials are available for this method + * + * @return bool + */ + public function isWppApiAvailable() { return $this->getValue('api_username') && $this->getValue('api_password') diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index 34e40ac7509d6..c16b3025e382a 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -677,7 +677,7 @@ public function isMethodAvailable($methodCode = null) } break; case self::METHOD_BILLING_AGREEMENT: - $result = $this->isWppApiAvailabe(); + $result = $this->isWppApiAvailable(); break; } return $result; diff --git a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php index 9ec9318212614..78bd269403b83 100644 --- a/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php +++ b/app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php @@ -189,14 +189,14 @@ public function getValueDataProvider() * * @dataProvider isWppApiAvailabeDataProvider */ - public function testIsWppApiAvailabe($returnMap, $expectedValue) + public function testIsWppApiAvailable($returnMap, $expectedValue) { $this->config->setMethod('paypal_express'); $this->scopeConfigMock->expects($this->any()) ->method('getValue') ->willReturnMap($returnMap); - $this->assertEquals($expectedValue, $this->config->isWppApiAvailabe()); + $this->assertEquals($expectedValue, $this->config->isWppApiAvailable()); } /** From 3b9e96360e71b5d38167068b2b1a069ca97dc672 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 11 Sep 2018 16:24:40 +0300 Subject: [PATCH 04/27] ISSUE-18009: [Forwardport] Cannot create a numeric value attribute option using the REST API. --- .../Magento/Eav/Model/Entity/Attribute/OptionManagement.php | 2 +- .../Api/ProductAttributeOptionManagementInterfaceTest.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php index a2c9611d26f5d..8cb8687cd1f1f 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php @@ -153,7 +153,7 @@ protected function validateOption($attribute, $optionId) */ private function getOptionId(\Magento\Eav\Api\Data\AttributeOptionInterface $option) : string { - return $option->getValue() ?: 'new_option'; + return 'id_' . ($option->getValue() ?: 'new_option'); } /** diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php index f9442d8b6499a..1d37ea9a2fc6d 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeOptionManagementInterfaceTest.php @@ -111,6 +111,9 @@ public function addDataProvider() 'option_with_value_node_that_starts_with_a_number' => [ array_merge($optionPayload, [AttributeOptionInterface::VALUE => '123_some_text']) ], + 'option_with_value_node_that_is_a_number' => [ + array_merge($optionPayload, [AttributeOptionInterface::VALUE => '123']) + ], ]; } From e74648058a77dd687eb73c73db6a44a8dcac5eba Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 23 Jun 2018 01:04:33 +0200 Subject: [PATCH 05/27] Fix setting billing address twice. Instead, set shipping address also. Additionally, improve code style slightly. --- .../testsuite/Magento/Sales/_files/order_list.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php index 43e98419798a8..23283e53e4202 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php @@ -8,10 +8,10 @@ require 'order.php'; /** @var Order $order */ -/** @var Order\Payment $payment */ -/** @var Order\Item $orderItem */ -/** @var Order\Address $billingAddress */ -/** @var Order\Address $shippingAddress */ +/** @var Order\Payment $payment */ +/** @var Order\Item $orderItem */ +/** @var Order\Address $billingAddress */ +/** @var Order\Address $shippingAddress */ $orders = [ [ 'increment_id' => '100000002', @@ -58,6 +58,6 @@ ->setData($orderData) ->addItem($orderItem) ->setBillingAddress($billingAddress) - ->setBillingAddress($shippingAddress) + ->setShippingAddress($shippingAddress) ->save(); } From 1481591bbe04db3f262362b7ff386d522c8ad494 Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 23 Jun 2018 09:25:33 +0200 Subject: [PATCH 06/27] Reset addresses for each order. Otherwise they cannot be accessed. --- .../testsuite/Magento/Sales/_files/order_list.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php index 23283e53e4202..f841658e3242c 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php @@ -54,6 +54,14 @@ $order = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create( \Magento\Sales\Model\Order::class ); + + // Reset addresses + $billingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); + $billingAddress->setAddressType('billing'); + + $shippingAddress = clone $billingAddress; + $shippingAddress->setId(null)->setAddressType('shipping'); + $order ->setData($orderData) ->addItem($orderItem) From cb578e741103483a068cd16e8a7bcfbc11dcb16e Mon Sep 17 00:00:00 2001 From: vagrant Date: Sat, 23 Jun 2018 09:33:35 +0200 Subject: [PATCH 07/27] Improve var tags. --- .../testsuite/Magento/Sales/_files/order_list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php index f841658e3242c..2789c8040f353 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php @@ -10,8 +10,7 @@ /** @var Order $order */ /** @var Order\Payment $payment */ /** @var Order\Item $orderItem */ -/** @var Order\Address $billingAddress */ -/** @var Order\Address $shippingAddress */ +/** @var array $addressData Data for creating addresses for the orders. */ $orders = [ [ 'increment_id' => '100000002', @@ -56,9 +55,11 @@ ); // Reset addresses + /** @var Order\Address $billingAddress */ $billingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); $billingAddress->setAddressType('billing'); + /** @var Order\Address $shippingAddress */ $shippingAddress = clone $billingAddress; $shippingAddress->setId(null)->setAddressType('shipping'); From d4d23fd42adfec7c39e51d698fffa55a060b68c6 Mon Sep 17 00:00:00 2001 From: Volodymyr Hryvinskyi Date: Wed, 19 Sep 2018 00:08:44 +0300 Subject: [PATCH 08/27] Update db schema comments --- app/code/Magento/Bundle/etc/db_schema.xml | 38 +++---- app/code/Magento/Catalog/etc/db_schema.xml | 33 +++--- .../Magento/CatalogRule/etc/db_schema.xml | 8 +- app/code/Magento/Cms/etc/db_schema.xml | 7 +- app/code/Magento/Customer/etc/db_schema.xml | 64 +++++------ app/code/Magento/Eav/etc/db_schema.xml | 14 +-- .../Magento/Integration/etc/db_schema.xml | 2 +- .../NewRelicReporting/etc/db_schema.xml | 10 +- app/code/Magento/Paypal/etc/db_schema.xml | 2 +- app/code/Magento/Quote/etc/db_schema.xml | 4 +- app/code/Magento/Review/etc/db_schema.xml | 12 +- app/code/Magento/Sales/etc/db_schema.xml | 104 +++++++++--------- app/code/Magento/SalesRule/etc/db_schema.xml | 11 +- app/code/Magento/Signifyd/etc/db_schema.xml | 3 +- app/code/Magento/Vault/etc/db_schema.xml | 2 +- app/code/Magento/Weee/etc/db_schema.xml | 2 +- 16 files changed, 162 insertions(+), 154 deletions(-) diff --git a/app/code/Magento/Bundle/etc/db_schema.xml b/app/code/Magento/Bundle/etc/db_schema.xml index 8092f34c533fa..f1c1e7ae782dc 100644 --- a/app/code/Magento/Bundle/etc/db_schema.xml +++ b/app/code/Magento/Bundle/etc/db_schema.xml @@ -120,11 +120,11 @@ + comment="Entity ID"/> + comment="Customer Group ID"/> + comment="Entity ID"/> + comment="Website ID"/> + comment="Stock ID"/> + comment="Entity ID"/> + comment="Website ID"/> + default="0" comment="Tax Class ID"/> + comment="Entity ID"/> + comment="Website ID"/> + default="0" comment="Tax Class ID"/> + comment="Entity ID"/> + comment="Website ID"/> + comment="Entity ID"/> + comment="Website ID"/> + comment="Entity ID"/> + comment="Website ID"/> + comment="Entity ID"/> + comment="Website ID"/>
+ comment="Entity ID"/> @@ -41,7 +41,7 @@ + default="0" comment="Entity ID"/> @@ -76,7 +76,7 @@ + default="0" comment="Entity ID"/> @@ -112,7 +112,7 @@ + default="0" comment="Entity ID"/> @@ -148,7 +148,7 @@ + default="0" comment="Entity ID"/> @@ -183,7 +183,7 @@ + default="0" comment="Entity ID"/> @@ -218,7 +218,7 @@ + default="0" comment="Entity ID"/> @@ -251,7 +251,7 @@
+ comment="Entity ID"/> + default="0" comment="Entity ID"/> @@ -324,7 +324,7 @@ + default="0" comment="Entity ID"/> @@ -363,7 +363,7 @@ + default="0" comment="Entity ID"/> @@ -402,7 +402,7 @@ + default="0" comment="Entity ID"/> @@ -440,7 +440,7 @@ + default="0" comment="Entity ID"/> @@ -738,7 +738,7 @@ + default="0" comment="Entity ID"/> + default="0" comment="Entity ID"/> @@ -1651,7 +1651,8 @@ comment="Link Media value to Product entity table"> - +
+ comment="Entity ID"/> @@ -137,7 +137,8 @@
- + @@ -156,7 +157,8 @@
- + diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml index 2b825544f56f1..3f97a94d54943 100644 --- a/app/code/Magento/Cms/etc/db_schema.xml +++ b/app/code/Magento/Cms/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
+ comment="Entity ID"/> @@ -46,7 +46,7 @@
+ comment="Entity ID"/> @@ -86,7 +86,8 @@
- + diff --git a/app/code/Magento/Customer/etc/db_schema.xml b/app/code/Magento/Customer/etc/db_schema.xml index 368ca417432fd..657083b58e1b1 100644 --- a/app/code/Magento/Customer/etc/db_schema.xml +++ b/app/code/Magento/Customer/etc/db_schema.xml @@ -9,15 +9,15 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
+ comment="Entity ID"/> + comment="Website ID"/> + default="0" comment="Group ID"/> + default="0" comment="Store ID"/>
+ comment="Entity ID"/> + comment="Parent ID"/> + default="0" comment="Entity ID"/> @@ -159,7 +159,7 @@ + default="0" comment="Entity ID"/> @@ -186,11 +186,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -218,11 +218,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -244,11 +244,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -274,11 +274,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -304,11 +304,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -335,11 +335,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -366,11 +366,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> @@ -391,11 +391,11 @@
+ comment="Value ID"/> + default="0" comment="Attribute ID"/> + default="0" comment="Entity ID"/> diff --git a/app/code/Magento/Eav/etc/db_schema.xml b/app/code/Magento/Eav/etc/db_schema.xml index f930321e5259b..e81fad5ebded8 100644 --- a/app/code/Magento/Eav/etc/db_schema.xml +++ b/app/code/Magento/Eav/etc/db_schema.xml @@ -15,7 +15,7 @@ - +
+ comment="Entity ID"/> + default="0" comment="Entity ID"/> @@ -123,7 +123,7 @@ + default="0" comment="Entity ID"/> @@ -164,7 +164,7 @@ + default="0" comment="Entity ID"/> @@ -204,7 +204,7 @@ + default="0" comment="Entity ID"/> @@ -241,7 +241,7 @@ + default="0" comment="Entity ID"/> diff --git a/app/code/Magento/Integration/etc/db_schema.xml b/app/code/Magento/Integration/etc/db_schema.xml index 9e81b867d36d5..33173df4f6c0b 100644 --- a/app/code/Magento/Integration/etc/db_schema.xml +++ b/app/code/Magento/Integration/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
+ comment="Entity ID"/> + comment="Entity ID"/> @@ -35,9 +35,9 @@
+ comment="Entity ID"/> + comment="Customer ID"/>
+ comment="Entity ID"/>
+ comment="Entity ID"/> + comment="Entity ID"/> diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml index 3bd7122e65d7f..725825e976ad7 100644 --- a/app/code/Magento/Quote/etc/db_schema.xml +++ b/app/code/Magento/Quote/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
+ comment="Entity ID"/>
+ comment="Entity ID"/> diff --git a/app/code/Magento/Review/etc/db_schema.xml b/app/code/Magento/Review/etc/db_schema.xml index 1a2ff588180ce..2ae43ea608eca 100644 --- a/app/code/Magento/Review/etc/db_schema.xml +++ b/app/code/Magento/Review/etc/db_schema.xml @@ -95,7 +95,7 @@ + default="0" comment="Store ID"/> @@ -108,9 +108,9 @@
+ comment="Review ID"/> + comment="Store ID"/> @@ -125,7 +125,7 @@
+ comment="Entity ID"/> @@ -136,9 +136,9 @@
+ comment="Rating ID"/> + default="0" comment="Entity ID"/> diff --git a/app/code/Magento/Sales/etc/db_schema.xml b/app/code/Magento/Sales/etc/db_schema.xml index 4b716e761094c..fda6e75cf00c6 100644 --- a/app/code/Magento/Sales/etc/db_schema.xml +++ b/app/code/Magento/Sales/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
+ comment="Entity ID"/> @@ -297,13 +297,13 @@
+ comment="Entity ID"/> + comment="Store ID"/> + comment="Customer ID"/>
+ comment="Entity ID"/> + comment="Parent ID"/> + comment="Customer Address ID"/> + comment="Quote Address ID"/> + comment="Region ID"/> + comment="Customer ID"/> @@ -431,9 +431,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> + comment="Store ID"/> + comment="Order ID"/> + comment="Customer ID"/> + comment="Shipping Address ID"/> + comment="Billing Address ID"/> @@ -762,13 +762,13 @@
+ comment="Entity ID"/> + comment="Store ID"/> + comment="Order ID"/> @@ -837,9 +837,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/> + comment="Product ID"/> + comment="Order Item ID"/> @@ -867,14 +867,14 @@
+ comment="Entity ID"/> + comment="Parent ID"/> + comment="Order ID"/> @@ -901,9 +901,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> + comment="Store ID"/>
+ comment="Entity ID"/> + comment="Store ID"/> + comment="Order ID"/> @@ -1136,9 +1136,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> + comment="Store ID"/>
+ comment="Entity ID"/> + comment="Order ID"/> @@ -1366,7 +1366,7 @@ comment="Base Grand Total"/> + comment="Store ID"/> @@ -1438,9 +1438,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/> + comment="Product ID"/> + comment="Order Item ID"/> @@ -1494,9 +1494,9 @@
+ comment="Entity ID"/> + comment="Parent ID"/>
+ comment="Entity ID"/> @@ -163,7 +163,8 @@
- +
- + @@ -336,7 +338,8 @@
- + diff --git a/app/code/Magento/Signifyd/etc/db_schema.xml b/app/code/Magento/Signifyd/etc/db_schema.xml index 6a31eacbb45f5..6f41b883c71e1 100644 --- a/app/code/Magento/Signifyd/etc/db_schema.xml +++ b/app/code/Magento/Signifyd/etc/db_schema.xml @@ -37,6 +37,7 @@
- +
diff --git a/app/code/Magento/Vault/etc/db_schema.xml b/app/code/Magento/Vault/etc/db_schema.xml index ed1f2adba2142..e9645e211ae9b 100644 --- a/app/code/Magento/Vault/etc/db_schema.xml +++ b/app/code/Magento/Vault/etc/db_schema.xml @@ -9,7 +9,7 @@ xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd"> + comment="Entity ID"/> + default="0" comment="Entity ID"/> From cfa4d605a2d6437e08d8693135c028e8f7796fbb Mon Sep 17 00:00:00 2001 From: mage2pratik Date: Wed, 19 Sep 2018 23:39:45 +0530 Subject: [PATCH 09/27] Update time12h javascript validation rule to be compatible with js minify --- lib/web/mage/validation.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 86dd5a3b03681..a577208894944 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -364,7 +364,7 @@ ], 'time12h': [ function (value, element) { - return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\ [AP]M))$/i.test(value); + return this.optional(element) || /^((0?[1-9]|1[012])(:[0-5]\d){0,2}(\s[AP]M))$/i.test(value); }, $.mage.__('Please enter a valid time, between 00:00 am and 12:00 pm') ], From ad35b6f83dadcf3e33e7d6a09ca8125d189cfa87 Mon Sep 17 00:00:00 2001 From: David Manners Date: Thu, 20 Sep 2018 10:39:14 +0000 Subject: [PATCH 10/27] Update Magento_Sales integrations tests to fix error when running RMA module tests - Use the order repository for saving, - Use guest customer, - Attach email address to order, --- .../testsuite/Magento/Sales/_files/order_list.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php index 2789c8040f353..9a7442081770f 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php @@ -5,6 +5,7 @@ */ use Magento\Sales\Model\Order; +use Magento\Sales\Api\OrderRepositoryInterface; require 'order.php'; /** @var Order $order */ @@ -47,6 +48,8 @@ ], ]; +/** @var OrderRepositoryInterface $orderRepository */ +$orderRepository = $objectManager->create(OrderRepositoryInterface::class); /** @var array $orderData */ foreach ($orders as $orderData) { /** @var $order \Magento\Sales\Model\Order */ @@ -60,13 +63,16 @@ $billingAddress->setAddressType('billing'); /** @var Order\Address $shippingAddress */ - $shippingAddress = clone $billingAddress; - $shippingAddress->setId(null)->setAddressType('shipping'); + $shippingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); + $shippingAddress->setAddressType('shipping'); $order ->setData($orderData) ->addItem($orderItem) ->setBillingAddress($billingAddress) ->setShippingAddress($shippingAddress) - ->save(); + ->setCustomerIsGuest(true) + ->setCustomerEmail('customer@null.com'); + + $orderRepository->save($order); } From 214ba6748a99d211578471ad8c158375ca4951b9 Mon Sep 17 00:00:00 2001 From: David Manners Date: Thu, 20 Sep 2018 12:09:02 +0000 Subject: [PATCH 11/27] Set the customer address and is gust flag before setting the addresses against the order --- .../testsuite/Magento/Sales/_files/order_list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php index 9a7442081770f..7f14d8cf26056 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php +++ b/dev/tests/integration/testsuite/Magento/Sales/_files/order_list.php @@ -6,6 +6,7 @@ use Magento\Sales\Model\Order; use Magento\Sales\Api\OrderRepositoryInterface; +use Magento\Sales\Model\Order\Address as OrderAddress; require 'order.php'; /** @var Order $order */ @@ -59,20 +60,19 @@ // Reset addresses /** @var Order\Address $billingAddress */ - $billingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); + $billingAddress = $objectManager->create(OrderAddress::class, ['data' => $addressData]); $billingAddress->setAddressType('billing'); - /** @var Order\Address $shippingAddress */ - $shippingAddress = $objectManager->create(\Magento\Sales\Model\Order\Address::class, ['data' => $addressData]); - $shippingAddress->setAddressType('shipping'); + $shippingAddress = clone $billingAddress; + $shippingAddress->setId(null)->setAddressType('shipping'); $order ->setData($orderData) ->addItem($orderItem) - ->setBillingAddress($billingAddress) - ->setShippingAddress($shippingAddress) ->setCustomerIsGuest(true) - ->setCustomerEmail('customer@null.com'); + ->setCustomerEmail('customer@null.com') + ->setBillingAddress($billingAddress) + ->setShippingAddress($shippingAddress); $orderRepository->save($order); } From 38dfdd8c714f11e67dc7a2495cc16c08d794a71d Mon Sep 17 00:00:00 2001 From: mage2pratik Date: Sat, 22 Sep 2018 00:16:44 +0530 Subject: [PATCH 12/27] Replace sort callbacks to spaceship operator --- .../Magento/Backend/Block/Widget/Button/ButtonList.php | 8 +------- app/code/Magento/Bundle/Model/Product/Type.php | 6 ++---- .../Config/Model/Config/Structure/Mapper/Sorting.php | 6 +----- .../Deploy/Model/DeploymentConfig/ImporterPool.php | 9 +-------- app/code/Magento/Paypal/Model/Express/Checkout.php | 5 +---- .../Sales/Block/Adminhtml/Order/View/Tab/History.php | 6 +----- app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php | 6 +----- app/code/Magento/Ui/DataProvider/Modifier/Pool.php | 9 +-------- .../Test/Constraint/AssertDownloadableDuplicateForm.php | 6 +----- 9 files changed, 10 insertions(+), 51 deletions(-) diff --git a/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php b/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php index ced07fb662f14..e2d71d171cf15 100644 --- a/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php +++ b/app/code/Magento/Backend/Block/Widget/Button/ButtonList.php @@ -127,12 +127,6 @@ public function getItems() */ public function sortButtons(Item $itemA, Item $itemB) { - $sortOrderA = (int) $itemA->getSortOrder(); - $sortOrderB = (int) $itemB->getSortOrder(); - - if ($sortOrderA == $sortOrderB) { - return 0; - } - return ($sortOrderA < $sortOrderB) ? -1 : 1; + return (int)$itemA->getSortOrder() <=> (int)$itemB->getSortOrder(); } } diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index d25f856e0b40d..92bada8094c7e 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -1014,10 +1014,8 @@ public function shakeSelections($firstItem, $secondItem) $secondItem->getPosition(), $secondItem->getSelectionId(), ]; - if ($aPosition == $bPosition) { - return 0; - } - return $aPosition < $bPosition ? -1 : 1; + + return $aPosition <=> $bPosition; } /** diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php index 2733847bab1d0..e615678550108 100644 --- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php +++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php @@ -62,10 +62,6 @@ protected function _cmp($elementA, $elementB) $sortIndexB = (float)$elementB['sortOrder']; } - if ($sortIndexA == $sortIndexB) { - return 0; - } - - return $sortIndexA < $sortIndexB ? -1 : 1; + return $sortIndexA <=> $sortIndexB; } } diff --git a/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php b/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php index a4a9ef00c4a83..cae76a4c2591f 100644 --- a/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php +++ b/app/code/Magento/Deploy/Model/DeploymentConfig/ImporterPool.php @@ -187,14 +187,7 @@ public function getValidator($section) private function sort(array $data) { uasort($data, function (array $a, array $b) { - $a['sort_order'] = $this->getSortOrder($a); - $b['sort_order'] = $this->getSortOrder($b); - - if ($a['sort_order'] == $b['sort_order']) { - return 0; - } - - return ($a['sort_order'] < $b['sort_order']) ? -1 : 1; + return $this->getSortOrder($a) <=> $this->getSortOrder($b); }); return $data; diff --git a/app/code/Magento/Paypal/Model/Express/Checkout.php b/app/code/Magento/Paypal/Model/Express/Checkout.php index 1300c79368943..856e01f7353f2 100644 --- a/app/code/Magento/Paypal/Model/Express/Checkout.php +++ b/app/code/Magento/Paypal/Model/Express/Checkout.php @@ -1056,10 +1056,7 @@ protected function _prepareShippingOptions(Address $address, $mayReturnEmpty = f */ protected static function cmpShippingOptions(DataObject $option1, DataObject $option2) { - if ($option1->getAmount() == $option2->getAmount()) { - return 0; - } - return ($option1->getAmount() < $option2->getAmount()) ? -1 : 1; + return $option1->getAmount() <=> $option2->getAmount(); } /** diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php index 64b53d10d4af6..30b0872dfa90d 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/View/Tab/History.php @@ -303,11 +303,7 @@ public static function sortHistoryByTimestamp($a, $b) $createdAtA = $a['created_at']; $createdAtB = $b['created_at']; - /** @var $createdAtA \DateTime */ - if ($createdAtA->getTimestamp() == $createdAtB->getTimestamp()) { - return 0; - } - return $createdAtA->getTimestamp() < $createdAtB->getTimestamp() ? -1 : 1; + return $createdAtA->getTimestamp() <=> $createdAtB->getTimestamp(); } /** diff --git a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php index 401fdcd2b04ac..2989e8a95c198 100644 --- a/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php +++ b/app/code/Magento/Sales/Model/Order/Pdf/AbstractPdf.php @@ -641,11 +641,7 @@ protected function _sortTotalsList($a, $b) return 0; } - if ($a['sort_order'] == $b['sort_order']) { - return 0; - } - - return $a['sort_order'] > $b['sort_order'] ? 1 : -1; + return $a['sort_order'] <=> $b['sort_order']; } /** diff --git a/app/code/Magento/Ui/DataProvider/Modifier/Pool.php b/app/code/Magento/Ui/DataProvider/Modifier/Pool.php index 34a24499834d2..882f97d57e9fb 100644 --- a/app/code/Magento/Ui/DataProvider/Modifier/Pool.php +++ b/app/code/Magento/Ui/DataProvider/Modifier/Pool.php @@ -88,14 +88,7 @@ public function getModifiersInstances() protected function sort(array $data) { usort($data, function (array $a, array $b) { - $a['sortOrder'] = $this->getSortOrder($a); - $b['sortOrder'] = $this->getSortOrder($b); - - if ($a['sortOrder'] == $b['sortOrder']) { - return 0; - } - - return ($a['sortOrder'] < $b['sortOrder']) ? -1 : 1; + return $this->getSortOrder($a) <=> $this->getSortOrder($b); }); return $data; diff --git a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php index e5d97e1511e71..2033189214e12 100644 --- a/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php +++ b/dev/tests/functional/tests/app/Magento/Downloadable/Test/Constraint/AssertDownloadableDuplicateForm.php @@ -32,11 +32,7 @@ protected function sortDownloadableArray(array $fields) usort( $fields, function ($row1, $row2) { - if ($row1['sort_order'] == $row2['sort_order']) { - return 0; - } - - return ($row1['sort_order'] < $row2['sort_order']) ? -1 : 1; + return $row1['sort_order'] <=> $row2['sort_order']; } ); From e20dfc360361d783643b42d2ef7c20206eeed51e Mon Sep 17 00:00:00 2001 From: Volodymyr Hryvinskyi Date: Sat, 22 Sep 2018 21:54:09 +0300 Subject: [PATCH 13/27] Replace 'Rule Id' to 'Rule ID' --- app/code/Magento/CatalogRule/etc/db_schema.xml | 12 ++++++------ app/code/Magento/SalesRule/etc/db_schema.xml | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/CatalogRule/etc/db_schema.xml b/app/code/Magento/CatalogRule/etc/db_schema.xml index 537ed75e7d55e..25c9d866167ce 100644 --- a/app/code/Magento/CatalogRule/etc/db_schema.xml +++ b/app/code/Magento/CatalogRule/etc/db_schema.xml @@ -39,7 +39,7 @@ + comment="Rule ID"/>
+ comment="Rule ID"/>
+ comment="Rule ID"/> @@ -158,7 +158,7 @@
+ comment="Rule ID"/> @@ -179,7 +179,7 @@ + comment="Rule ID"/> + comment="Rule ID"/> + comment="Rule ID"/> @@ -117,7 +117,7 @@ + comment="Rule ID"/> + comment="Rule ID"/> @@ -164,7 +164,7 @@
+ comment="Rule ID"/>
+ comment="Rule ID"/> @@ -339,7 +339,7 @@
+ comment="Rule ID"/> From 85422338bc2eb0bb337c1602a51209e8e4be39bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Lavorel?= Date: Tue, 4 Sep 2018 18:23:45 +0200 Subject: [PATCH 14/27] rich snippet declaration on grouped product --- .../view/base/templates/product/price/final_price.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/GroupedProduct/view/base/templates/product/price/final_price.phtml b/app/code/Magento/GroupedProduct/view/base/templates/product/price/final_price.phtml index 34de1a18cf28a..d9238e9794d7e 100644 --- a/app/code/Magento/GroupedProduct/view/base/templates/product/price/final_price.phtml +++ b/app/code/Magento/GroupedProduct/view/base/templates/product/price/final_price.phtml @@ -26,7 +26,7 @@ if ($minProduct) { ); } ?> -
+
getZone()): ?>

toHtml() ?> From edd2e93a251424577f231f574d2424c4e06248d0 Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Fri, 24 Aug 2018 11:48:56 +0300 Subject: [PATCH 15/27] Current password autocomplete for admin login Browsers have an autocomplete functionality with permissions for every site separately. It is a user's decision - enable/disable autocomplete for the certain site, not developer's is. --- .../Backend/view/adminhtml/templates/admin/login.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml index 805e9783f3f18..528c13fc874aa 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml @@ -27,7 +27,7 @@ value="" data-validate="{required:true}" placeholder="" - autocomplete="off" + autocomplete="on" />

@@ -43,7 +43,7 @@ data-validate="{required:true}" value="" placeholder="" - autocomplete="new-password" + autocomplete="current-password" /> From 692e89e106210cc1a63ca0e257a172e65a961bc2 Mon Sep 17 00:00:00 2001 From: Alex Gusev Date: Fri, 14 Sep 2018 12:33:45 +0300 Subject: [PATCH 16/27] Switch off autocomplete see https://github.com/magento/magento2/pull/17783#issuecomment-421235681 --- .../Backend/view/adminhtml/templates/admin/login.phtml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml index 528c13fc874aa..52d5dd6d114ee 100644 --- a/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml +++ b/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml @@ -27,7 +27,7 @@ value="" data-validate="{required:true}" placeholder="" - autocomplete="on" + autocomplete="off" /> @@ -43,7 +43,7 @@ data-validate="{required:true}" value="" placeholder="" - autocomplete="current-password" + autocomplete="off" /> From a2d9d2b9b7fa04e61716c8160d4bcaa7cc98685e Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Wed, 5 Sep 2018 23:56:03 +0300 Subject: [PATCH 17/27] return $this from setters in Analytics/ReportXml/DB/SelectBuilder.php --- .../Analytics/ReportXml/DB/SelectBuilder.php | 32 ++++++++++++++----- .../Unit/ReportXml/DB/SelectBuilderTest.php | 12 +++---- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php index 81ee9b15781d1..f61e02988103a 100644 --- a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php +++ b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php @@ -85,11 +85,13 @@ public function getJoins() * Set joins conditions * * @param array $joins - * @return void + * @return $this */ public function setJoins($joins) { $this->joins = $joins; + + return $this; } /** @@ -106,11 +108,13 @@ public function getConnectionName() * Set connection name * * @param string $connectionName - * @return void + * @return $this */ public function setConnectionName($connectionName) { $this->connectionName = $connectionName; + + return $this; } /** @@ -127,11 +131,13 @@ public function getColumns() * Set columns * * @param array $columns - * @return void + * @return $this */ public function setColumns($columns) { $this->columns = $columns; + + return $this; } /** @@ -148,11 +154,13 @@ public function getFilters() * Set filters * * @param array $filters - * @return void + * @return $this */ public function setFilters($filters) { $this->filters = $filters; + + return $this; } /** @@ -169,11 +177,13 @@ public function getFrom() * Set from condition * * @param array $from - * @return void + * @return $this */ public function setFrom($from) { $this->from = $from; + + return $this; } /** @@ -236,11 +246,13 @@ public function getGroup() * Set group * * @param array $group - * @return void + * @return $this */ public function setGroup($group) { $this->group = $group; + + return $this; } /** @@ -257,11 +269,13 @@ public function getParams() * Set parameters * * @param array $params - * @return void + * @return $this */ public function setParams($params) { $this->params = $params; + + return $this; } /** @@ -278,10 +292,12 @@ public function getHaving() * Set having condition * * @param array $having - * @return void + * @return $this */ public function setHaving($having) { $this->having = $having; + + return $this; } } diff --git a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php index 8be2f0ee968ef..a4362d583dfbc 100644 --- a/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php +++ b/app/code/Magento/Analytics/Test/Unit/ReportXml/DB/SelectBuilderTest.php @@ -64,12 +64,12 @@ public function testCreate() ['link-type' => 'right', 'table' => 'attribute', 'condition' => 'neq'], ]; $groups = ['id', 'name']; - $this->selectBuilder->setConnectionName($connectionName); - $this->selectBuilder->setFrom($from); - $this->selectBuilder->setColumns($columns); - $this->selectBuilder->setFilters([$filter]); - $this->selectBuilder->setJoins($joins); - $this->selectBuilder->setGroup($groups); + $this->selectBuilder->setConnectionName($connectionName) + ->setFrom($from) + ->setColumns($columns) + ->setFilters([$filter]) + ->setJoins($joins) + ->setGroup($groups); $this->resourceConnectionMock->expects($this->once()) ->method('getConnection') ->with($connectionName) From 8b9fff56f2172bb2e3fa5bde4d16daa18df97e22 Mon Sep 17 00:00:00 2001 From: francesco Date: Sat, 8 Sep 2018 11:33:12 +0200 Subject: [PATCH 18/27] Fix module uninstall shell command and composer removal w/out regression --- lib/internal/Magento/Framework/Composer/Remove.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/Magento/Framework/Composer/Remove.php b/lib/internal/Magento/Framework/Composer/Remove.php index b7a9a20333d86..b7cea7769a176 100644 --- a/lib/internal/Magento/Framework/Composer/Remove.php +++ b/lib/internal/Magento/Framework/Composer/Remove.php @@ -46,7 +46,7 @@ public function remove(array $packages) [ 'command' => 'remove', 'packages' => $packages, - '--no-update' => true, + '--no-update-with-dependencies' => true, ] ); } From fa4289fe8534a2af5aeb69839ba0df6aa21a55ed Mon Sep 17 00:00:00 2001 From: francesco Date: Mon, 10 Sep 2018 13:18:29 +0200 Subject: [PATCH 19/27] test updated --- .../testsuite/Magento/Framework/Composer/RemoveTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Framework/Composer/RemoveTest.php b/dev/tests/integration/testsuite/Magento/Framework/Composer/RemoveTest.php index bfe8264d7cce6..211b28617cbe2 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Composer/RemoveTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Composer/RemoveTest.php @@ -24,7 +24,7 @@ public function testRemove() [ 'command' => 'remove', 'packages' => ['magento/package-a', 'magento/package-b'], - '--no-update' => true, + '--no-update-with-dependencies' => true, ] ); $composerAppFactory->expects($this->once()) From 74e1ea92cb57d739d3552fa9b86c51a8d5d8cfe9 Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Sat, 1 Sep 2018 16:01:25 +0200 Subject: [PATCH 20/27] [Forwardport] Make sure all linked products (related, upsells, crosssells) show up in the backend grids and in the correct order. Fixes #13720 (cherry picked from commit a3f1c384e77ea1e693b18462e82091cf72965269) --- .../Model/ProductLink/CollectionProvider.php | 22 +++++++++---------- .../Unit/Model/CollectionProviderTest.php | 20 ++++++++++++----- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php index bc212adae2c32..24ba5cb627896 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php +++ b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php @@ -47,22 +47,20 @@ public function getCollection(\Magento\Catalog\Model\Product $product, $type) $products = $this->providers[$type]->getLinkedProducts($product); $converter = $this->converterPool->getConverter($type); - $output = []; $sorterItems = []; foreach ($products as $item) { - $output[$item->getId()] = $converter->convert($item); + $itemId = $item->getId(); + $sorterItems[$itemId] = $converter->convert($item); + $sorterItems[$itemId]['position'] = $sorterItems[$itemId]['position'] ?? 0; } - foreach ($output as $item) { - $itemPosition = $item['position']; - if (!isset($sorterItems[$itemPosition])) { - $sorterItems[$itemPosition] = $item; - } else { - $newPosition = $itemPosition + 1; - $sorterItems[$newPosition] = $item; - } - } - ksort($sorterItems); + usort($sorterItems, function ($itemA, $itemB) { + $posA = intval($itemA['position']); + $posB = intval($itemB['position']); + + return $posA <=> $posB; + }); + return $sorterItems; } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php index d8931cbbfcf73..f0e17c7938b27 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/CollectionProviderTest.php @@ -57,10 +57,14 @@ public function testGetCollection() $linkedProductOneMock = $this->createMock(Product::class); $linkedProductTwoMock = $this->createMock(Product::class); $linkedProductThreeMock = $this->createMock(Product::class); + $linkedProductFourMock = $this->createMock(Product::class); + $linkedProductFiveMock = $this->createMock(Product::class); $linkedProductOneMock->expects($this->once())->method('getId')->willReturn(1); $linkedProductTwoMock->expects($this->once())->method('getId')->willReturn(2); $linkedProductThreeMock->expects($this->once())->method('getId')->willReturn(3); + $linkedProductFourMock->expects($this->once())->method('getId')->willReturn(4); + $linkedProductFiveMock->expects($this->once())->method('getId')->willReturn(5); $this->converterPoolMock->expects($this->once()) ->method('getConverter') @@ -71,9 +75,11 @@ public function testGetCollection() [$linkedProductOneMock, ['name' => 'Product One', 'position' => 10]], [$linkedProductTwoMock, ['name' => 'Product Two', 'position' => 2]], [$linkedProductThreeMock, ['name' => 'Product Three', 'position' => 2]], + [$linkedProductFourMock, ['name' => 'Product Four', 'position' => null]], + [$linkedProductFiveMock, ['name' => 'Product Five']], ]; - $this->converterMock->expects($this->exactly(3))->method('convert')->willReturnMap($map); + $this->converterMock->expects($this->exactly(5))->method('convert')->willReturnMap($map); $this->providerMock->expects($this->once()) ->method('getLinkedProducts') @@ -82,14 +88,18 @@ public function testGetCollection() [ $linkedProductOneMock, $linkedProductTwoMock, - $linkedProductThreeMock + $linkedProductThreeMock, + $linkedProductFourMock, + $linkedProductFiveMock, ] ); $expectedResult = [ - 2 => ['name' => 'Product Two', 'position' => 2], - 3 => ['name' => 'Product Three', 'position' => 2], - 10 => ['name' => 'Product One', 'position' => 10], + 0 => ['name' => 'Product Four', 'position' => 0], + 1 => ['name' => 'Product Five', 'position' => 0], + 2 => ['name' => 'Product Three', 'position' => 2], + 3 => ['name' => 'Product Two', 'position' => 2], + 4 => ['name' => 'Product One', 'position' => 10], ]; $actualResult = $this->model->getCollection($this->productMock, 'crosssell'); From d5b6231a241ade0acf154f8e88de88714b8e5cff Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Sun, 23 Sep 2018 14:39:24 +0200 Subject: [PATCH 21/27] Satisfy static tests. --- .../Magento/Catalog/Model/ProductLink/CollectionProvider.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php index 24ba5cb627896..13f0dbf79a1b9 100644 --- a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php +++ b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php @@ -9,6 +9,9 @@ use Magento\Catalog\Model\ProductLink\Converter\ConverterPool; use Magento\Framework\Exception\NoSuchEntityException; +/** + * Provides a collection of linked product items (crosssells, related, upsells, ...) + */ class CollectionProvider { /** From 47f791a21c5d2d40d3dd0585f106f0ad2ca35664 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Mon, 10 Sep 2018 17:22:50 +0300 Subject: [PATCH 22/27] Covering the CategoryProcessUrlRewriteMovingObserver by Unit Test --- ...oryProcessUrlRewriteMovingObserverTest.php | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php new file mode 100644 index 0000000000000..d9b0c14b2a342 --- /dev/null +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php @@ -0,0 +1,151 @@ +categoryUrlRewriteGeneratorMock = $this->createMock(CategoryUrlRewriteGenerator::class); + $this->urlPersistMock = $this->createMock(UrlPersistInterface::class); + $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); + $this->urlRewriteHandlerMock = $this->createMock(UrlRewriteHandler::class); + $this->urlRewriteBunchReplacerMock = $this->createPartialMock(UrlRewriteBunchReplacer::class, + ['doBunchReplace'] + ); + $this->databaseMapPoolMock = $this->createMock(DatabaseMapPool::class); + + $this->observer = new CategoryProcessUrlRewriteMovingObserver( + $this->categoryUrlRewriteGeneratorMock, + $this->urlPersistMock, + $this->scopeConfigMock, + $this->urlRewriteHandlerMock, + $this->urlRewriteBunchReplacerMock, + $this->databaseMapPoolMock, + [ + DataCategoryUrlRewriteDatabaseMap::class, + DataProductUrlRewriteDatabaseMap::class + ] + ); + } + + /** + * Test category process rewrite url by changing the parent + * + * @return void + */ + public function testCategoryProcessUrlRewriteAfterMovingWithChangedParentId() + { + /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $observerMock */ + $observerMock = $this->createMock(Observer::class); + $eventMock = $this->getMockBuilder(Event::class) + ->disableOriginalConstructor() + ->setMethods(['getCategory']) + ->getMock(); + $categoryMock = $this->createPartialMock(Category::class, [ + 'dataHasChangedFor', + 'getEntityId', + 'getStoreId', + 'setData' + ]); + + $categoryMock->expects($this->once())->method('dataHasChangedFor')->with('parent_id') + ->willReturn(true); + $eventMock->expects($this->once())->method('getCategory')->willReturn($categoryMock); + $observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); + $this->scopeConfigMock->expects($this->once())->method('isSetFlag') + ->with(UrlKeyRenderer::XML_PATH_SEO_SAVE_HISTORY)->willReturn(true); + $this->categoryUrlRewriteGeneratorMock->expects($this->once())->method('generate') + ->with($categoryMock, true)->willReturn(['category-url-rewrite']); + $this->urlRewriteHandlerMock->expects($this->once())->method('generateProductUrlRewrites') + ->with($categoryMock)->willReturn(['product-url-rewrite']); + $this->databaseMapPoolMock->expects($this->exactly(2))->method('resetMap')->willReturnSelf(); + + $this->observer->execute($observerMock); + } + + /** + * Test category process rewrite url without changing the parent + * + * @return void + */ + public function testCategoryProcessUrlRewriteAfterMovingWithinNotChangedParent() + { + /** @var Observer|\PHPUnit_Framework_MockObject_MockObject $observerMock */ + $observerMock = $this->createMock(Observer::class); + $eventMock = $this->getMockBuilder(Event::class) + ->disableOriginalConstructor() + ->setMethods(['getCategory']) + ->getMock(); + $categoryMock = $this->createPartialMock(Category::class, ['dataHasChangedFor']); + $observerMock->expects($this->once())->method('getEvent')->willReturn($eventMock); + $eventMock->expects($this->once())->method('getCategory')->willReturn($categoryMock); + $categoryMock->expects($this->once())->method('dataHasChangedFor')->with('parent_id') + ->willReturn(false); + + $this->observer->execute($observerMock); + } +} From 94ed408b61c46d86c4adeefe273c16447b565e42 Mon Sep 17 00:00:00 2001 From: Yaroslav Rogoza Date: Mon, 10 Sep 2018 16:41:34 +0200 Subject: [PATCH 23/27] Code style adjustments --- .../Observer/CategoryProcessUrlRewriteMovingObserverTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php index d9b0c14b2a342..7e51731cf0776 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php @@ -73,7 +73,8 @@ protected function setUp() $this->urlPersistMock = $this->createMock(UrlPersistInterface::class); $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); $this->urlRewriteHandlerMock = $this->createMock(UrlRewriteHandler::class); - $this->urlRewriteBunchReplacerMock = $this->createPartialMock(UrlRewriteBunchReplacer::class, + $this->urlRewriteBunchReplacerMock = $this->createPartialMock( + UrlRewriteBunchReplacer::class, ['doBunchReplace'] ); $this->databaseMapPoolMock = $this->createMock(DatabaseMapPool::class); From 36d1a95037a7ec97afae0c0a54aa56cc0b60a48c Mon Sep 17 00:00:00 2001 From: eduard13 Date: Tue, 11 Sep 2018 10:48:57 +0300 Subject: [PATCH 24/27] Small adjustments --- .../CategoryProcessUrlRewriteMovingObserverTest.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php index 7e51731cf0776..6c54b4d554243 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php @@ -20,14 +20,13 @@ use Magento\Framework\Event; use Magento\Framework\Event\Observer; use Magento\UrlRewrite\Model\UrlPersistInterface; -use PHPUnit\Framework\TestCase; /** * Class CategoryProcessUrlRewriteMovingObserverTest * * @covers \Magento\CatalogUrlRewrite\Observer\CategoryProcessUrlRewriteMovingObserver */ -class CategoryProcessUrlRewriteMovingObserverTest extends TestCase +class CategoryProcessUrlRewriteMovingObserverTest extends \PHPUnit\Framework\TestCase { /** * @var CategoryProcessUrlRewriteMovingObserver @@ -54,11 +53,6 @@ class CategoryProcessUrlRewriteMovingObserverTest extends TestCase */ private $urlRewriteHandlerMock; - /** - * @var UrlRewriteBunchReplacer|\PHPUnit_Framework_MockObject_MockObject - */ - private $urlRewriteBunchReplacerMock; - /** * @var DatabaseMapPool|\PHPUnit_Framework_MockObject_MockObject */ @@ -73,7 +67,8 @@ protected function setUp() $this->urlPersistMock = $this->createMock(UrlPersistInterface::class); $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); $this->urlRewriteHandlerMock = $this->createMock(UrlRewriteHandler::class); - $this->urlRewriteBunchReplacerMock = $this->createPartialMock( + /** @var UrlRewriteBunchReplacer|\PHPUnit_Framework_MockObject_MockObject $urlRewriteBunchReplacerMock */ + $urlRewriteBunchReplacerMock = $this->createPartialMock( UrlRewriteBunchReplacer::class, ['doBunchReplace'] ); @@ -84,7 +79,7 @@ protected function setUp() $this->urlPersistMock, $this->scopeConfigMock, $this->urlRewriteHandlerMock, - $this->urlRewriteBunchReplacerMock, + $urlRewriteBunchReplacerMock, $this->databaseMapPoolMock, [ DataCategoryUrlRewriteDatabaseMap::class, From a73393393d460c63f26a155417d7a62e466b9f4e Mon Sep 17 00:00:00 2001 From: eduard13 Date: Tue, 11 Sep 2018 13:42:35 +0300 Subject: [PATCH 25/27] Refactoring the local variable's name --- .../CategoryProcessUrlRewriteMovingObserverTest.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php index 6c54b4d554243..d22f0e212b75e 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php @@ -67,11 +67,8 @@ protected function setUp() $this->urlPersistMock = $this->createMock(UrlPersistInterface::class); $this->scopeConfigMock = $this->createMock(ScopeConfigInterface::class); $this->urlRewriteHandlerMock = $this->createMock(UrlRewriteHandler::class); - /** @var UrlRewriteBunchReplacer|\PHPUnit_Framework_MockObject_MockObject $urlRewriteBunchReplacerMock */ - $urlRewriteBunchReplacerMock = $this->createPartialMock( - UrlRewriteBunchReplacer::class, - ['doBunchReplace'] - ); + /** @var UrlRewriteBunchReplacer|\PHPUnit_Framework_MockObject_MockObject $urlRewriteMock */ + $urlRewriteMock = $this->createMock(UrlRewriteBunchReplacer::class); $this->databaseMapPoolMock = $this->createMock(DatabaseMapPool::class); $this->observer = new CategoryProcessUrlRewriteMovingObserver( @@ -79,7 +76,7 @@ protected function setUp() $this->urlPersistMock, $this->scopeConfigMock, $this->urlRewriteHandlerMock, - $urlRewriteBunchReplacerMock, + $urlRewriteMock, $this->databaseMapPoolMock, [ DataCategoryUrlRewriteDatabaseMap::class, From fd2cb4c38273ef894670ddc6e59ea3afbeae52f2 Mon Sep 17 00:00:00 2001 From: Eugene Shakhsuvarov Date: Tue, 18 Sep 2018 12:47:17 +0300 Subject: [PATCH 26/27] Update CategoryProcessUrlRewriteMovingObserverTest.php Suppress PHPMD warning for test --- .../Observer/CategoryProcessUrlRewriteMovingObserverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php index d22f0e212b75e..b12da6243a903 100644 --- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php +++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryProcessUrlRewriteMovingObserverTest.php @@ -24,7 +24,7 @@ /** * Class CategoryProcessUrlRewriteMovingObserverTest * - * @covers \Magento\CatalogUrlRewrite\Observer\CategoryProcessUrlRewriteMovingObserver + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class CategoryProcessUrlRewriteMovingObserverTest extends \PHPUnit\Framework\TestCase { From ac48c86bc7374ff99fb8e1ba6c7c75ac414084c7 Mon Sep 17 00:00:00 2001 From: Stanislav Idolov Date: Tue, 25 Sep 2018 11:43:13 +0300 Subject: [PATCH 27/27] magento-engcom/magento2ce#2203: Fixed tests failures --- .../Analytics/ReportXml/DB/SelectBuilder.php | 1 + .../Model/Entity/Attribute/OptionManagement.php | 15 ++++++++++++--- .../Entity/Attribute/OptionManagementTest.php | 14 +++++++------- app/code/Magento/Paypal/Model/AbstractConfig.php | 4 ++-- app/code/Magento/Paypal/Model/Config.php | 12 ++++++++++++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php index f61e02988103a..b4b7adebf7459 100644 --- a/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php +++ b/app/code/Magento/Analytics/ReportXml/DB/SelectBuilder.php @@ -11,6 +11,7 @@ /** * Responsible for Select object creation, works as a builder. Returns Select as result; + * * Used in SQL assemblers. */ class SelectBuilder diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php index 8cb8687cd1f1f..4e4e146208a47 100644 --- a/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php +++ b/app/code/Magento/Eav/Model/Entity/Attribute/OptionManagement.php @@ -10,6 +10,9 @@ use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; +/** + * Eav Option Management + */ class OptionManagement implements \Magento\Eav\Api\AttributeOptionManagementInterface { /** @@ -36,7 +39,7 @@ public function __construct( } /** - * {@inheritdoc} + * @inheritdoc */ public function add($entityType, $attributeCode, $option) { @@ -79,7 +82,7 @@ public function add($entityType, $attributeCode, $option) } /** - * {@inheritdoc} + * @inheritdoc */ public function delete($entityType, $attributeCode, $optionId) { @@ -110,7 +113,7 @@ public function delete($entityType, $attributeCode, $optionId) } /** - * {@inheritdoc} + * @inheritdoc */ public function getItems($entityType, $attributeCode) { @@ -129,6 +132,8 @@ public function getItems($entityType, $attributeCode) } /** + * Validate option + * * @param \Magento\Eav\Api\Data\AttributeInterface $attribute * @param int $optionId * @throws NoSuchEntityException @@ -148,6 +153,8 @@ protected function validateOption($attribute, $optionId) } /** + * Returns option id + * * @param \Magento\Eav\Api\Data\AttributeOptionInterface $option * @return string */ @@ -157,6 +164,8 @@ private function getOptionId(\Magento\Eav\Api\Data\AttributeOptionInterface $opt } /** + * Set option value + * * @param \Magento\Eav\Api\Data\AttributeOptionInterface $option * @param \Magento\Eav\Api\Data\AttributeInterface $attribute * @param string $optionLabel diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php index 2ae31a05d957f..b63a4dd2c9ae6 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/OptionManagementTest.php @@ -59,13 +59,13 @@ public function testAdd() $labelMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); $option = ['value' => [ - 'new_option' => [ + 'id_new_option' => [ 0 => 'optionLabel', 42 => 'labelLabel', ], ], 'order' => [ - 'new_option' => 'optionSortOrder', + 'id_new_option' => 'optionSortOrder', ], ]; @@ -78,10 +78,10 @@ public function testAdd() $labelMock->expects($this->once())->method('getStoreId')->willReturn(42); $labelMock->expects($this->once())->method('getLabel')->willReturn('labelLabel'); $optionMock->expects($this->once())->method('getIsDefault')->willReturn(true); - $attributeMock->expects($this->once())->method('setDefault')->with(['new_option']); + $attributeMock->expects($this->once())->method('setDefault')->with(['id_new_option']); $attributeMock->expects($this->once())->method('setOption')->with($option); $this->resourceModelMock->expects($this->once())->method('save')->with($attributeMock); - $this->assertEquals('new_option', $this->model->add($entityType, $attributeCode, $optionMock)); + $this->assertEquals('id_new_option', $this->model->add($entityType, $attributeCode, $optionMock)); } /** @@ -167,13 +167,13 @@ public function testAddWithCannotSaveException() $labelMock = $this->createMock(\Magento\Eav\Api\Data\AttributeOptionLabelInterface::class); $option = ['value' => [ - 'new_option' => [ + 'id_new_option' => [ 0 => 'optionLabel', 42 => 'labelLabel', ], ], 'order' => [ - 'new_option' => 'optionSortOrder', + 'id_new_option' => 'optionSortOrder', ], ]; @@ -186,7 +186,7 @@ public function testAddWithCannotSaveException() $labelMock->expects($this->once())->method('getStoreId')->willReturn(42); $labelMock->expects($this->once())->method('getLabel')->willReturn('labelLabel'); $optionMock->expects($this->once())->method('getIsDefault')->willReturn(true); - $attributeMock->expects($this->once())->method('setDefault')->with(['new_option']); + $attributeMock->expects($this->once())->method('setDefault')->with(['id_new_option']); $attributeMock->expects($this->once())->method('setOption')->with($option); $this->resourceModelMock->expects($this->once())->method('save')->with($attributeMock) ->willThrowException(new \Exception()); diff --git a/app/code/Magento/Paypal/Model/AbstractConfig.php b/app/code/Magento/Paypal/Model/AbstractConfig.php index 8d002a670a435..e5beddac3b189 100644 --- a/app/code/Magento/Paypal/Model/AbstractConfig.php +++ b/app/code/Magento/Paypal/Model/AbstractConfig.php @@ -134,7 +134,7 @@ public function setStoreId($storeId) * Returns payment configuration value * * @param string $key - * @param null $storeId + * @param null|int $storeId * @return null|string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) @@ -254,7 +254,7 @@ public function isWppApiAvailable() /** * Check whether method available for checkout or not * - * @param null $methodCode + * @param null|string $methodCode * * @return bool */ diff --git a/app/code/Magento/Paypal/Model/Config.php b/app/code/Magento/Paypal/Model/Config.php index c16b3025e382a..b058ba129a33f 100644 --- a/app/code/Magento/Paypal/Model/Config.php +++ b/app/code/Magento/Paypal/Model/Config.php @@ -10,6 +10,7 @@ /** * Config model that is aware of all \Magento\Paypal payment methods + * * Works with PayPal-specific system configuration * @SuppressWarnings(PHPMD.ExcessivePublicCount) @@ -632,6 +633,7 @@ public function __construct( /** * Check whether method available for checkout or not + * * Logic based on merchant country, methods dependence * * @param string|null $methodCode @@ -723,6 +725,7 @@ public function getMerchantCountry() /** * Check whether method supported for specified country or not + * * Use $_methodCode and merchant country by default * * @param string|null $method @@ -896,6 +899,7 @@ public function getExpressCheckoutEditUrl($token) /** * Get url for additional actions that PayPal may require customer to do after placing the order. + * * For instance, redirecting customer to bank for payment confirmation. * * @param string $token @@ -957,6 +961,7 @@ public function areButtonsDynamic() /** * Express checkout shortcut pic URL getter + * * PayPal will ignore "pal", if there is no total amount specified * * @param string $localeCode @@ -996,6 +1001,7 @@ public function getExpressCheckoutInContextImageUrl($localeCode) /** * Get PayPal "mark" image URL + * * Supposed to be used on payment methods selection * $staticSize is applicable for static images only * @@ -1032,6 +1038,7 @@ public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = n /** * Get "What Is PayPal" localized URL + * * Supposed to be used with "mark" as popup window * * @param \Magento\Framework\Locale\ResolverInterface $localeResolver @@ -1262,6 +1269,7 @@ public function getExpressCheckoutBASignupOptions() /** * Whether to ask customer to create billing agreements + * * Unilateral payments are incompatible with the billing agreements * * @return bool @@ -1376,6 +1384,7 @@ public function exportExpressCheckoutStyleSettings(\Magento\Framework\DataObject /** * Dynamic PayPal image URL getter + * * Also can render dynamic Acceptance Mark * * @param string $type @@ -1725,6 +1734,7 @@ public function getBmlPublisherId() /** * Get Display option from stored config + * * @param string $section * * @return mixed @@ -1752,6 +1762,7 @@ public function getBmlDisplay($section) /** * Get Position option from stored config + * * @param string $section * * @return mixed @@ -1767,6 +1778,7 @@ public function getBmlPosition($section) /** * Get Size option from stored config + * * @param string $section * * @return mixed