From 1b8ea3f7c284a2146bcc496272d954908d8c1c0b Mon Sep 17 00:00:00 2001 From: Yu Tang Date: Fri, 5 Jun 2015 12:08:17 -0500 Subject: [PATCH 1/2] MAGETWO-37032: Port M1 Braintree V1 code to M2 using V.Zero PHP library - Fixed templates that uses prototype templates to use underscore template --- .../Block/Adminhtml/Form/Field/Minsaleqty.php | 7 +++++-- .../templates/system/config/form/field/array.phtml | 1 + .../Magento/Framework/View/Element/Html/Select.php | 2 +- .../Framework/View/Test/Unit/Element/Html/SelectTest.php | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php index b40e6b9fe3ebf..14205e21cdc2d 100644 --- a/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php +++ b/app/code/Magento/CatalogInventory/Block/Adminhtml/Form/Field/Minsaleqty.php @@ -60,9 +60,12 @@ protected function _prepareToRender() */ protected function _prepareArrayRow(\Magento\Framework\Object $row) { + $optionExtraAttr = []; + $optionExtraAttr['option_' . $this->_getGroupRenderer()->calcOptionHash($row->getData('customer_group_id'))] = + 'selected="selected"'; $row->setData( - 'option_extra_attr_' . $this->_getGroupRenderer()->calcOptionHash($row->getData('customer_group_id')), - 'selected="selected"' + 'option_extra_attrs', + $optionExtraAttr ); } } diff --git a/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml b/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml index c85f9314837ff..fcf805942d75c 100644 --- a/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml +++ b/app/code/Magento/Config/view/adminhtml/templates/system/config/form/field/array.phtml @@ -73,6 +73,7 @@ $_colspan = $block->isAddAfter() ? 2 : 1; templateValues = { getColumns() as $columnName => $column): ?> : '', + 'option_extra_attrs': {}, _id: '_' + d.getTime() + '_' + d.getMilliseconds() }; diff --git a/lib/internal/Magento/Framework/View/Element/Html/Select.php b/lib/internal/Magento/Framework/View/Element/Html/Select.php index 49c9563179ed5..ab54697632ace 100644 --- a/lib/internal/Magento/Framework/View/Element/Html/Select.php +++ b/lib/internal/Magento/Framework/View/Element/Html/Select.php @@ -193,7 +193,7 @@ protected function _optionToHtml($option, $selected = false) { $selectedHtml = $selected ? ' selected="selected"' : ''; if ($this->getIsRenderToJsTemplate() === true) { - $selectedHtml .= ' #{option_extra_attr_' . self::calcOptionHash($option['value']) . '}'; + $selectedHtml .= ' <%= option_extra_attrs.option_' . self::calcOptionHash($option['value']) . ' %>'; } $params = ''; diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php index f1c7564910154..d3660f32178ac 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Element/Html/SelectTest.php @@ -157,8 +157,9 @@ public function testGetHtmlJs() $this->select->setValue($selectedValue); $result = ''; $this->select->setIsRenderToJsTemplate(true); From 6f723ff5675956ff0f5b0dca349b0072c89437fc Mon Sep 17 00:00:00 2001 From: Yu Tang Date: Sat, 20 Jun 2015 07:23:50 -0500 Subject: [PATCH 2/2] MAGETWO-37032: Port M1 Braintree V1 code to M2 using V.Zero PHP library - Fix unit test failure --- app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index 62e3684db0609..a4f473ef75b3f 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -182,14 +182,14 @@ function ($value) { $this->transactionFactory = $this->getMock( 'Magento\Sales\Model\Order\Payment\TransactionFactory', - [], + ['create'], [], '', false ); $this->transactionCollectionFactory = $this->getMock( 'Magento\Sales\Model\Resource\Order\Payment\Transaction\CollectionFactory', - [], + ['create'], [], '', false