From 764612e55df56d72f326246c39358a35d3fb07cb Mon Sep 17 00:00:00 2001 From: Nick de Kleijn Date: Tue, 15 Jan 2019 16:39:08 +0100 Subject: [PATCH 01/26] #20310 change product_price_value based on tax setting --- .../Magento/Tax/Plugin/Checkout/CustomerData/Cart.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php index 87f65ef311ac2..c1b495d4ecf98 100644 --- a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php +++ b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php @@ -68,6 +68,14 @@ public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject $this->itemPriceRenderer->setItem($item); $this->itemPriceRenderer->setTemplate('checkout/cart/item/price/sidebar.phtml'); $result['items'][$key]['product_price']=$this->itemPriceRenderer->toHtml(); + if($this->itemPriceRenderer->displayPriceExclTax()) { + $result['items'][$key]['product_price_value'] = $item->getCalculationPrice(); + } elseif ($this->itemPriceRenderer->displayPriceInclTax()) { + $result['items'][$key]['product_price_value'] = $item->getPriceInclTax(); + } elseif ($this->itemPriceRenderer->displayBothPrices()) { + $result['items'][$key]['product_price_value']['incl_tax'] = $item->getPriceInclTax(); + $result['items'][$key]['product_price_value']['excl_tax'] = $item->getCalculationPrice(); + } } } } From 8233da21ed4323d98b3445e2864cc758be02e7fb Mon Sep 17 00:00:00 2001 From: Christian Walter Date: Tue, 22 Jan 2019 11:08:17 +0100 Subject: [PATCH 02/26] [TASK] Fix translation of attribute store label in getAdditionalData Attribute labels should be translated in magento admin setting correct translation for stores --- app/code/Magento/Catalog/Block/Product/View/Attributes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Attributes.php b/app/code/Magento/Catalog/Block/Product/View/Attributes.php index cb59d86a74512..b096874081eb9 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Attributes.php +++ b/app/code/Magento/Catalog/Block/Product/View/Attributes.php @@ -90,7 +90,7 @@ public function getAdditionalData(array $excludeAttr = []) if (is_string($value) && strlen($value)) { $data[$attribute->getAttributeCode()] = [ - 'label' => __($attribute->getStoreLabel()), + 'label' => $attribute->getStoreLabel(), 'value' => $value, 'code' => $attribute->getAttributeCode(), ]; From 91ff1c5d21281dc015942f92766e09cd012dcbbb Mon Sep 17 00:00:00 2001 From: Pieter Hoste Date: Sat, 9 Feb 2019 10:29:04 +0100 Subject: [PATCH 03/26] Also populate the storesCache when importing product only on storeview(s) level, previously the storesCache was only populated for products imported on global level. This causes problems with the correct url rewrites to be generated. --- .../CatalogUrlRewrite/Observer/AfterImportDataObserver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php index 9aaa384776855..7b60c85049767 100644 --- a/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php +++ b/app/code/Magento/CatalogUrlRewrite/Observer/AfterImportDataObserver.php @@ -263,6 +263,7 @@ protected function _populateForUrlGeneration($rowData) if ($this->isGlobalScope($product->getStoreId())) { $this->populateGlobalProduct($product); } else { + $this->storesCache[$product->getStoreId()] = true; $this->addProductToImport($product, $product->getStoreId()); } return $this; From 53694fa9941f5111c6798c962ee7a5fb0b78ca20 Mon Sep 17 00:00:00 2001 From: Oshan Date: Mon, 11 Feb 2019 17:15:38 +0530 Subject: [PATCH 04/26] Remove unused use statement in Wishlist Allcart Controller --- app/code/Magento/Wishlist/Controller/Index/Allcart.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Allcart.php b/app/code/Magento/Wishlist/Controller/Index/Allcart.php index 8463a00c866c5..7035547ec5224 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Allcart.php +++ b/app/code/Magento/Wishlist/Controller/Index/Allcart.php @@ -6,7 +6,6 @@ namespace Magento\Wishlist\Controller\Index; use Magento\Framework\Data\Form\FormKey\Validator; -use Magento\Framework\App\Action; use Magento\Framework\App\Action\Context; use Magento\Wishlist\Controller\WishlistProviderInterface; use Magento\Wishlist\Model\ItemCarrier; From 9de6daf7883ce32929f70f02640bd759fc0892aa Mon Sep 17 00:00:00 2001 From: Dmytro Cheshun Date: Mon, 11 Feb 2019 21:38:20 +0200 Subject: [PATCH 05/26] Fix static test --- app/code/Magento/Wishlist/Controller/Index/Allcart.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Wishlist/Controller/Index/Allcart.php b/app/code/Magento/Wishlist/Controller/Index/Allcart.php index 7035547ec5224..08aaea5e4f425 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Allcart.php +++ b/app/code/Magento/Wishlist/Controller/Index/Allcart.php @@ -11,6 +11,9 @@ use Magento\Wishlist\Model\ItemCarrier; use Magento\Framework\Controller\ResultFactory; +/** + * Action Add All to Cart + */ class Allcart extends \Magento\Wishlist\Controller\AbstractIndex { /** From 18663c069a01b6988a714643b4ef279c119456ca Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Wed, 13 Feb 2019 15:11:22 +0200 Subject: [PATCH 06/26] ENGCOM-4220: Static test fix. --- app/code/Magento/Wishlist/Controller/Index/Allcart.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Wishlist/Controller/Index/Allcart.php b/app/code/Magento/Wishlist/Controller/Index/Allcart.php index 08aaea5e4f425..958e0f49ca1b6 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Allcart.php +++ b/app/code/Magento/Wishlist/Controller/Index/Allcart.php @@ -5,6 +5,7 @@ */ namespace Magento\Wishlist\Controller\Index; +use Magento\Framework\App\Action\HttpPostActionInterface; use Magento\Framework\Data\Form\FormKey\Validator; use Magento\Framework\App\Action\Context; use Magento\Wishlist\Controller\WishlistProviderInterface; @@ -14,7 +15,7 @@ /** * Action Add All to Cart */ -class Allcart extends \Magento\Wishlist\Controller\AbstractIndex +class Allcart extends \Magento\Wishlist\Controller\AbstractIndex implements HttpPostActionInterface { /** * @var WishlistProviderInterface From 5c1b27da714ac785eab9b739f38dc60cf4b7e196 Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Thu, 14 Feb 2019 16:52:25 +0200 Subject: [PATCH 07/26] ENGCOM-4220: Integration test fix. --- .../testsuite/Magento/Wishlist/Controller/IndexTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php index 92eae7a3fe3d7..940d05eb4d5d7 100644 --- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php +++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php @@ -128,6 +128,7 @@ public function testAddActionProductNameXss() public function testAllcartAction() { $formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class)->getFormKey(); + $this->getRequest()->setMethod('POST'); $this->getRequest()->setParam('form_key', $formKey); $this->dispatch('wishlist/index/allcart'); From c7930eb37b29c3bc14735d048845278092fca053 Mon Sep 17 00:00:00 2001 From: Yevhenii Dumskyi Date: Tue, 19 Feb 2019 18:07:10 +0200 Subject: [PATCH 08/26] ENGCOM-21154: Add watermark processing in media application --- .../MediaStorage/Service/ImageResize.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/code/Magento/MediaStorage/Service/ImageResize.php b/app/code/Magento/MediaStorage/Service/ImageResize.php index 6e3929296e252..faefd40279084 100644 --- a/app/code/Magento/MediaStorage/Service/ImageResize.php +++ b/app/code/Magento/MediaStorage/Service/ImageResize.php @@ -257,9 +257,41 @@ private function resize(array $viewImage, string $originalImagePath, string $ori ] ); + if (isset($imageParams['watermark_file'])) { + if ($imageParams['watermark_height'] !== null) { + $image->setWatermarkHeight($imageParams['watermark_height']); + } + + if ($imageParams['watermark_width'] !== null) { + $image->setWatermarkWidth($imageParams['watermark_width']); + } + + if ($imageParams['watermark_position'] !== null) { + $image->setWatermarkPosition($imageParams['watermark_position']); + } + + if ($imageParams['watermark_image_opacity'] !== null) { + $image->setWatermarkImageOpacity($imageParams['watermark_image_opacity']); + } + + $image->watermark($this->getWatermarkFilePath($imageParams['watermark_file'])); + } + if ($imageParams['image_width'] !== null && $imageParams['image_height'] !== null) { $image->resize($imageParams['image_width'], $imageParams['image_height']); } $image->save($imageAsset->getPath()); } + + /** + * Returns watermark file absolute path + * + * @param string $file + * @return string + */ + private function getWatermarkFilePath($file) + { + $path = $this->imageConfig->getMediaPath('/watermark/' . $file); + return $this->mediaDirectory->getAbsolutePath($path); + } } From 4a598e785441304bef5c7e2817ef6d99a963aca2 Mon Sep 17 00:00:00 2001 From: Jitheesh Date: Wed, 20 Feb 2019 16:14:06 +0530 Subject: [PATCH 09/26] Checkout Page Cancel button is not working #21327 - hide cancel button if billing address is not available on current quote --- .../Checkout/view/frontend/web/js/view/billing-address.js | 6 ++++++ .../view/frontend/web/template/billing-address.html | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 6f9a1a46826da..121a94a14852f 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -201,6 +201,12 @@ function ( this.isAddressDetailsVisible(true); } }, + /** + * Manage cancel button visibility + */ + canUseCancelBillingAddress: ko.computed(function () { + return quote.billingAddress() || lastSelectedBillingAddress; + }), /** * Restore billing address diff --git a/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html b/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html index 5f735fbb4daa9..63edb5057b933 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/billing-address.html @@ -22,7 +22,7 @@ - From a0be69b48ad0ac15834c31787d8a4fbc9c4b0ab1 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Wed, 20 Feb 2019 15:41:36 +0200 Subject: [PATCH 10/26] Fixing the Products grid with default values on multi stores --- .../Ui/DataProvider/Product/ProductDataProvider.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index 200ecf89641fa..2971a21b964b0 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -7,6 +7,7 @@ use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory; use Magento\Framework\App\ObjectManager; +use Magento\Store\Model\Store; use Magento\Ui\DataProvider\Modifier\ModifierInterface; use Magento\Ui\DataProvider\Modifier\PoolInterface; @@ -67,6 +68,7 @@ public function __construct( $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; $this->modifiersPool = $modifiersPool ?: ObjectManager::getInstance()->get(PoolInterface::class); + $this->setDefaultStoreToCollection(); } /** @@ -140,4 +142,12 @@ public function getMeta() return $meta; } + + /** + * Filter the product collection by Default Store if no filter is applied + */ + private function setDefaultStoreToCollection() + { + $this->getCollection()->setStoreId(Store::DEFAULT_STORE_ID); + } } From 9e657ad9a2696e15a346d636a245c9a2184e9019 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Wed, 20 Feb 2019 17:20:13 +0200 Subject: [PATCH 11/26] Moving the method's logic into construct --- .../Ui/DataProvider/Product/ProductDataProvider.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index 2971a21b964b0..edc2bcb66f7db 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -68,7 +68,7 @@ public function __construct( $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; $this->modifiersPool = $modifiersPool ?: ObjectManager::getInstance()->get(PoolInterface::class); - $this->setDefaultStoreToCollection(); + $this->getCollection()->setStoreId(Store::DEFAULT_STORE_ID); } /** @@ -142,12 +142,4 @@ public function getMeta() return $meta; } - - /** - * Filter the product collection by Default Store if no filter is applied - */ - private function setDefaultStoreToCollection() - { - $this->getCollection()->setStoreId(Store::DEFAULT_STORE_ID); - } } From 5372fdc88a4aa1e00d9983b7f538760d2f210fe1 Mon Sep 17 00:00:00 2001 From: Jitheesh Date: Thu, 21 Feb 2019 10:28:32 +0530 Subject: [PATCH 12/26] Checkout Page Cancel button is not working #21327 - CR fix --- .../Checkout/view/frontend/web/js/view/billing-address.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 121a94a14852f..4ea6fb5e5df75 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -201,6 +201,7 @@ function ( this.isAddressDetailsVisible(true); } }, + /** * Manage cancel button visibility */ From 642a4ebee39ffef3ac4ae6e848bf5659fdcd1459 Mon Sep 17 00:00:00 2001 From: Jitheesh Date: Fri, 22 Feb 2019 11:21:44 +0530 Subject: [PATCH 13/26] Checkout Page Cancel button is not working - Code style issues fixed --- .../Checkout/view/frontend/web/js/view/billing-address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js index 4ea6fb5e5df75..d68b0682eb511 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js @@ -201,7 +201,7 @@ function ( this.isAddressDetailsVisible(true); } }, - + /** * Manage cancel button visibility */ From 5d2ffad7b23d1c7d6fe46d9288217ee5a1df4e5e Mon Sep 17 00:00:00 2001 From: eduard13 Date: Fri, 22 Feb 2019 09:59:32 +0200 Subject: [PATCH 14/26] Adjusting the Unit Tests --- .../Product/ProductCustomOptionsDataProviderTest.php | 11 ++++++++++- .../Ui/DataProvider/Product/ProductDataProvider.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php index 6d7c8814bd474..0e0cb676cdf3e 100644 --- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/ProductCustomOptionsDataProviderTest.php @@ -54,7 +54,16 @@ protected function setUp() ->getMockForAbstractClass(); $this->collectionMock = $this->getMockBuilder(AbstractCollection::class) ->disableOriginalConstructor() - ->setMethods(['load', 'getSelect', 'getTable', 'getIterator', 'isLoaded', 'toArray', 'getSize']) + ->setMethods([ + 'load', + 'getSelect', + 'getTable', + 'getIterator', + 'isLoaded', + 'toArray', + 'getSize', + 'setStoreId' + ]) ->getMockForAbstractClass(); $this->dbSelectMock = $this->getMockBuilder(DbSelect::class) ->disableOriginalConstructor() diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index edc2bcb66f7db..9a16356698263 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -68,7 +68,7 @@ public function __construct( $this->addFieldStrategies = $addFieldStrategies; $this->addFilterStrategies = $addFilterStrategies; $this->modifiersPool = $modifiersPool ?: ObjectManager::getInstance()->get(PoolInterface::class); - $this->getCollection()->setStoreId(Store::DEFAULT_STORE_ID); + $this->collection->setStoreId(Store::DEFAULT_STORE_ID); } /** From 68ee3af4512ec5db3e8b65e66a59db5b061e5dd0 Mon Sep 17 00:00:00 2001 From: Shikha Mishra Date: Mon, 25 Feb 2019 22:38:49 +0530 Subject: [PATCH 15/26] Fixed #21425 Date design change show not correctly value in backend --- .../Magento/Backend/Block/System/Design/Edit/Tab/General.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php index 5a09e1f17f617..3fe187e6e7694 100644 --- a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php +++ b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php @@ -90,7 +90,7 @@ protected function _prepareForm() ] ); - $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT); + $dateFormat = $this->_localeDate->getDateFormatWithLongYear(); $fieldset->addField( 'date_from', 'date', From 3c8c4a7f9cba91e45ec890703a9a80e96a52a54c Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Tue, 26 Feb 2019 14:23:30 +0200 Subject: [PATCH 16/26] Fix static and functional tests. --- .../Magento/Tax/Plugin/Checkout/CustomerData/Cart.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php index c1b495d4ecf98..208833733ae3f 100644 --- a/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php +++ b/app/code/Magento/Tax/Plugin/Checkout/CustomerData/Cart.php @@ -6,6 +6,10 @@ namespace Magento\Tax\Plugin\Checkout\CustomerData; +/** + * Process quote items price, considering tax configuration. + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) + */ class Cart { /** @@ -68,11 +72,13 @@ public function afterGetSectionData(\Magento\Checkout\CustomerData\Cart $subject $this->itemPriceRenderer->setItem($item); $this->itemPriceRenderer->setTemplate('checkout/cart/item/price/sidebar.phtml'); $result['items'][$key]['product_price']=$this->itemPriceRenderer->toHtml(); - if($this->itemPriceRenderer->displayPriceExclTax()) { + if ($this->itemPriceRenderer->displayPriceExclTax()) { $result['items'][$key]['product_price_value'] = $item->getCalculationPrice(); } elseif ($this->itemPriceRenderer->displayPriceInclTax()) { $result['items'][$key]['product_price_value'] = $item->getPriceInclTax(); } elseif ($this->itemPriceRenderer->displayBothPrices()) { + //unset product price value in case price already has been set as scalar value. + unset($result['items'][$key]['product_price_value']); $result['items'][$key]['product_price_value']['incl_tax'] = $item->getPriceInclTax(); $result['items'][$key]['product_price_value']['excl_tax'] = $item->getCalculationPrice(); } From 14dbb4f3470780daa74644dc1450ec6e99cdcaf2 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Tue, 26 Feb 2019 17:22:46 +0200 Subject: [PATCH 17/26] Fix static test. --- .../Catalog/Ui/DataProvider/Product/ProductDataProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php index 9a16356698263..a518afc576d61 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/ProductDataProvider.php @@ -112,7 +112,7 @@ public function addField($field, $alias = null) } /** - * {@inheritdoc} + * @inheritdoc */ public function addFilter(\Magento\Framework\Api\Filter $filter) { From 9dc9829da45de1d2221c2924a507c5e64629209c Mon Sep 17 00:00:00 2001 From: eduard13 Date: Wed, 27 Feb 2019 16:07:39 +0200 Subject: [PATCH 18/26] Covering the guest order view by integration tests --- .../Sales/Controller/Guest/FormTest.php | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php new file mode 100644 index 0000000000000..91e1415035e2b --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php @@ -0,0 +1,96 @@ +prepareRequestData(); + $this->dispatch('sales/guest/view/'); + $content = $this->getResponse()->getBody(); + $this->assertContains('Order # 100000001', $content); + } + + /** + * View order as logged in customer + * + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testViewOrderAsLoggedIn() + { + $this->login(1); + $this->dispatch('sales/guest/view/'); + $this->assertRedirect($this->stringContains('sales/order/history/')); + } + + /** + * Test Return Order for guest with incorrect data + */ + public function testViewOrderAsGuestWithIncorrectData() + { + $this->prepareRequestData(true); + $this->dispatch('sales/guest/view/'); + $this->assertSessionMessages( + $this->equalTo(['You entered incorrect data. Please try again.']), + MessageInterface::TYPE_ERROR + ); + } + + /** + * Login the user + * + * @param string $customerId Customer to mark as logged in for the session + * @return void + */ + protected function login($customerId) + { + /** @var Session $session */ + $session = $this->_objectManager->get(Session::class); + $session->loginById($customerId); + } + + /** + * @param bool $invalidData + * @return void + */ + private function prepareRequestData($invalidData = false) + { + $orderId = 100000001; + $email = $invalidData ? 'wrong@example.com' : 'customer@null.com'; + + /** @var FormKey $formKey */ + $formKey = $this->_objectManager->get(FormKey::class); + $post = [ + 'oar_order_id' => $orderId, + 'oar_billing_lastname' => 'lastname', + 'oar_type' => 'email', + 'oar_email' => $email, + 'oar_zip' => '', + 'form_key' => $formKey->getFormKey(), + ]; + + $this->getRequest()->setMethod(Request::METHOD_POST); + $this->getRequest()->setPostValue($post); + } +} From 37c10bc108c4b148d7e98cb1d79b504cf0091ff4 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Wed, 27 Feb 2019 16:14:11 +0200 Subject: [PATCH 19/26] Covering the guest order view by integration tests --- .../testsuite/Magento/Sales/Controller/Guest/FormTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php index 91e1415035e2b..d1ea911405fb3 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php @@ -7,9 +7,9 @@ namespace Magento\Sales\Controller; +use Magento\Customer\Model\Session; use Magento\Framework\Data\Form\FormKey; use Magento\Framework\Message\MessageInterface; -use Magento\Customer\Model\Session; use Magento\TestFramework\Request; use Magento\TestFramework\TestCase\AbstractController; From a146f50fbf97d637e977105d384d9c09db39ce53 Mon Sep 17 00:00:00 2001 From: eduard13 Date: Wed, 27 Feb 2019 16:22:12 +0200 Subject: [PATCH 20/26] Covering the logged in to access the Returns form use case --- .../Magento/Sales/Controller/Guest/FormTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php index d1ea911405fb3..4ca8b361f0473 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php @@ -44,6 +44,19 @@ public function testViewOrderAsLoggedIn() $this->assertRedirect($this->stringContains('sales/order/history/')); } + /** + * Test attempting to open the Returns form as logged in customer + * + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento/Customer/_files/customer.php + */ + public function testAttemptToOpenTheFormAsLoggedIn() + { + $this->login(1); + $this->dispatch('sales/guest/form/'); + $this->assertRedirect($this->stringContains('customer/account')); + } + /** * Test Return Order for guest with incorrect data */ From 96f6a61d96415931c5b870653fb66babd984372b Mon Sep 17 00:00:00 2001 From: eduard13 Date: Thu, 28 Feb 2019 09:59:09 +0200 Subject: [PATCH 21/26] Adjusting the namespace --- .../testsuite/Magento/Sales/Controller/Guest/FormTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php index 4ca8b361f0473..1067a474e19aa 100644 --- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php +++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Guest/FormTest.php @@ -5,7 +5,7 @@ */ declare(strict_types=1); -namespace Magento\Sales\Controller; +namespace Magento\Sales\Controller\Guest; use Magento\Customer\Model\Session; use Magento\Framework\Data\Form\FormKey; From e4a1b8ae0d5a7591a41a3f4a31bad98fb81f802b Mon Sep 17 00:00:00 2001 From: eduard13 Date: Thu, 28 Feb 2019 10:01:20 +0200 Subject: [PATCH 22/26] Merging the PR #21480 --- .../Magento/Sales/Controller/Guest/Form.php | 49 +++++++++++++++---- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/app/code/Magento/Sales/Controller/Guest/Form.php b/app/code/Magento/Sales/Controller/Guest/Form.php index 8b4467cb538fa..a1a9f03a20cb8 100644 --- a/app/code/Magento/Sales/Controller/Guest/Form.php +++ b/app/code/Magento/Sales/Controller/Guest/Form.php @@ -4,40 +4,71 @@ * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ +declare(strict_types=1); + namespace Magento\Sales\Controller\Guest; +use Magento\Customer\Model\Session as CustomerSession; +use Magento\Framework\App\Action\Context; +use Magento\Framework\App\ObjectManager; +use Magento\Framework\Controller\Result\Redirect; +use Magento\Framework\View\Result\Page; +use Magento\Framework\View\Result\PageFactory; +use Magento\Sales\Helper\Guest as GuestHelper; + +/** + * Class Form + */ class Form extends \Magento\Framework\App\Action\Action { /** - * @var \Magento\Framework\View\Result\PageFactory + * @var PageFactory */ protected $resultPageFactory; /** - * @param \Magento\Framework\App\Action\Context $context - * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory + * @var CustomerSession|null + */ + private $customerSession; + + /** + * @var GuestHelper|null + */ + private $guestHelper; + + /** + * @param Context $context + * @param PageFactory $resultPageFactory + * @param CustomerSession|null $customerSession + * @param GuestHelper|null $guestHelper */ public function __construct( - \Magento\Framework\App\Action\Context $context, - \Magento\Framework\View\Result\PageFactory $resultPageFactory + Context $context, + PageFactory $resultPageFactory, + CustomerSession $customerSession = null, + GuestHelper $guestHelper = null ) { parent::__construct($context); $this->resultPageFactory = $resultPageFactory; + $this->customerSession = $customerSession ?: ObjectManager::getInstance()->get(CustomerSession::class); + $this->guestHelper = $guestHelper ?: ObjectManager::getInstance()->get(GuestHelper::class); } /** * Order view form page * - * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page + * @return Redirect|Page */ public function execute() { - if ($this->_objectManager->get(\Magento\Customer\Model\Session::class)->isLoggedIn()) { + if ($this->customerSession->isLoggedIn()) { return $this->resultRedirectFactory->create()->setPath('customer/account/'); } + $resultPage = $this->resultPageFactory->create(); $resultPage->getConfig()->getTitle()->set(__('Orders and Returns')); - $this->_objectManager->get(\Magento\Sales\Helper\Guest::class)->getBreadcrumbs($resultPage); + $this->guestHelper->getBreadcrumbs($resultPage); + return $resultPage; } -} +} \ No newline at end of file From f0a98a5a8263cba774d503171e2eb00567365d5b Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Thu, 28 Feb 2019 10:36:58 +0200 Subject: [PATCH 23/26] Fix static tests. --- .../Magento/Backend/Block/System/Design/Edit/Tab/General.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php index 3fe187e6e7694..6004d08b4b738 100644 --- a/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php +++ b/app/code/Magento/Backend/Block/System/Design/Edit/Tab/General.php @@ -6,6 +6,9 @@ namespace Magento\Backend\Block\System\Design\Edit\Tab; +/** + * General system tab block. + */ class General extends \Magento\Backend\Block\Widget\Form\Generic { /** From 832bb705767eca78f0d675a7c7c3149be524fafd Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Fri, 1 Mar 2019 11:41:43 +0200 Subject: [PATCH 24/26] Fix static tests. --- app/code/Magento/Sales/Controller/Guest/Form.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Controller/Guest/Form.php b/app/code/Magento/Sales/Controller/Guest/Form.php index a1a9f03a20cb8..04bb66f3d5b6e 100644 --- a/app/code/Magento/Sales/Controller/Guest/Form.php +++ b/app/code/Magento/Sales/Controller/Guest/Form.php @@ -10,6 +10,7 @@ use Magento\Customer\Model\Session as CustomerSession; use Magento\Framework\App\Action\Context; +use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\App\ObjectManager; use Magento\Framework\Controller\Result\Redirect; use Magento\Framework\View\Result\Page; @@ -19,7 +20,7 @@ /** * Class Form */ -class Form extends \Magento\Framework\App\Action\Action +class Form extends \Magento\Framework\App\Action\Action implements HttpGetActionInterface { /** * @var PageFactory @@ -71,4 +72,4 @@ public function execute() return $resultPage; } -} \ No newline at end of file +} From 7190983a7aa4c4c09d997871a4d71d863e3872f0 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Fri, 1 Mar 2019 13:34:39 +0200 Subject: [PATCH 25/26] Fix static tests. --- .../MediaStorage/Service/ImageResize.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/MediaStorage/Service/ImageResize.php b/app/code/Magento/MediaStorage/Service/ImageResize.php index faefd40279084..aae90512b3d95 100644 --- a/app/code/Magento/MediaStorage/Service/ImageResize.php +++ b/app/code/Magento/MediaStorage/Service/ImageResize.php @@ -24,6 +24,8 @@ use Magento\Framework\App\Filesystem\DirectoryList; /** + * Image resize service. + * * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class ImageResize @@ -123,7 +125,8 @@ public function __construct( } /** - * Create resized images of different sizes from an original image + * Create resized images of different sizes from an original image. + * * @param string $originalImageName * @throws NotFoundException */ @@ -141,7 +144,8 @@ public function resizeFromImageName(string $originalImageName) } /** - * Create resized images of different sizes from themes + * Create resized images of different sizes from themes. + * * @param array|null $themes * @return \Generator * @throws NotFoundException @@ -169,7 +173,8 @@ public function resizeFromThemes(array $themes = null): \Generator } /** - * Search the current theme + * Search the current theme. + * * @return array */ private function getThemesInUse(): array @@ -187,7 +192,8 @@ private function getThemesInUse(): array } /** - * Get view images data from themes + * Get view images data from themes. + * * @param array $themes * @return array */ @@ -211,7 +217,8 @@ private function getViewImages(array $themes): array } /** - * Get unique image index + * Get unique image index. + * * @param array $imageData * @return string */ @@ -223,7 +230,8 @@ private function getUniqueImageIndex(array $imageData): string } /** - * Make image + * Make image. + * * @param string $originalImagePath * @param array $imageParams * @return Image @@ -241,7 +249,8 @@ private function makeImage(string $originalImagePath, array $imageParams): Image } /** - * Resize image + * Resize image. + * * @param array $viewImage * @param string $originalImagePath * @param string $originalImageName From 23f415a5d7f7f032a33f75ced47a76b4b422ef7e Mon Sep 17 00:00:00 2001 From: Maksym Novik Date: Fri, 1 Mar 2019 17:02:10 +0200 Subject: [PATCH 26/26] Static tests: forbid 'or' instead of '||' #21062. Added Squiz.Operators.ValidLogicalOperators rule --- dev/tests/static/framework/Magento/ruleset.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/tests/static/framework/Magento/ruleset.xml b/dev/tests/static/framework/Magento/ruleset.xml index d0f0d38f8fa03..9dde4b7bd7d32 100644 --- a/dev/tests/static/framework/Magento/ruleset.xml +++ b/dev/tests/static/framework/Magento/ruleset.xml @@ -84,5 +84,6 @@ +