From 592bca3c7929cde67153f1316cb36eb10a174910 Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Tue, 19 Jun 2018 16:55:20 -0500 Subject: [PATCH 01/14] Adding test coverage for Group Repository not copying extension attributes. --- .../ResourceModel/GroupRepositoryTest.php | 46 +++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index 98cf8c212a784..ab206b9db3a8c 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -37,6 +37,11 @@ class GroupRepositoryTest extends \PHPUnit\Framework\TestCase * @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $group; + + /** + * @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $factoryCreatedGroup; /** * @var \Magento\Customer\Model\ResourceModel\Group|\PHPUnit_Framework_MockObject_MockObject @@ -153,6 +158,12 @@ private function setupGroupObjects() 'group', false ); + $this->factoryCreatedGroup = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\GroupInterface::class, + [], + 'group', + false + ); $this->groupResourceModel = $this->createMock(\Magento\Customer\Model\ResourceModel\Group::class); } @@ -162,16 +173,20 @@ public function testSave() $groupId = 0; $taxClass = $this->getMockForAbstractClass(\Magento\Tax\Api\Data\TaxClassInterface::class, [], '', false); + $groupExtensionAttributes = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupExtensionInterface::class); - $this->group->expects($this->once()) + $this->group->expects($this->atLeastOnce()) ->method('getCode') ->willReturn('Code'); $this->group->expects($this->atLeastOnce()) ->method('getId') ->willReturn($groupId); - $this->group->expects($this->once()) + $this->group->expects($this->atLeastOnce()) ->method('getTaxClassId') ->willReturn(17); + $this->group->expects($this->atLeastOnce()) + ->method('getExtensionAttributes') + ->willReturn($groupExtensionAttributes); $this->groupModel->expects($this->atLeastOnce()) ->method('getId') @@ -185,22 +200,34 @@ public function testSave() $this->groupModel->expects($this->atLeastOnce()) ->method('getTaxClassName') ->willReturn('Tax class name'); - $this->group->expects($this->once()) + + + $this->factoryCreatedGroup->expects($this->once()) ->method('setId') ->with($groupId) ->willReturnSelf(); - $this->group->expects($this->once()) + $this->factoryCreatedGroup->expects($this->once()) ->method('setCode') ->with('Code') ->willReturnSelf(); - $this->group->expects($this->once()) + $this->factoryCreatedGroup->expects($this->once()) ->method('setTaxClassId') ->with(234) ->willReturnSelf(); - $this->group->expects($this->once()) + $this->factoryCreatedGroup->expects($this->once()) ->method('setTaxClassName') ->with('Tax class name') ->willReturnSelf(); + $this->factoryCreatedGroup->expects($this->once()) + ->method('setExtensionAttributes') + ->with($groupExtensionAttributes) + ->willReturnSelf(); + $this->factoryCreatedGroup->expects($this->atLeastOnce()) + ->method('getCode') + ->willReturn('Code'); + $this->factoryCreatedGroup->expects($this->atLeastOnce()) + ->method('getTaxClassId') + ->willReturn(17); $this->taxClassRepository->expects($this->once()) ->method('get') @@ -229,9 +256,12 @@ public function testSave() ->with($groupId); $this->groupDataFactory->expects($this->once()) ->method('create') - ->willReturn($this->group); + ->willReturn($this->factoryCreatedGroup); + + $updatedGroup = $this->model->save($this->group); - $this->assertSame($this->group, $this->model->save($this->group)); + $this->assertSame($this->group->getCode(), $updatedGroup->getCode()); + $this->assertSame($this->group->getTaxClassId(), $updatedGroup->getTaxClassId()); } /** From df03a5062a6c5369a78d1e665d4d83ead03d10bb Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Tue, 19 Jun 2018 16:56:20 -0500 Subject: [PATCH 02/14] Including extension attributes when returning new group details --- .../Magento/Customer/Model/ResourceModel/GroupRepository.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php index d004b99c5a3c9..0f294c3dab1df 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php @@ -156,6 +156,11 @@ public function save(\Magento\Customer\Api\Data\GroupInterface $group) ->setCode($groupModel->getCode()) ->setTaxClassId($groupModel->getTaxClassId()) ->setTaxClassName($groupModel->getTaxClassName()); + + if ($group->getExtensionAttributes()) { + $groupDataObject->setExtensionAttributes($group->getExtensionAttributes()); + } + return $groupDataObject; } From 5529aac4843af111d71dbae609bfda4518001f6d Mon Sep 17 00:00:00 2001 From: Joseph Maxwell Date: Tue, 19 Jun 2018 17:26:34 -0500 Subject: [PATCH 03/14] Updating group repository test to fix code standards problem --- .../Test/Unit/Model/ResourceModel/GroupRepositoryTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index ab206b9db3a8c..692d3b8737d02 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -173,7 +173,7 @@ public function testSave() $groupId = 0; $taxClass = $this->getMockForAbstractClass(\Magento\Tax\Api\Data\TaxClassInterface::class, [], '', false); - $groupExtensionAttributes = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupExtensionInterface::class); + $extensionAttributes = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupExtensionInterface::class); $this->group->expects($this->atLeastOnce()) ->method('getCode') @@ -186,7 +186,7 @@ public function testSave() ->willReturn(17); $this->group->expects($this->atLeastOnce()) ->method('getExtensionAttributes') - ->willReturn($groupExtensionAttributes); + ->willReturn($extensionAttributes); $this->groupModel->expects($this->atLeastOnce()) ->method('getId') @@ -220,7 +220,7 @@ public function testSave() ->willReturnSelf(); $this->factoryCreatedGroup->expects($this->once()) ->method('setExtensionAttributes') - ->with($groupExtensionAttributes) + ->with($extensionAttributes) ->willReturnSelf(); $this->factoryCreatedGroup->expects($this->atLeastOnce()) ->method('getCode') From a6de725df53a0ee20698e488d9176ae8aaca5dce Mon Sep 17 00:00:00 2001 From: Vishal Gelani Date: Wed, 20 Jun 2018 08:54:09 +0530 Subject: [PATCH 04/14] Update GroupRepository.php --- .../Magento/Customer/Model/ResourceModel/GroupRepository.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php index 0f294c3dab1df..af48299ad98ee 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php @@ -155,12 +155,11 @@ public function save(\Magento\Customer\Api\Data\GroupInterface $group) ->setId($groupModel->getId()) ->setCode($groupModel->getCode()) ->setTaxClassId($groupModel->getTaxClassId()) - ->setTaxClassName($groupModel->getTaxClassName()); - + ->setTaxClassName($groupModel->getTaxClassName()); if ($group->getExtensionAttributes()) { $groupDataObject->setExtensionAttributes($group->getExtensionAttributes()); } - + return $groupDataObject; } From 56fe65107ceaa6d9ff0748ca1956a2735bf709ff Mon Sep 17 00:00:00 2001 From: Vishal Gelani Date: Wed, 20 Jun 2018 08:55:01 +0530 Subject: [PATCH 05/14] Update GroupRepositoryTest.php --- .../Test/Unit/Model/ResourceModel/GroupRepositoryTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index 692d3b8737d02..b2d132665362b 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -37,7 +37,7 @@ class GroupRepositoryTest extends \PHPUnit\Framework\TestCase * @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $group; - + /** * @var \Magento\Customer\Api\Data\GroupInterface|\PHPUnit_Framework_MockObject_MockObject */ @@ -173,7 +173,9 @@ public function testSave() $groupId = 0; $taxClass = $this->getMockForAbstractClass(\Magento\Tax\Api\Data\TaxClassInterface::class, [], '', false); - $extensionAttributes = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\GroupExtensionInterface::class); + $extensionAttributes = $this->getMockForAbstractClass( + \Magento\Customer\Api\Data\GroupExtensionInterface::class + ); $this->group->expects($this->atLeastOnce()) ->method('getCode') From c86a1016820b0672c81e54269541ba10aadc0a88 Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta Date: Fri, 22 Jun 2018 18:05:15 +0200 Subject: [PATCH 06/14] Update GroupRepositoryTest.php Simple CS fix: Removed double empty space. --- .../Test/Unit/Model/ResourceModel/GroupRepositoryTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php index b2d132665362b..9e8440b500989 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/GroupRepositoryTest.php @@ -202,8 +202,7 @@ public function testSave() $this->groupModel->expects($this->atLeastOnce()) ->method('getTaxClassName') ->willReturn('Tax class name'); - - + $this->factoryCreatedGroup->expects($this->once()) ->method('setId') ->with($groupId) From daf66cb5d906606ffcfe8afc1409d4e182b17c9c Mon Sep 17 00:00:00 2001 From: Riccardo Tempesta Date: Fri, 22 Jun 2018 21:04:27 +0200 Subject: [PATCH 07/14] CS FIX Removed empty spaces --- .../Magento/Customer/Model/ResourceModel/GroupRepository.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php index af48299ad98ee..89c096a9f6585 100644 --- a/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php +++ b/app/code/Magento/Customer/Model/ResourceModel/GroupRepository.php @@ -155,11 +155,12 @@ public function save(\Magento\Customer\Api\Data\GroupInterface $group) ->setId($groupModel->getId()) ->setCode($groupModel->getCode()) ->setTaxClassId($groupModel->getTaxClassId()) - ->setTaxClassName($groupModel->getTaxClassName()); + ->setTaxClassName($groupModel->getTaxClassName()); + if ($group->getExtensionAttributes()) { $groupDataObject->setExtensionAttributes($group->getExtensionAttributes()); } - + return $groupDataObject; } From 3c0372bfb2e85d5ad7db3be20e8c92268e6bca73 Mon Sep 17 00:00:00 2001 From: Alexander Shkurko Date: Sun, 1 Jul 2018 18:19:20 +0300 Subject: [PATCH 08/14] [FIX] dev:di:info duplicates plugin info --- app/code/Magento/Developer/Model/Di/PluginList.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 0a1df8a974242..39b978ac6fd93 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -143,9 +143,8 @@ private function addPluginToList($pluginInstance, $pluginMethod, $methodTypes, $ { if ($methodTypes & $typeCode) { if (!array_key_exists($pluginInstance, $this->pluginList[$this->pluginTypeMapping[$typeCode]])) { - $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = []; + $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod; } - $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod ; } } } From bbb0d243c6ba4f2808d0f4fa72eb61fdebdb3420 Mon Sep 17 00:00:00 2001 From: "Leandro F. L" Date: Mon, 2 Jul 2018 20:21:18 +0200 Subject: [PATCH 09/14] Variable as a method parameter might be overridden by the loop --- app/code/Magento/Bundle/Model/Product/Type.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Bundle/Model/Product/Type.php b/app/code/Magento/Bundle/Model/Product/Type.php index 91e002735a0a6..bec77bce1d879 100644 --- a/app/code/Magento/Bundle/Model/Product/Type.php +++ b/app/code/Magento/Bundle/Model/Product/Type.php @@ -536,12 +536,12 @@ public function updateQtyOption($options, \Magento\Framework\DataObject $option, foreach ($selections as $selection) { if ($selection->getProductId() == $optionProduct->getId()) { - foreach ($options as &$option) { - if ($option->getCode() == 'selection_qty_' . $selection->getSelectionId()) { + foreach ($options as $quoteItemOption) { + if ($quoteItemOption->getCode() == 'selection_qty_' . $selection->getSelectionId()) { if ($optionUpdateFlag) { - $option->setValue(intval($option->getValue())); + $quoteItemOption->setValue(intval($quoteItemOption->getValue())); } else { - $option->setValue($value); + $quoteItemOption->setValue($value); } } } From 3f70b119ac32e109eac852b82bfe2339a0367b84 Mon Sep 17 00:00:00 2001 From: Alexander Shkurko Date: Tue, 3 Jul 2018 20:55:06 +0300 Subject: [PATCH 10/14] Fix according review - change how we manage that plugin in a property array --- app/code/Magento/Developer/Model/Di/PluginList.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Developer/Model/Di/PluginList.php b/app/code/Magento/Developer/Model/Di/PluginList.php index 39b978ac6fd93..fc342b5051000 100644 --- a/app/code/Magento/Developer/Model/Di/PluginList.php +++ b/app/code/Magento/Developer/Model/Di/PluginList.php @@ -143,6 +143,10 @@ private function addPluginToList($pluginInstance, $pluginMethod, $methodTypes, $ { if ($methodTypes & $typeCode) { if (!array_key_exists($pluginInstance, $this->pluginList[$this->pluginTypeMapping[$typeCode]])) { + $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = []; + } + + if (!in_array($pluginMethod, $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance])) { $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod; } } From 873471a3064c831af1b2eb22e56af939e44e97a0 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara Date: Thu, 5 Jul 2018 19:32:24 +0530 Subject: [PATCH 11/14] Trim email address in newsletter subscribe form --- .../Magento/Newsletter/view/frontend/templates/subscribe.phtml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml b/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml index b633c61d9dc35..b2e0edbf04452 100644 --- a/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml +++ b/app/code/Magento/Newsletter/view/frontend/templates/subscribe.phtml @@ -23,6 +23,7 @@
From 9d84b2cc8a2cf2de7506b9809b035ed0077ac0eb Mon Sep 17 00:00:00 2001 From: Piyush Dankhara Date: Thu, 5 Jul 2018 19:34:58 +0530 Subject: [PATCH 12/14] Trim email address in forgot password form --- .../Customer/view/frontend/templates/form/forgotpassword.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml b/app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml index 5bc4a929d6d94..f8eb0bd44b681 100644 --- a/app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/form/forgotpassword.phtml @@ -20,7 +20,7 @@ getChildHtml('form_additional_info') ?> From d495275f4b65d16dbd6fda682b2c94e7cf4e6a02 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara Date: Thu, 5 Jul 2018 19:35:11 +0530 Subject: [PATCH 13/14] Trim email address in checkout page login form --- .../view/frontend/web/template/form/element/email.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/template/form/element/email.html b/app/code/Magento/Checkout/view/frontend/web/template/form/element/email.html index bb68e24835b67..8d6142e07fcf0 100644 --- a/app/code/Magento/Checkout/view/frontend/web/template/form/element/email.html +++ b/app/code/Magento/Checkout/view/frontend/web/template/form/element/email.html @@ -22,7 +22,8 @@ type="email" data-bind=" textInput: email, - hasFocus: emailFocused" + hasFocus: emailFocused, + mageInit: {'mage/trim-input':{}}" name="username" data-validate="{required:true, 'validate-email':true}" id="customer-email" /> From b827bd19118c1de262d99c1ea9fd3f3a22c51872 Mon Sep 17 00:00:00 2001 From: Piyush Dankhara Date: Thu, 5 Jul 2018 19:35:43 +0530 Subject: [PATCH 14/14] Trim email address in email to a friend form --- .../Magento/SendFriend/view/frontend/templates/send.phtml | 4 +++- app/code/Magento/Theme/view/frontend/web/js/row-builder.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/SendFriend/view/frontend/templates/send.phtml b/app/code/Magento/SendFriend/view/frontend/templates/send.phtml index 7a972cd5f01c5..3342530f01eb5 100644 --- a/app/code/Magento/SendFriend/view/frontend/templates/send.phtml +++ b/app/code/Magento/SendFriend/view/frontend/templates/send.phtml @@ -35,6 +35,7 @@
@@ -72,7 +73,8 @@
diff --git a/app/code/Magento/Theme/view/frontend/web/js/row-builder.js b/app/code/Magento/Theme/view/frontend/web/js/row-builder.js index 62537c8b1b899..7785ced2e4bd5 100644 --- a/app/code/Magento/Theme/view/frontend/web/js/row-builder.js +++ b/app/code/Magento/Theme/view/frontend/web/js/row-builder.js @@ -144,7 +144,7 @@ define([ $(tmpl).appendTo(row); - $(this.options.rowContainer).append(row); + $(this.options.rowContainer).append(row).trigger('contentUpdated'); row.addClass(this.options.additionalRowClass);