From 15c31e13080c511d00a103013fcf0d98ac48dff3 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Mon, 16 May 2016 13:25:56 +0300 Subject: [PATCH 01/57] MAGETWO-52785: Save button doesn't work on category edit page --- lib/web/mage/validation.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 26cd61df45c80..b809c92830e03 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -1423,11 +1423,17 @@ var errors = {}, valid = true, validateConfig = { - errorElement: 'label' + errorElement: 'label', + ignore: '.ignore-validate' }, form, validator, classes; - element = $(element); + element = $(element).not(validateConfig.ignore); + + if (!element.length) { + return true; + } + form = element.get(0).form; validator = form ? $(form).data('validator') : null; From 3d398cf790aa217eacc2393eaea18496a4ab77d3 Mon Sep 17 00:00:00 2001 From: Elena Marchenko Date: Mon, 16 May 2016 18:25:48 +0300 Subject: [PATCH 02/57] MAGETWO-52696: Fix ExpressCheckoutOnePageTest and ExpressCheckoutFromProductPageTest tests --- .../Paypal/Test/Block/Sandbox/SignupCreate.php | 2 +- .../ExpressCheckoutFromProductPageTest.xml | 2 +- .../ExpressCheckoutFromShoppingCartTest.xml | 14 +++++++------- .../TestStep/ExpressCheckoutOrderPlaceStep.php | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupCreate.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupCreate.php index a727c88a719f4..217e691205a6f 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupCreate.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupCreate.php @@ -19,7 +19,7 @@ class SignupCreate extends Form * * @var string */ - protected $termsAgree = '#termsAgree'; + protected $termsAgree = '#termsAgreeLabel span'; /** * Continue personal account signup button. diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml index 6105e8a65af43..4373523471cff 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromProductPageTest.xml @@ -27,7 +27,7 @@ paypal_express paypal_express, freeshipping - test_type:3rd_party_test_deprecated + test_type:3rd_party_test diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml index 5441a4749949c..b2e9ce9b56327 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestCase/ExpressCheckoutFromShoppingCartTest.xml @@ -8,25 +8,25 @@ - catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option, bundleProduct::fixed_100_dollar_with_required_options + catalogProductSimple::simple_10_dollar, configurableProduct::with_one_option, bundleProduct::bundle_fixed_100_dollar_product us_ca_ny_rule - sandbox_us_default + sandbox_us_default guest Fixed Flat Rate - 131.00 + 121.00 - 131.00 - 10.81 + 121.00 + 9.98 15.00 - 156.81 + 145.98 payflowpro - test_type:3rd_party_test_deprecated + test_type:3rd_party_test diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php index efb5afd2e38a5..60109c51ed255 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/TestStep/ExpressCheckoutOrderPlaceStep.php @@ -87,7 +87,7 @@ public function __construct( CheckoutOnepage $checkoutOnepage, CheckoutOnepageSuccess $checkoutOnepageSuccess, FixtureFactory $fixtureFactory, - array $products, + array $products = [], array $shipping = [], array $prices = [] ) { From 8be48f1e886319640853d94eec089c8ff4b452fa Mon Sep 17 00:00:00 2001 From: Elena Marchenko Date: Tue, 17 May 2016 13:05:18 +0300 Subject: [PATCH 03/57] MAGETWO-52696: Fix ExpressCheckoutOnePageTest and ExpressCheckoutFromProductPageTest tests --- .../app/Magento/Paypal/Test/Block/Sandbox/SignupAddCard.php | 1 + .../app/Magento/Paypal/Test/Repository/SandboxCustomer.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupAddCard.php b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupAddCard.php index 9f9edc52d601c..d1be4525c61d2 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupAddCard.php +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Block/Sandbox/SignupAddCard.php @@ -27,6 +27,7 @@ class SignupAddCard extends Form */ public function linkCardToAccount() { + $this->browser->selectWindow(); $this->_rootElement->find($this->linkCard)->click(); } } diff --git a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/SandboxCustomer.xml b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/SandboxCustomer.xml index 8bd0c3cc86002..7443516c3a70f 100644 --- a/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/SandboxCustomer.xml +++ b/dev/tests/functional/tests/app/Magento/Paypal/Test/Repository/SandboxCustomer.xml @@ -18,7 +18,7 @@ CA 90230 555-55-555-55 - 4032037915119131 + 4032034402702800 05/20 123 From b85c6e0a78ee354040bfd988a91ea5cdded97e3e Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Wed, 18 May 2016 14:04:04 +0300 Subject: [PATCH 04/57] MAGETWO-52781: DeleteSavedCreditCardTest is failing on credit card deletion --- .../tests/app/Magento/Vault/Test/Block/CreditCards.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php index 8f55c177661bf..1869cf3673f2f 100644 --- a/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php +++ b/dev/tests/functional/tests/app/Magento/Vault/Test/Block/CreditCards.php @@ -44,7 +44,7 @@ public function getCreditCards() foreach ($elements as $row) { $number = substr($row->find('./td[@data-th="Card Number"]', Locator::SELECTOR_XPATH)->getText(), -4, 4); $deleteButton = $row->find( - "./td[contains(text(), '{$number}')]/following-sibling::td[@data-th='Actions']//span[text()='Delete']", + "./td[text()[contains(.,'{$number}')]]/following-sibling::td[@data-th='Actions']//span[text()='Delete']", Locator::SELECTOR_XPATH ); $result[$number] = $deleteButton; From cd13a85fa7594a1d24af7cff1509011c04bb0f28 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Wed, 18 May 2016 16:10:01 +0300 Subject: [PATCH 05/57] MAGETWO-52101: Mark insecure methods as deprecated in Message\ManagerInterface --- lib/internal/Magento/Framework/Message/ManagerInterface.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/internal/Magento/Framework/Message/ManagerInterface.php b/lib/internal/Magento/Framework/Message/ManagerInterface.php index 7fee32dc10c0e..08d8ea91b139a 100644 --- a/lib/internal/Magento/Framework/Message/ManagerInterface.php +++ b/lib/internal/Magento/Framework/Message/ManagerInterface.php @@ -52,6 +52,7 @@ public function addMessages(array $messages, $group = null); * @param string $message * @param string|null $group * @return ManagerInterface + * @deprecated * @see \Magento\Framework\Message\ManagerInterface::addErrorMessage */ public function addError($message, $group = null); @@ -62,6 +63,7 @@ public function addError($message, $group = null); * @param string $message * @param string|null $group * @return ManagerInterface + * @deprecated * @see \Magento\Framework\Message\ManagerInterface::addWarningMessage */ public function addWarning($message, $group = null); @@ -72,6 +74,7 @@ public function addWarning($message, $group = null); * @param string $message * @param string|null $group * @return ManagerInterface + * @deprecated * @see \Magento\Framework\Message\ManagerInterface::addNoticeMessage */ public function addNotice($message, $group = null); @@ -82,6 +85,7 @@ public function addNotice($message, $group = null); * @param string $message * @param string|null $group * @return ManagerInterface + * @deprecated * @see \Magento\Framework\Message\ManagerInterface::addSuccessMessage */ public function addSuccess($message, $group = null); @@ -178,6 +182,8 @@ public function addUniqueMessages(array $messages, $group = null); * @param string $alternativeText * @param string|null $group * @return ManagerInterface + * @deprecated + * @see \Magento\Framework\Message\ManagerInterface::addExceptionMessage */ public function addException(\Exception $exception, $alternativeText, $group = null); From bbe125d291832bb7da5e9507f677bda8cd740cdb Mon Sep 17 00:00:00 2001 From: "Yushkin, Dmytro" Date: Wed, 18 May 2016 18:58:58 +0300 Subject: [PATCH 06/57] MAGETWO-52552: [Github] Invoice status not changed after capturing saved invoice #4385 --- .../Invoice/AbstractInvoice/View.php | 36 +++++++++--- .../Order/Invoice/AddCommentTest.php | 42 ++++++-------- .../Adminhtml/Order/Invoice/CancelTest.php | 57 +++++++------------ .../Adminhtml/Order/Invoice/CaptureTest.php | 57 +++++++------------ .../Adminhtml/Order/Invoice/ViewTest.php | 45 ++++++--------- .../Adminhtml/Order/Invoice/VoidTest.php | 48 +++++++--------- 6 files changed, 125 insertions(+), 160 deletions(-) diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php index 25fb917184b32..2960f88190625 100644 --- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php +++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php @@ -7,7 +7,10 @@ namespace Magento\Sales\Controller\Adminhtml\Invoice\AbstractInvoice; use Magento\Backend\App\Action\Context; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Registry; +use Magento\Sales\Api\InvoiceRepositoryInterface; +use Magento\Sales\Model\Order\InvoiceRepository; abstract class View extends \Magento\Backend\App\Action { @@ -28,6 +31,11 @@ abstract class View extends \Magento\Backend\App\Action */ protected $resultForwardFactory; + /** + * @var InvoiceRepositoryInterface + */ + protected $invoiceRepository; + /** * @param Context $context * @param Registry $registry @@ -66,16 +74,28 @@ public function execute() */ protected function getInvoice() { - $invoiceId = $this->getRequest()->getParam('invoice_id'); - if (!$invoiceId) { + try { + $invoice = $this->getInvoiceRepository() + ->get($this->getRequest()->getParam('invoice_id')); + $this->registry->register('current_invoice', $invoice); + } catch (\Exception $e) { + $this->messageManager->addError(__('Invoice capturing error')); return false; } - /** @var \Magento\Sales\Model\Order\Invoice $invoice */ - $invoice = $this->_objectManager->create('Magento\Sales\Api\InvoiceRepositoryInterface')->get($invoiceId); - if (!$invoice) { - return false; - } - $this->registry->register('current_invoice', $invoice); + return $invoice; } + + /** + * @return InvoiceRepository + */ + private function getInvoiceRepository() + { + if ($this->invoiceRepository === null) { + $this->invoiceRepository = ObjectManager::getInstance() + ->get(InvoiceRepositoryInterface::class); + } + + return $this->invoiceRepository; + } } diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php index 93d776a35d1f1..33d89a4173706 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php @@ -7,10 +7,12 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class AddCommentTest * @package Magento\Sales\Controller\Adminhtml\Order\Invoice + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AddCommentTest extends \PHPUnit_Framework_TestCase { @@ -34,11 +36,6 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected $viewMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $objectManagerMock; - /** * @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ @@ -79,6 +76,11 @@ class AddCommentTest extends \PHPUnit_Framework_TestCase */ protected $resultJsonMock; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * SetUp method * @@ -104,10 +106,6 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') - ->disableOriginalConstructor() - ->setMethods([]) - ->getMock(); $this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page') ->disableOriginalConstructor() ->getMock(); @@ -133,9 +131,6 @@ protected function setUp() $contextMock->expects($this->any()) ->method('getView') ->will($this->returnValue($this->viewMock)); - $contextMock->expects($this->any()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); $this->viewMock->expects($this->any()) ->method('getPage') ->willReturn($this->resultPageMock); @@ -150,26 +145,26 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); - $this->resultRawFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\RawFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultJsonFactoryMock = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->commentSenderMock = $this->getMockBuilder('Magento\Sales\Model\Order\Email\Sender\InvoiceCommentSender') ->disableOriginalConstructor() ->setMethods([]) ->getMock(); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\AddComment', [ @@ -180,6 +175,12 @@ protected function setUp() 'resultJsonFactory' => $this->resultJsonFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -218,16 +219,9 @@ public function testExecute() $invoiceMock->expects($this->once()) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); $commentsBlockMock = $this->getMockBuilder('Magento\Sales\Block\Adminhtml\Order\Invoice\View\Comments') ->disableOriginalConstructor() diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php index 6331e60c69d1c..56c3cf42146a8 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CancelTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class CancelTest @@ -64,6 +65,11 @@ class CancelTest extends \PHPUnit_Framework_TestCase */ protected $controller; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void */ @@ -141,6 +147,10 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Cancel', [ @@ -148,6 +158,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -196,18 +212,11 @@ public function testExecute() ->method('addSuccess') ->with('You canceled the invoice.'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(1)) + $this->objectManagerMock->expects($this->once()) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -241,18 +250,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->setMethods([]) @@ -297,18 +298,10 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) @@ -353,18 +346,10 @@ public function testExecuteException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php index e74264e8fb681..88d39a0a885f0 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/CaptureTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class CaptureTest @@ -69,6 +70,11 @@ class CaptureTest extends \PHPUnit_Framework_TestCase */ protected $invoiceManagement; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void */ @@ -149,11 +155,13 @@ protected function setUp() $this->invoiceManagement = $this->getMockBuilder('Magento\Sales\Api\InvoiceManagementInterface') ->disableOriginalConstructor() ->getMock(); - $this->objectManagerMock->expects($this->any()) ->method('get') ->with('Magento\Sales\Api\InvoiceManagementInterface') ->willReturn($this->invoiceManagement); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Capture', @@ -162,6 +170,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock, ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -219,18 +233,11 @@ public function testExecute() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(2)) + $this->objectManagerMock->expects($this->at(1)) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -259,18 +266,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->getMock(); @@ -318,18 +317,10 @@ public function testExecuteModelException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->getMock(); @@ -377,18 +368,10 @@ public function testExecuteException() ->method('getEntityId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultRedirect = $this->getMockBuilder('Magento\Backend\Model\View\Result\Redirect') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php index 8e4ade54c2911..1a6ca7c8b3e22 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/ViewTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class ViewTest @@ -49,11 +50,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected $invoiceLoaderMock; - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $objectManagerMock; - /** * @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ @@ -84,6 +80,11 @@ class ViewTest extends \PHPUnit_Framework_TestCase */ protected $resultForwardFactoryMock; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + protected function setUp() { $objectManager = new ObjectManager($this); @@ -112,7 +113,6 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['getCommentText', 'setIsUrlNotice']) ->getMock(); - $this->objectManagerMock = $this->getMock('Magento\Framework\ObjectManagerInterface'); $this->resultPageMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') ->disableOriginalConstructor() ->getMock(); @@ -145,9 +145,6 @@ protected function setUp() $contextMock->expects($this->any()) ->method('getSession') ->will($this->returnValue($this->sessionMock)); - $contextMock->expects($this->any()) - ->method('getObjectManager') - ->will($this->returnValue($this->objectManagerMock)); $this->viewMock->expects($this->any()) ->method('getPage') ->willReturn($this->resultPageMock); @@ -162,11 +159,13 @@ protected function setUp() ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); - $this->resultForwardFactoryMock = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\View', @@ -176,6 +175,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } public function testExecute() @@ -226,18 +231,10 @@ public function testExecute() ->setMethods([]) ->getMock(); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->resultPageMock->expects($this->once())->method('setActiveMenu')->with('Magento_Sales::sales_order'); $this->resultPageFactoryMock->expects($this->once()) @@ -256,18 +253,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') ->disableOriginalConstructor() ->setMethods([]) diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php index 4cd66680b139d..305c55ba63dca 100644 --- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php +++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/VoidTest.php @@ -7,6 +7,7 @@ use Magento\Backend\App\Action; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +use Magento\Sales\Api\InvoiceRepositoryInterface; /** * Class VoidTest @@ -74,8 +75,14 @@ class VoidTest extends \PHPUnit_Framework_TestCase */ protected $invoiceManagement; + /** + * @var InvoiceRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $invoiceRepository; + /** * @return void + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function setUp() { @@ -167,6 +174,10 @@ protected function setUp() ->method('getResultRedirectFactory') ->willReturn($this->resultRedirectFactoryMock); + $this->invoiceRepository = $this->getMockBuilder(InvoiceRepositoryInterface::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + $this->controller = $objectManager->getObject( 'Magento\Sales\Controller\Adminhtml\Order\Invoice\Void', [ @@ -174,6 +185,12 @@ protected function setUp() 'resultForwardFactory' => $this->resultForwardFactoryMock ] ); + + $objectManager->setBackwardCompatibleProperty( + $this->controller, + 'invoiceRepository', + $this->invoiceRepository + ); } /** @@ -225,18 +242,11 @@ public function testExecute() $transactionMock->expects($this->at(2)) ->method('save'); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->at(0)) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->objectManagerMock->expects($this->at(2)) + $this->objectManagerMock->expects($this->at(1)) ->method('create') ->with('Magento\Framework\DB\Transaction') ->will($this->returnValue($transactionMock)); @@ -270,18 +280,10 @@ public function testExecuteNoInvoice() ->with('invoice_id') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn(null); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->messageManagerMock->expects($this->never()) ->method('addError'); $this->messageManagerMock->expects($this->never()) @@ -329,18 +331,10 @@ public function testExecuteModelException() ->method('getId') ->will($this->returnValue($invoiceId)); - $invoiceRepository = $this->getMockBuilder('Magento\Sales\Api\InvoiceRepositoryInterface') - ->disableOriginalConstructor() - ->getMock(); - $invoiceRepository->expects($this->any()) + $this->invoiceRepository->expects($this->once()) ->method('get') ->willReturn($invoiceMock); - $this->objectManagerMock->expects($this->once()) - ->method('create') - ->with('Magento\Sales\Api\InvoiceRepositoryInterface') - ->willReturn($invoiceRepository); - $this->messageManagerMock->expects($this->once()) ->method('addError'); From 07b49c76126ca244cfd80d68ef8f1117181d57fd Mon Sep 17 00:00:00 2001 From: Denys Rul Date: Mon, 23 May 2016 11:33:11 +0300 Subject: [PATCH 07/57] MAGETWO-50522: Wysiwyg editor is removing html5 tags - Implement and apply HTML5 schema based on the data used in TinyMCE 4.x --- .../wysiwyg/tiny_mce/html5-schema.js | 204 ++++++++++++++++++ .../mage/adminhtml/wysiwyg/tiny_mce/setup.js | 48 ++++- 2 files changed, 243 insertions(+), 9 deletions(-) create mode 100644 lib/web/mage/adminhtml/wysiwyg/tiny_mce/html5-schema.js diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/html5-schema.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/html5-schema.js new file mode 100644 index 0000000000000..a74a9f12fb2df --- /dev/null +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/html5-schema.js @@ -0,0 +1,204 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +define([ + 'underscore' +], function (_) { + 'use strict'; + + /* eslint-disable max-len */ + + var schema = { + blockContent: [ + 'address', 'article', 'aside', 'blockquote', 'details', 'dialog', 'div', 'dl', 'fieldset', + 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', + 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul' + ], + phrasingContent: [ + '#comment', '#text', 'a', 'abbr', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', + 'cite','code', 'command', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img', + 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'meter', 'noscript', 'object', + 'output', 'picture', 'progress', 'q', 'ruby', 's', 'samp', 'script', 'select', 'small', + 'span', 'strong', 'sub', 'sup', 'textarea', 'time', 'u', 'var', 'video', 'wbr' + ], + blockElements: [ + 'address', 'article', 'aside', 'blockquote', 'caption', 'center', 'datalist', 'dd', 'dir', 'div', + 'dl', 'dt', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', + 'header', 'hgroup', 'hr', 'isindex', 'li', 'menu', 'nav', 'noscript', 'ol', 'optgroup', 'option', + 'p', 'pre', 'section', 'select', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul' + ], + boolAttrs: [ + 'autoplay', 'checked', 'compact', 'controls', 'declare', 'defer', 'disabled', 'ismap', 'loop', + 'multiple', 'nohref', 'noresize', 'noshade', 'nowrap', 'readonly', 'selected' + ], + shortEnded: [ + 'area', 'base', 'basefont', 'br', 'col', 'embed', 'frame', 'hr', 'img', 'input', 'isindex', + 'link', 'meta', 'param', 'source', 'track', 'wbr' + ], + whiteSpace: [ + 'audio', 'iframe', 'noscript', 'object', 'pre', 'script', 'style', 'textarea', 'video' + ], + selfClosing: [ + 'colgroup', 'dd', 'dt', 'li', 'option', 'p', 'td', 'tfoot', 'th', 'thead', 'tr' + ] + }; + + schema.flowContent = schema.blockContent.concat(schema.phrasingContent, ['style']); + schema.nonEmpty = ['td', 'th', 'iframe', 'video', 'audio', 'object', 'script'].concat(schema.shortEnded); + + _.extend(schema, (function (phrasingContent, flowContent) { + var validElements = [], + validChildren = [], + compiled = {}, + globalAttrs, + rawData; + + globalAttrs = [ + 'id', 'dir', 'lang', 'class', 'style', 'title', 'hidden', 'onclick', 'onkeyup', + 'tabindex', 'dropzone', 'accesskey', 'draggable', 'translate', 'onmouseup', + 'onkeydown', 'spellcheck', 'ondblclick', 'onmouseout', 'onkeypress', 'contextmenu', + 'onmousedown', 'onmouseover', 'onmousemove', 'contenteditable' + ]; + + rawData = [ + ['html', 'manifest', 'head body'], + ['head', '', 'base command link meta noscript script style title'], + ['title hr noscript br'], + ['base', 'href target'], + ['link', 'href rel media hreflang type sizes hreflang'], + ['meta', 'name http-equiv content charset'], + ['style', 'media type scoped'], + ['script', 'src async defer type charset'], + ['body', 'onafterprint onbeforeprint onbeforeunload onblur onerror onfocus ' + + 'onhashchange onload onmessage onoffline ononline onpagehide onpageshow ' + + 'onpopstate onresize onscroll onstorage onunload background bgcolor text link vlink alink', flowContent + ], + ['caption', '', _.without(flowContent, 'table')], + ['address dt dd div', '', flowContent], + ['h1 h2 h3 h4 h5 h6 pre p abbr code var samp kbd sub sup i b u bdo span legend em strong small s cite dfn', '', phrasingContent], + ['blockquote', 'cite', flowContent], + ['ol', 'reversed start type', 'li'], + ['ul', 'type compact', 'li'], + ['li', 'value type', flowContent], + ['dl', '', 'dt dd'], + ['a', 'href target rel media hreflang type charset name rev shape coords download', phrasingContent], + ['q', 'cite', phrasingContent], + ['ins del', 'cite datetime', flowContent], + ['img', 'src sizes srcset alt usemap ismap width height name longdesc align border hspace vspace'], + ['iframe', 'src name width height longdesc frameborder marginwidth marginheight scrolling align sandbox seamless allowfullscreen', flowContent], + ['embed', 'src type width height'], + ['object', 'data type typemustmatch name usemap form width height declare classid code codebase codetype archive standby align border hspace vspace', flowContent.concat(['param'])], + ['param', 'name value valuetype type'], + ['map', 'name', flowContent.concat(['area'])], + ['area', 'alt coords shape href target rel media hreflang type nohref'], + ['table', 'border summary width frame rules cellspacing cellpadding align bgcolor', 'caption colgroup thead tfoot tbody tr col'], + ['colgroup', 'span width align char charoff valign', 'col'], + ['col', 'span'], + ['tbody thead tfoot', 'align char charoff valign', 'tr'], + ['tr', 'align char charoff valign bgcolor', 'td th'], + ['td', 'colspan rowspan headers abbr axis scope align char charoff valign nowrap bgcolor width height', flowContent], + ['th', 'colspan rowspan headers scope abbr axis align char charoff valign nowrap bgcolor width height accept', flowContent], + ['form', 'accept-charset action autocomplete enctype method name novalidate target onsubmit onreset', flowContent], + ['fieldset', 'disabled form name', flowContent.concat(['legend'])], + ['label', 'form for', phrasingContent], + ['input', 'accept alt autocomplete checked dirname disabled form formaction formenctype formmethod formnovalidate ' + + 'formtarget height list max maxlength min multiple name pattern readonly required size src step type value width usemap align' + ], + ['button', 'disabled form formaction formenctype formmethod formnovalidate formtarget name type value', phrasingContent], + ['select', 'disabled form multiple name required size onfocus onblur onchange', 'option optgroup'], + ['optgroup', 'disabled label', 'option'], + ['option', 'disabled label selected value'], + ['textarea', 'cols dirname disabled form maxlength name readonly required rows wrap'], + ['menu', 'type label', flowContent.concat(['li'])], + ['noscript', '', flowContent], + ['wbr'], + ['ruby', '', phrasingContent.concat(['rt', 'rp'])], + ['figcaption', '', flowContent], + ['mark rt rp summary bdi', '', phrasingContent], + ['canvas', 'width height', flowContent], + ['video', 'src crossorigin poster preload autoplay mediagroup loop muted controls width height buffered', flowContent.concat(['track', 'source'])], + ['audio', 'src crossorigin preload autoplay mediagroup loop muted controls buffered volume', flowContent.concat(['track', 'source'])], + ['picture', '', 'img source'], + ['source', 'src srcset type media sizes'], + ['track', 'kind src srclang label default'], + ['datalist', '', phrasingContent.concat(['option'])], + ['article section nav aside header footer', '', flowContent], + ['hgroup', '', 'h1 h2 h3 h4 h5 h6'], + ['figure', '', flowContent.concat(['figcaption'])], + ['time', 'datetime', phrasingContent], + ['dialog', 'open', flowContent], + ['command', 'type label icon disabled checked radiogroup command'], + ['output', 'for form name', phrasingContent], + ['progress', 'value max', phrasingContent], + ['meter', 'value min max low high optimum', phrasingContent], + ['details', 'open', flowContent.concat(['summary'])], + ['keygen', 'autofocus challenge disabled form keytype name'], + ['script', 'language xml:space'], + ['style', 'xml:space'], + ['embed', 'align name hspace vspace'], + ['br', 'clear'], + ['applet', 'codebase archive code object alt name width height align hspace vspace'], + ['font basefont', 'size color face'], + ['h1 h2 h3 h4 h5 h6 div p legend caption', 'align'], + ['ol dl menu dir', 'compact'], + ['pre', 'width xml:space'], + ['hr', 'align noshade size width'], + ['isindex', 'prompt'], + ['col', 'width align char charoff valign'], + ['input button select textarea', 'autofocus'], + ['input textarea', 'placeholder onselect onchange onfocus onblur'], + ['link script img', 'crossorigin'] + ]; + + rawData.forEach(function (data) { + var nodes = data[0].split(' '), + attributes = data[1] || [], + children = data[2] || [], + ni = nodes.length, + nodeName, + schemaData; + + if (typeof attributes === 'string') { + attributes = attributes.split(' '); + } + + if (typeof children === 'string') { + children = children.split(' '); + } + + while (ni--) { + nodeName = nodes[ni]; + schemaData = compiled[nodeName] || {}; + + compiled[nodeName] = { + attributes: _.union(schemaData.attributes, globalAttrs, attributes), + children: _.union(schemaData.children, children) + }; + } + }); + + ['a', 'dfn', 'form', 'meter', 'progress'].forEach(function (nodeName) { + var node = compiled[nodeName]; + + node.children = _.without(node.children, nodeName); + }); + + _.each(compiled, function (node, nodeName) { + var attributes = node.attributes.join('|'), + children = node.children.join('|'); + + validElements.push(nodeName + '[' + attributes + ']'); + validChildren.push(nodeName + '[' + children + ']'); + }); + + return { + nodes: compiled, + validElements: validElements, + validChildren: validChildren + }; + })(schema.phrasingContent, schema.flowContent)); + + return schema; +}); diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js index 6f1952285549e..685502907bebb 100755 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js @@ -6,11 +6,12 @@ define([ 'jquery', 'underscore', 'tinymce', + 'mage/adminhtml/wysiwyg/tiny_mce/html5-schema', 'mage/translate', 'prototype', 'mage/adminhtml/events', 'mage/adminhtml/browser' -], function(jQuery, _, tinyMCE) { +], function(jQuery, _, tinyMCE, html5Schema) { tinyMceWysiwygSetup = Class.create(); @@ -25,6 +26,7 @@ define([ this.id = htmlId; this.config = config; + this.schema = config.schema || html5Schema; _.bindAll(this, 'beforeSetContent', 'saveContent', 'onChangeContent', 'openFileBrowser', 'updateTextArea'); @@ -56,6 +58,7 @@ define([ getSettings: function(mode) { var plugins = 'inlinepopups,safari,pagebreak,style,layer,table,advhr,advimage,emotions,iespell,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras'; + var self = this; if (this.config.widget_plugin_src) { plugins = 'magentowidget,' + plugins; @@ -86,9 +89,8 @@ define([ theme_advanced_toolbar_location: 'top', theme_advanced_toolbar_align: 'left', theme_advanced_statusbar_location: 'bottom', - extended_valid_elements: 'style,input[placeholder|accept|alt|checked|disabled|maxlength|name|readonly|size|src|type|value]', - valid_children: '+body[style]', - custom_elements: 'style', + valid_elements: this.schema.validElements.join(','), + valid_children: this.schema.validChildren.join(','), theme_advanced_resizing: true, theme_advanced_resize_horizontal: false, convert_urls: false, @@ -99,6 +101,8 @@ define([ magentoPluginsOptions: magentoPluginsOptions, doctype: '', setup: function(ed){ + ed.onInit.add(self.onEditorInit.bind(self)); + ed.onSubmit.add(function(ed, e) { varienGlobalEvents.fireEvent('tinymceSubmit', e); }); @@ -162,6 +166,28 @@ define([ return settings; }, + applySchema: function (editor) { + var schema = editor.schema, + schemaData = this.schema, + makeMap = tinyMCE.makeMap; + + jQuery.extend(true, { + nonEmpty: schema.getNonEmptyElements(), + boolAttrs: schema.getBoolAttrs(), + whiteSpace: schema.getWhiteSpaceElements(), + shortEnded: schema.getShortEndedElements(), + selfClosing: schema.getSelfClosingElements(), + blockElements: schema.getBlockElements() + }, { + nonEmpty: makeMap(schemaData.nonEmpty), + boolAttrs: makeMap(schemaData.boolAttrs), + whiteSpace: makeMap(schemaData.whiteSpace), + shortEnded: makeMap(schemaData.shortEnded), + selfClosing: makeMap(schemaData.selfClosing), + blockElements: makeMap(schemaData.blockElements) + }); + }, + openFileBrowser: function(o) { var typeTitle, storeId = this.config.store_id !== null ? this.config.store_id : 0, @@ -215,21 +241,21 @@ define([ this.closePopups(); this.setup(mode); - + tinyMCE.execCommand('mceAddControl', false, this.id); - + this.getPluginButtons().each(function(e) { e.hide(); }); - + return this; }, turnOff: function() { this.closePopups(); - + tinyMCE.execCommand('mceRemoveControl', false, this.id); - + this.getPluginButtons().each(function(e) { e.show(); }); @@ -255,6 +281,10 @@ define([ } }, + onEditorInit: function (editor) { + this.applySchema(editor); + }, + onFormValidation: function() { if (tinyMCE.get(this.id)) { $(this.id).value = tinyMCE.get(this.id).getContent(); From 210bdc55f7006b547fe21c8122c5865ab4dd313d Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Wed, 25 May 2016 13:25:44 +0300 Subject: [PATCH 08/57] MAGETWO-53286: Error while creating shipping label for FedEx - Refactored code to remove link for array --- app/code/Magento/Fedex/Model/Carrier.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Fedex/Model/Carrier.php b/app/code/Magento/Fedex/Model/Carrier.php index 4cd95cb5b4ba9..2d9e162d85f1c 100644 --- a/app/code/Magento/Fedex/Model/Carrier.php +++ b/app/code/Magento/Fedex/Model/Carrier.php @@ -1260,7 +1260,6 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) $width = $packageParams->getWidth(); $length = $packageParams->getLength(); $weightUnits = $packageParams->getWeightUnits() == \Zend_Measure_Weight::POUND ? 'LB' : 'KG'; - $dimensionsUnits = $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM'; $unitPrice = 0; $itemsQty = 0; $itemsDesc = []; @@ -1403,12 +1402,12 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request) // set dimensions if ($length || $width || $height) { - $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = []; - $dimenssions = &$requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions']; - $dimenssions['Length'] = $length; - $dimenssions['Width'] = $width; - $dimenssions['Height'] = $height; - $dimenssions['Units'] = $dimensionsUnits; + $requestClient['RequestedShipment']['RequestedPackageLineItems']['Dimensions'] = [ + 'Length' => $length, + 'Width' => $width, + 'Height' => $height, + 'Units' => $packageParams->getDimensionUnits() == \Zend_Measure_Length::INCH ? 'IN' : 'CM' + ]; } return $this->_getAuthDetails() + $requestClient; From 32a855055ca95d0b462b48733c18ee2113bc9c6f Mon Sep 17 00:00:00 2001 From: Denys Rul Date: Wed, 25 May 2016 14:25:48 +0300 Subject: [PATCH 09/57] MAGETWO-53263: [Github] Issue with blank theme search input #4282 - Prevent default label click behavior when search field is active --- .../Search/view/frontend/web/form-mini.js | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/app/code/Magento/Search/view/frontend/web/form-mini.js b/app/code/Magento/Search/view/frontend/web/form-mini.js index cceda751f6317..7c9bc4255fb21 100644 --- a/app/code/Magento/Search/view/frontend/web/form-mini.js +++ b/app/code/Magento/Search/view/frontend/web/form-mini.js @@ -71,14 +71,18 @@ define([ }.bind(this) }); + this.searchLabel.on('click', function (e) { + // allow input to lose its' focus when clicking on label + if (this.isExpandable && this.isActive()) { + e.preventDefault(); + } + }.bind(this)); + this.element.on('blur', $.proxy(function () { setTimeout($.proxy(function () { if (this.autoComplete.is(':hidden')) { - this.searchLabel.removeClass('active'); - if (this.isExpandable === true) { - this.element.attr('aria-expanded', 'false'); - } + this.setActiveState(false); } this.autoComplete.hide(); this._updateAriaHasPopup(false); @@ -87,12 +91,7 @@ define([ this.element.trigger('blur'); - this.element.on('focus', $.proxy(function () { - this.searchLabel.addClass('active'); - if (this.isExpandable === true) { - this.element.attr('aria-expanded', 'true'); - } - }, this)); + this.element.on('focus', this.setActiveState.bind(this, true)); this.element.on('keydown', this._onKeyDown); this.element.on('input propertychange', this._onPropertyChange); @@ -101,6 +100,29 @@ define([ this._updateAriaHasPopup(false); }, this)); }, + + /** + * Checks if search field is active. + * + * @returns {Boolean} + */ + isActive: function () { + return this.searchLabel.hasClass('active'); + }, + + /** + * Sets state of the search field to provided value. + * + * @param {Boolean} isActive + */ + setActiveState: function (isActive) { + this.searchLabel.toggleClass('active', isActive); + + if (this.isExpandable) { + this.element.attr('aria-expanded', isActive); + } + }, + /** * @private * @return {Element} The first element in the suggestion list. From d608f9eb3ff35d60a90d7bab38db62e69f0b6f93 Mon Sep 17 00:00:00 2001 From: Oleksandr Miroshnichenko Date: Wed, 25 May 2016 16:23:52 +0300 Subject: [PATCH 10/57] MAGETWO-53439: [Github][PR] Removed inline JavaScript from template #4141 --- .../templates/product/view/addtocart.phtml | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml index 9a7db79414836..063f4011879c7 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/addtocart.phtml @@ -40,7 +40,6 @@ -isRedirectToCartEnabled()) : ?> - - \ No newline at end of file From e8eea7136b93d62cde15d190c24b8eae6dd53e31 Mon Sep 17 00:00:00 2001 From: Denys Rul Date: Wed, 25 May 2016 17:00:11 +0300 Subject: [PATCH 11/57] MAGETWO-50522: Wysiwyg editor is removing html5 tags - Fix code style --- lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js index 685502907bebb..94de561da986d 100755 --- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js +++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js @@ -57,8 +57,8 @@ define([ }, getSettings: function(mode) { - var plugins = 'inlinepopups,safari,pagebreak,style,layer,table,advhr,advimage,emotions,iespell,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras'; - var self = this; + var plugins = 'inlinepopups,safari,pagebreak,style,layer,table,advhr,advimage,emotions,iespell,media,searchreplace,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras', + self = this; if (this.config.widget_plugin_src) { plugins = 'magentowidget,' + plugins; From ca0feac3d850268ff8526cbda73d99cff095e622 Mon Sep 17 00:00:00 2001 From: Iurii Ivashchenko Date: Wed, 25 May 2016 17:31:43 +0300 Subject: [PATCH 12/57] MAGETWO-53299: "Go Today" button is not working for dates range component --- lib/web/mage/calendar.js | 47 ++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/lib/web/mage/calendar.js b/lib/web/mage/calendar.js index 0f86c83e7f8be..4ebd91662812f 100644 --- a/lib/web/mage/calendar.js +++ b/lib/web/mage/calendar.js @@ -23,6 +23,24 @@ var calendarBasePrototype; + /** + * Get date/time according to store settings + * @returns {Date} + */ + function getTimezoneDate() { + // Get local time in ms + var ms = Date.now(), + options = $.calendarConfig ? $.calendarConfig : {}; + + // Use store timestamp based on store timezone settings + if (typeof options.serverTimezoneSeconds !== 'undefined') { + //Adjust milliseconds according to client local timezone offset + ms = (options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000; + } + + return new Date(ms); + } + $.datepicker.markerClassName = '_has-datepicker'; /** @@ -72,8 +90,6 @@ * Wrapper for overwrite jQuery UI datepicker function. */ _overwriteGenerateHtml: function () { - var self = this; - /** * Overwrite jQuery UI datepicker function. * Reason: magento date could be set before calendar show @@ -83,7 +99,7 @@ * @return {String} html template */ $.datepicker.constructor.prototype._generateHTML = function (inst) { - var today = self.getTimezoneDate(), + var today = getTimezoneDate(), isRTL = this._get(inst, 'isRTL'), showButtonPanel = this._get(inst, 'showButtonPanel'), hideIfNoPrevNext = this._get(inst, 'hideIfNoPrevNext'), @@ -316,24 +332,6 @@ }; }, - /** - * If server timezone is defined then take to account server timezone shift - * @return {Object} date - */ - getTimezoneDate: function () { - - // Get local time in ms - var ms = Date.now(); - - // Use store timestamp based on store timezone settings - if (typeof this.options.serverTimezoneSeconds !== 'undefined') { - //Adjust milliseconds according to client local timezone offset - ms = (this.options.serverTimezoneSeconds + new Date().getTimezoneOffset() * 60) * 1000; - } - - return new Date(ms); - }, - /** * Set current date if the date is not set * @protected @@ -341,7 +339,7 @@ */ _setCurrentDate: function (element) { if (!element.val()) { - element[this._picker()]('setDate', this.getTimezoneDate()) + element[this._picker()]('setDate', getTimezoneDate()) .val(''); } }, @@ -356,6 +354,7 @@ pickerButtonText = picker.next('.ui-datepicker-trigger') .find('img') .attr('title'); + picker.next('.ui-datepicker-trigger') .addClass('v-middle') .text('') // Remove jQuery UI datepicker generated image @@ -523,8 +522,8 @@ $.datepicker._gotoToday = function (el) { var pickerObject = $(el); - // Set date/time according to timezone offset - pickerObject.datepicker( "setDate", pickerObject.calendar("getTimezoneDate") ) + //Set date/time according to timezone offset + pickerObject.datepicker('setDate', getTimezoneDate()) // To ensure that user can re-select date field without clicking outside it first. .blur(); }; From 7527a1e3ec2da98046183d66349bf08bda32e348 Mon Sep 17 00:00:00 2001 From: Roman Liukshyn Date: Wed, 25 May 2016 15:37:23 +0000 Subject: [PATCH 13/57] MAGETWO-53317: Unable to place order within direct payment method from admin - Solo/Switch cc form related methods are marked as deprecated - Start Year, Start Month and Issue Number fields are removed from cc forms --- app/code/Magento/Payment/Block/Form/Cc.php | 2 + app/code/Magento/Payment/Model/CcConfig.php | 2 + .../Payment/Model/CcGenericConfigProvider.php | 4 +- .../Payment/Test/Unit/Model/CcConfigTest.php | 11 --- .../view/adminhtml/templates/form/cc.phtml | 68 ------------------- .../view/frontend/templates/form/cc.phtml | 59 ---------------- .../web/template/payment/cc-form.html | 62 ----------------- .../Sales/Api/Data/OrderPaymentInterface.php | 18 ++++- .../Order/Create/Billing/Method/Form.php | 1 + .../Magento/Sales/Model/Order/Payment.php | 9 +++ 10 files changed, 31 insertions(+), 205 deletions(-) diff --git a/app/code/Magento/Payment/Block/Form/Cc.php b/app/code/Magento/Payment/Block/Form/Cc.php index 1871da613b254..a6eb1a9324f8e 100644 --- a/app/code/Magento/Payment/Block/Form/Cc.php +++ b/app/code/Magento/Payment/Block/Form/Cc.php @@ -108,6 +108,7 @@ public function hasVerification() /** * Whether switch/solo card type available * + * @deprecated * @return bool */ public function hasSsCardType() @@ -123,6 +124,7 @@ public function hasSsCardType() /** * Solo/switch card start year * + * @deprecated * @return array */ public function getSsStartYears() diff --git a/app/code/Magento/Payment/Model/CcConfig.php b/app/code/Magento/Payment/Model/CcConfig.php index e80edc45da0ef..605014519faa8 100644 --- a/app/code/Magento/Payment/Model/CcConfig.php +++ b/app/code/Magento/Payment/Model/CcConfig.php @@ -62,6 +62,7 @@ public function __construct( * Solo/switch card start years * * @return array + * @deprecated */ public function getSsStartYears() { @@ -119,6 +120,7 @@ public function hasVerification() * Whether switch/solo card type available * * @return bool + * @deprecated */ public function hasSsCardType() { diff --git a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php index 768c1368f3af4..6c04de009a402 100644 --- a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php +++ b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php @@ -51,8 +51,6 @@ public function getConfig() 'months' => [$methodCode => $this->getCcMonths()], 'years' => [$methodCode => $this->getCcYears()], 'hasVerification' => [$methodCode => $this->hasVerification($methodCode)], - 'hasSsCardType' => [$methodCode => $this->hasSsCardType($methodCode)], - 'ssStartYears' => [$methodCode => $this->getSsStartYears()], 'cvvImageUrl' => [$methodCode => $this->getCvvImageUrl()] ] ] @@ -66,6 +64,7 @@ public function getConfig() * Solo/switch card start years * * @return array + * @deprecated */ protected function getSsStartYears() { @@ -144,6 +143,7 @@ protected function hasVerification($methodCode) * * @param string $methodCode * @return bool + * @deprecated */ protected function hasSsCardType($methodCode) { diff --git a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php index aa4b8c0587a69..46663d30d8a0d 100644 --- a/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php +++ b/app/code/Magento/Payment/Test/Unit/Model/CcConfigTest.php @@ -44,12 +44,6 @@ protected function setUp() ); } - public function testGetSsStartYears() - { - $this->assertCount(6, $this->model->getSsStartYears()); - $this->assertEquals(date("Y"), $this->model->getSsStartYears()[date("Y")]); - } - public function testGetCcAvailableTypes() { $data = [1, 2, 3]; @@ -85,11 +79,6 @@ public function testHasVerification() $this->assertEquals(true, $this->model->hasVerification()); } - public function testHasSsCardType() - { - $this->assertEquals(false, $this->model->hasSsCardType()); - } - public function testGetCvvImageUrl() { $params = ['_secure' => true]; diff --git a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml index f07aceb5ddb5f..bddf821c3b376 100644 --- a/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml +++ b/app/code/Magento/Payment/view/adminhtml/templates/form/cc.phtml @@ -80,72 +80,4 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); - - hasSsCardType()): ?> -
-
- -
-
- - -
- -
-
-
- -
- - -
-
- -
 
- - -
- diff --git a/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml b/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml index 3a2a342c207fe..0f2782db469ac 100644 --- a/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml +++ b/app/code/Magento/Payment/view/frontend/templates/form/cc.phtml @@ -109,64 +109,5 @@ $ccExpYear = $block->getInfoData('cc_exp_year'); - hasSsCardType()): ?> -
-
-
- -
-
- -
- -
-
- -
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
 
-
-
- getChildHtml() ?> diff --git a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html index 2b3ea564912b9..c1cc8f009bcec 100644 --- a/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html +++ b/app/code/Magento/Payment/view/frontend/web/template/payment/cc-form.html @@ -124,66 +124,4 @@ - -
-
-
- -
-
- -
- -
-
- -
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
 
-
-
- diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index 7e408a0ec5cf6..9bf5a60b0ec9e 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -110,8 +110,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card expiration month. */ const CC_EXP_MONTH = 'cc_exp_month'; - /* + + /** * Credit card SS start year. + * + * @deprecated */ const CC_SS_START_YEAR = 'cc_ss_start_year'; /* @@ -154,8 +157,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card debug response serialized. */ const CC_DEBUG_RESPONSE_SERIALIZED = 'cc_debug_response_serialized'; - /* + + /** * Credit card SS start month. + * + * @deprecated */ const CC_SS_START_MONTH = 'cc_ss_start_month'; /* @@ -206,8 +212,11 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt * Credit card debug response body. */ const CC_DEBUG_RESPONSE_BODY = 'cc_debug_response_body'; - /* + + /** * Credit card SS issue. + * + * @deprecated */ const CC_SS_ISSUE = 'cc_ss_issue'; /* @@ -463,6 +472,7 @@ public function getCcSecureVerify(); * Gets the credit card SS issue for the order payment. * * @return string|null Credit card SS issue. + * @deprecated */ public function getCcSsIssue(); @@ -470,6 +480,7 @@ public function getCcSsIssue(); * Gets the credit card SS start month for the order payment. * * @return string|null Credit card SS start month. + * @deprecated */ public function getCcSsStartMonth(); @@ -477,6 +488,7 @@ public function getCcSsStartMonth(); * Gets the credit card SS start year for the order payment. * * @return string|null Credit card SS start year. + * @deprecated */ public function getCcSsStartYear(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php index 99310038a02f4..8d769f53b36ff 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php @@ -101,6 +101,7 @@ public function getQuote() * Whether switch/solo card type available * * @return true + * @deprecated */ public function hasSsCardType() { diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 76f612851359d..31369455e8d74 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1703,6 +1703,7 @@ public function getCcSecureVerify() * Returns cc_ss_issue * * @return string + * @deprecated */ public function getCcSsIssue() { @@ -1713,6 +1714,7 @@ public function getCcSsIssue() * Returns cc_ss_start_month * * @return string + * @deprecated */ public function getCcSsStartMonth() { @@ -1723,6 +1725,7 @@ public function getCcSsStartMonth() * Returns cc_ss_start_year * * @return string + * @deprecated */ public function getCcSsStartYear() { @@ -2087,6 +2090,8 @@ public function setCcExpMonth($ccExpMonth) /** * {@inheritdoc} + * + * @deprecated */ public function setCcSsStartYear($ccSsStartYear) { @@ -2175,6 +2180,8 @@ public function setCcDebugResponseSerialized($ccDebugResponseSerialized) /** * {@inheritdoc} + * + * @deprecated */ public function setCcSsStartMonth($ccSsStartMonth) { @@ -2279,6 +2286,8 @@ public function setCcDebugResponseBody($ccDebugResponseBody) /** * {@inheritdoc} + * + * @deprecated */ public function setCcSsIssue($ccSsIssue) { From a8310151e8570b5e9d08a9c21fb12bcc714609e2 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 26 May 2016 09:55:53 +0300 Subject: [PATCH 14/57] MAGETWO-53237: Exception if try to apply Gift Card Account/Discount Code on review page using PayPal (Braintree) --- .../Braintree/Controller/Paypal/Review.php | 23 +++---- .../Unit/Controller/Paypal/ReviewTest.php | 64 ++++++++++++++++++- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Braintree/Controller/Paypal/Review.php b/app/code/Magento/Braintree/Controller/Paypal/Review.php index b2b95f7897856..35ff1877110e5 100644 --- a/app/code/Magento/Braintree/Controller/Paypal/Review.php +++ b/app/code/Magento/Braintree/Controller/Paypal/Review.php @@ -10,6 +10,7 @@ use Magento\Framework\Controller\ResultFactory; use Magento\Braintree\Gateway\Config\PayPal\Config; use Magento\Braintree\Model\Paypal\Helper\QuoteUpdater; +use Magento\Framework\Exception\LocalizedException; /** * Class Review @@ -52,13 +53,16 @@ public function execute() try { $this->validateQuote($quote); - $this->validateRequestData($requestData); - $this->quoteUpdater->execute( - $requestData['nonce'], - $requestData['details'], - $quote - ); + if ($this->validateRequestData($requestData)) { + $this->quoteUpdater->execute( + $requestData['nonce'], + $requestData['details'], + $quote + ); + } elseif (!$quote->getPayment()->getAdditionalInformation('payment_method_nonce')) { + throw new LocalizedException(__('We can\'t initialize checkout.')); + } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); @@ -82,13 +86,10 @@ public function execute() /** * @param array $requestData - * @return void - * @throws \InvalidArgumentException + * @return boolean */ private function validateRequestData(array $requestData) { - if (empty($requestData['nonce']) || empty($requestData['details'])) { - throw new \InvalidArgumentException('Data of request cannot be empty.'); - } + return !empty($requestData['nonce']) && !empty($requestData['details']); } } diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index 4f1c053d31fba..838625133030b 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -172,6 +172,14 @@ public function testExecuteException() ->method('getItemsCount') ->willReturn(1); + $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + ->disableOriginalConstructor() + ->getMock(); + + $quoteMock->expects(self::once()) + ->method('getPayment') + ->willReturn($paymentMock); + $this->requestMock->expects(self::once()) ->method('getPostValue') ->with('result', '{}') @@ -187,8 +195,8 @@ public function testExecuteException() $this->messageManagerMock->expects(self::once()) ->method('addExceptionMessage') ->with( - self::isInstanceOf('\InvalidArgumentException'), - 'Data of request cannot be empty.' + self::isInstanceOf('\Magento\Framework\Exception\LocalizedException'), + 'We can\'t initialize checkout.' ); $this->resultFactoryMock->expects(self::once()) @@ -204,6 +212,58 @@ public function testExecuteException() self::assertEquals($this->review->execute(), $resultRedirectMock); } + /** + * @param array $data + * @param bool $result + * + * @dataProvider dataProviderValidateRequestData + */ + public function testValidateRequestData(array $data, $result) + { + $this->assertEquals( + $result, + $this->invokeMethod($this->review, 'validateRequestData', [$data]) + ); + } + + /** + * Invoke any method of an object. + * + * @param $object + * @param $methodName + * @param array $parameters + * @return mixed + */ + protected function invokeMethod(&$object, $methodName, array $parameters = []) + { + $reflection = new \ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); + } + + /** + * @return array + */ + public function dataProviderValidateRequestData() + { + return [ + [ + [ + ], + false + ], + [ + [ + 'nonce' => 'nonceValue', + 'details' => 'detailsValue' + ], + true + ] + ]; + } + /** * @return Redirect|\PHPUnit_Framework_MockObject_MockObject */ From cddfba2180ec0eb7673759cdbc3de8b104686e8a Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 26 May 2016 11:02:58 +0300 Subject: [PATCH 15/57] MAGETWO-53237: Exception if try to apply Gift Card Account/Discount Code on review page using PayPal (Braintree) --- .../Braintree/Controller/Paypal/Review.php | 7 +- .../Unit/Controller/Paypal/ReviewTest.php | 97 ++++++++----------- 2 files changed, 48 insertions(+), 56 deletions(-) diff --git a/app/code/Magento/Braintree/Controller/Paypal/Review.php b/app/code/Magento/Braintree/Controller/Paypal/Review.php index 35ff1877110e5..1b6c3a3ab5a91 100644 --- a/app/code/Magento/Braintree/Controller/Paypal/Review.php +++ b/app/code/Magento/Braintree/Controller/Paypal/Review.php @@ -22,6 +22,11 @@ class Review extends AbstractAction */ private $quoteUpdater; + /** + * @var string + */ + private static $paymentMethodNonce = 'payment_method_nonce'; + /** * Constructor * @@ -60,7 +65,7 @@ public function execute() $requestData['details'], $quote ); - } elseif (!$quote->getPayment()->getAdditionalInformation('payment_method_nonce')) { + } elseif (!$quote->getPayment()->getAdditionalInformation(self::$paymentMethodNonce)) { throw new LocalizedException(__('We can\'t initialize checkout.')); } diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index 838625133030b..d5342aa8b3deb 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -168,6 +168,48 @@ public function testExecuteException() $quoteMock = $this->getQuoteMock(); $resultRedirectMock = $this->getResultRedirectMock(); + $quoteMock->expects(self::once()) + ->method('getItemsCount') + ->willReturn(0); + + $this->requestMock->expects(self::once()) + ->method('getPostValue') + ->with('result', '{}') + ->willReturn($result); + + $this->checkoutSessionMock->expects(self::once()) + ->method('getQuote') + ->willReturn($quoteMock); + + $this->quoteUpdaterMock->expects(self::never()) + ->method('execute'); + + $this->messageManagerMock->expects(self::once()) + ->method('addExceptionMessage') + ->with( + self::isInstanceOf('\InvalidArgumentException'), + 'We can\'t initialize checkout.' + ); + + $this->resultFactoryMock->expects(self::once()) + ->method('create') + ->with(ResultFactory::TYPE_REDIRECT) + ->willReturn($resultRedirectMock); + + $resultRedirectMock->expects(self::once()) + ->method('setPath') + ->with('checkout/cart') + ->willReturnSelf(); + + self::assertEquals($this->review->execute(), $resultRedirectMock); + } + + public function testExecuteExceptionPaymentWithoutNonce() + { + $result = '{}'; + $quoteMock = $this->getQuoteMock(); + $resultRedirectMock = $this->getResultRedirectMock(); + $quoteMock->expects(self::once()) ->method('getItemsCount') ->willReturn(1); @@ -189,9 +231,6 @@ public function testExecuteException() ->method('getQuote') ->willReturn($quoteMock); - $this->quoteUpdaterMock->expects(self::never()) - ->method('execute'); - $this->messageManagerMock->expects(self::once()) ->method('addExceptionMessage') ->with( @@ -212,58 +251,6 @@ public function testExecuteException() self::assertEquals($this->review->execute(), $resultRedirectMock); } - /** - * @param array $data - * @param bool $result - * - * @dataProvider dataProviderValidateRequestData - */ - public function testValidateRequestData(array $data, $result) - { - $this->assertEquals( - $result, - $this->invokeMethod($this->review, 'validateRequestData', [$data]) - ); - } - - /** - * Invoke any method of an object. - * - * @param $object - * @param $methodName - * @param array $parameters - * @return mixed - */ - protected function invokeMethod(&$object, $methodName, array $parameters = []) - { - $reflection = new \ReflectionClass(get_class($object)); - $method = $reflection->getMethod($methodName); - $method->setAccessible(true); - - return $method->invokeArgs($object, $parameters); - } - - /** - * @return array - */ - public function dataProviderValidateRequestData() - { - return [ - [ - [ - ], - false - ], - [ - [ - 'nonce' => 'nonceValue', - 'details' => 'detailsValue' - ], - true - ] - ]; - } - /** * @return Redirect|\PHPUnit_Framework_MockObject_MockObject */ From ffe608f254396c2367c41d9452075a31c2da70fa Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 26 May 2016 11:05:32 +0300 Subject: [PATCH 16/57] MAGETWO-53237: Exception if try to apply Gift Card Account/Discount Code on review page using PayPal (Braintree) --- .../Braintree/Test/Unit/Controller/Paypal/ReviewTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php index d5342aa8b3deb..a5cdaf3e35b70 100644 --- a/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php +++ b/app/code/Magento/Braintree/Test/Unit/Controller/Paypal/ReviewTest.php @@ -214,7 +214,7 @@ public function testExecuteExceptionPaymentWithoutNonce() ->method('getItemsCount') ->willReturn(1); - $paymentMock = $this->getMockBuilder('Magento\Quote\Model\Quote\Payment') + $paymentMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Payment::class) ->disableOriginalConstructor() ->getMock(); @@ -234,7 +234,7 @@ public function testExecuteExceptionPaymentWithoutNonce() $this->messageManagerMock->expects(self::once()) ->method('addExceptionMessage') ->with( - self::isInstanceOf('\Magento\Framework\Exception\LocalizedException'), + self::isInstanceOf(\Magento\Framework\Exception\LocalizedException::class), 'We can\'t initialize checkout.' ); From a99620075fa5f5b3f0ea64187cdaf04724762b97 Mon Sep 17 00:00:00 2001 From: Viktor Tymchynskyi Date: Thu, 26 May 2016 14:24:38 +0300 Subject: [PATCH 17/57] MAGETWO-50972: Move to Shopping Cart action does not work inside creation offline order - Save backend quote after creation with is_active = false since quote was created with is_active = true --- app/code/Magento/Backend/Model/Session/Quote.php | 1 + .../Magento/Backend/Test/Unit/Model/Session/QuoteTest.php | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Backend/Model/Session/Quote.php b/app/code/Magento/Backend/Model/Session/Quote.php index 1ecbde15f840e..04458dc54cc86 100644 --- a/app/code/Magento/Backend/Model/Session/Quote.php +++ b/app/code/Magento/Backend/Model/Session/Quote.php @@ -159,6 +159,7 @@ public function getQuote() $this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]); $this->_quote->setCustomerGroupId($this->groupManagement->getDefaultGroup()->getId()); $this->_quote->setIsActive(false); + $this->quoteRepository->save($this->_quote); } else { $this->_quote = $this->quoteRepository->get($this->getQuoteId(), [$this->getStoreId()]); $this->_quote->setStoreId($this->getStoreId()); diff --git a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php index d02422ebdc93d..8ea5665baaa79 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Session/QuoteTest.php @@ -296,7 +296,12 @@ public function testGetQuoteWithoutQuoteId() '', false ); - $this->quoteRepositoryMock->expects($this->once())->method('get')->willReturn($quoteMock); + $this->quoteRepositoryMock->expects($this->once()) + ->method('get') + ->willReturn($quoteMock); + $this->quoteRepositoryMock->expects($this->once()) + ->method('save') + ->with($quoteMock); $quoteMock->expects($this->once()) ->method('setCustomerGroupId') ->with($customerGroupId) From ae6db442afafab2b4277c6314ab9b07945ebfc2e Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Thu, 26 May 2016 14:31:48 +0300 Subject: [PATCH 18/57] MAGETWO-53312: Click on "Submit invoice" button cause to expose php error log - removed code --- .../Model/ResourceModel/AbstractResource.php | 1 - .../ResourceModel/AbstractResourceStub.php | 20 +++- .../ResourceModel/AbstractResourceTest.php | 93 +++++++++++++++++++ 3 files changed, 111 insertions(+), 3 deletions(-) diff --git a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php index 4e38d13aa72f6..905db99ab17a6 100644 --- a/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php +++ b/lib/internal/Magento/Framework/Model/ResourceModel/AbstractResource.php @@ -82,7 +82,6 @@ public function commit() call_user_func($callback); } } catch (\Exception $e) { - echo $e; throw $e; } } diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceStub.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceStub.php index 13370114aa7ae..287e12e8abdf3 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceStub.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceStub.php @@ -6,10 +6,16 @@ namespace Magento\Framework\Model\Test\Unit\ResourceModel; use Magento\Framework\DataObject; +use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\Model\ResourceModel\AbstractResource; class AbstractResourceStub extends AbstractResource { + /** + * @var AdapterInterface + */ + private $connectionAdapter; + /** * Resource initialization * @@ -23,11 +29,21 @@ protected function _construct() /** * Get connection * - * @return \Magento\Framework\DB\Adapter\AdapterInterface + * @return AdapterInterface */ protected function getConnection() { - return null; + return $this->connectionAdapter; + } + + /** + * @param AdapterInterface $adapter + * + * @return void + */ + public function setConnection(AdapterInterface $adapter) + { + $this->connectionAdapter = $adapter; } /** diff --git a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceTest.php b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceTest.php index 6508f3d8122d3..217f5c8252378 100644 --- a/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceTest.php +++ b/lib/internal/Magento/Framework/Model/Test/Unit/ResourceModel/AbstractResourceTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Model\Test\Unit\ResourceModel; use Magento\Framework\DataObject; +use Magento\Framework\DB\Adapter\AdapterInterface; class AbstractResourceTest extends \PHPUnit_Framework_TestCase { @@ -105,4 +106,96 @@ public function unserializableFieldsDataProvider() [[$dataObject, 'serialized_boolean_false', null], false] ]; } + + public function testCommitZeroLevel() + { + /** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->getMock(AdapterInterface::class); + /** @var DataObject|\PHPUnit_Framework_MockObject_MockObject $closureExpectation */ + $closureExpectation = $this->getMockBuilder(DataObject::class) + ->disableOriginalConstructor() + ->getMock(); + + $abstractResource = new AbstractResourceStub(); + $abstractResource->setConnection($connection); + $abstractResource->addCommitCallback( + function () use ($closureExpectation) { + $closureExpectation->setData(1); + } + ); + + $abstractResource->addCommitCallback( + function () use ($closureExpectation) { + $closureExpectation->getData(); + } + ); + + $connection->expects(static::once()) + ->method('commit'); + $connection->expects(static::once()) + ->method('getTransactionLevel') + ->willReturn(0); + $closureExpectation->expects(static::once()) + ->method('setData') + ->with(1); + $closureExpectation->expects(static::once()) + ->method('getData'); + + $abstractResource->commit(); + } + + /** + * @expectedException \Exception + */ + public function testCommitZeroLevelCallbackException() + { + /** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->getMock(AdapterInterface::class); + + $abstractResource = new AbstractResourceStub(); + $abstractResource->setConnection($connection); + $abstractResource->addCommitCallback( + function () { + throw new \Exception(); + } + ); + + $connection->expects(static::once()) + ->method('commit'); + $connection->expects(static::once()) + ->method('getTransactionLevel') + ->willReturn(0); + + $abstractResource->commit(); + } + + public function testCommitNotCompletedTransaction() + { + /** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $connection */ + $connection = $this->getMock(AdapterInterface::class); + /** @var DataObject|\PHPUnit_Framework_MockObject_MockObject $closureExpectation */ + $closureExpectation = $this->getMockBuilder(DataObject::class) + ->disableOriginalConstructor() + ->getMock(); + + $abstractResource = new AbstractResourceStub(); + $abstractResource->setConnection($connection); + $abstractResource->addCommitCallback( + function () use ($closureExpectation) { + $closureExpectation->setData(1); + } + ); + + $connection->expects(static::once()) + ->method('commit'); + $connection->expects(static::once()) + ->method('getTransactionLevel') + ->willReturn(1); + + $closureExpectation->expects(static::never()) + ->method('setData') + ->with(1); + + $abstractResource->commit(); + } } From 4d147bb65d5f61365083e886a1a88bdef3ce471a Mon Sep 17 00:00:00 2001 From: Ievgen Sentiabov Date: Thu, 26 May 2016 14:44:00 +0300 Subject: [PATCH 19/57] MAGETWO-53240: There is no ability to preform Checkout for virtual product using PayPal (Braintree) - Added ability to retrieve billing address from PayPal side --- .../js/view/payment/method-renderer/paypal.js | 63 +++++++++++++++---- 1 file changed, 51 insertions(+), 12 deletions(-) diff --git a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js index 4155f2c25f8b0..ce83fb215d9b2 100644 --- a/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js +++ b/app/code/Magento/Braintree/view/frontend/web/js/view/payment/method-renderer/paypal.js @@ -144,12 +144,36 @@ define([ this.paymentMethodNonce = paymentMethodNonce; }, + /** + * Update quote billing address + * @param {Object}customer + * @param {Object}address + */ + setBillingAddress: function (customer, address) { + var billingAddress = { + street: [address.streetAddress], + city: address.locality, + regionCode: address.region, + postcode: address.postalCode, + countryId: address.countryCodeAlpha2, + firstname: customer.firstName, + lastname: customer.lastName, + telephone: customer.phone + }; + + quote.billingAddress(billingAddress); + }, + /** * Prepare data to place order * @param {Object} data */ beforePlaceOrder: function (data) { this.setPaymentMethodNonce(data.nonce); + + if (quote.billingAddress() === null && typeof data.details.billingAddress !== 'undefined') { + this.setBillingAddress(data.details, data.details.billingAddress); + } this.placeOrder(); }, @@ -200,8 +224,7 @@ define([ * @returns {Object} */ getPayPalConfig: function () { - var address = quote.shippingAddress(), - totals = quote.totals(), + var totals = quote.totals(), config = {}; config.paypal = { @@ -212,16 +235,6 @@ define([ currency: totals['base_currency_code'], locale: this.getLocale(), enableShippingAddress: true, - shippingAddressOverride: { - recipientName: address.firstname + ' ' + address.lastname, - streetAddress: address.street[0], - locality: address.city, - countryCodeAlpha2: address.countryId, - postalCode: address.postcode, - region: address.regionCode, - phone: address.telephone, - editable: this.isAllowOverrideShippingAddress() - }, /** * Triggers on any Braintree error @@ -238,6 +251,8 @@ define([ } }; + config.paypal.shippingAddressOverride = this.getShippingAddress(); + if (this.getMerchantName()) { config.paypal.displayName = this.getMerchantName(); } @@ -245,6 +260,30 @@ define([ return config; }, + /** + * Get shipping address + * @returns {Object} + */ + getShippingAddress: function () { + var address = quote.shippingAddress(); + + if (address.postcode === null) { + + return {}; + } + + return { + recipientName: address.firstname + ' ' + address.lastname, + streetAddress: address.street[0], + locality: address.city, + countryCodeAlpha2: address.countryId, + postalCode: address.postcode, + region: address.regionCode, + phone: address.telephone, + editable: this.isAllowOverrideShippingAddress() + }; + }, + /** * Get merchant name * @returns {String} From 867126f99ae9b6e13ee405ae892f32f547f17f5d Mon Sep 17 00:00:00 2001 From: Roman Liukshyn Date: Thu, 26 May 2016 13:22:36 +0000 Subject: [PATCH 20/57] MAGETWO-53317: Unable to place order within direct payment method from admin - Removed redundant usages of deprecated methods - Fixed code style --- app/code/Magento/Payment/Block/Form/Cc.php | 4 ++-- app/code/Magento/Payment/Model/CcConfig.php | 4 ++-- .../Payment/Model/CcGenericConfigProvider.php | 4 ++-- app/code/Magento/Paypal/Model/Direct.php | 7 ------- .../Sales/Api/Data/OrderPaymentInterface.php | 12 ++++++------ .../Order/Create/Billing/Method/Form.php | 2 +- app/code/Magento/Sales/Model/Order/Payment.php | 15 ++++++--------- 7 files changed, 19 insertions(+), 29 deletions(-) diff --git a/app/code/Magento/Payment/Block/Form/Cc.php b/app/code/Magento/Payment/Block/Form/Cc.php index a6eb1a9324f8e..9fcd03b446470 100644 --- a/app/code/Magento/Payment/Block/Form/Cc.php +++ b/app/code/Magento/Payment/Block/Form/Cc.php @@ -108,7 +108,7 @@ public function hasVerification() /** * Whether switch/solo card type available * - * @deprecated + * @deprecated unused * @return bool */ public function hasSsCardType() @@ -124,7 +124,7 @@ public function hasSsCardType() /** * Solo/switch card start year * - * @deprecated + * @deprecated unused * @return array */ public function getSsStartYears() diff --git a/app/code/Magento/Payment/Model/CcConfig.php b/app/code/Magento/Payment/Model/CcConfig.php index 605014519faa8..bb57756fb7e1d 100644 --- a/app/code/Magento/Payment/Model/CcConfig.php +++ b/app/code/Magento/Payment/Model/CcConfig.php @@ -62,7 +62,7 @@ public function __construct( * Solo/switch card start years * * @return array - * @deprecated + * @deprecated unused */ public function getSsStartYears() { @@ -120,7 +120,7 @@ public function hasVerification() * Whether switch/solo card type available * * @return bool - * @deprecated + * @deprecated unused */ public function hasSsCardType() { diff --git a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php index 6c04de009a402..a29bff3576a16 100644 --- a/app/code/Magento/Payment/Model/CcGenericConfigProvider.php +++ b/app/code/Magento/Payment/Model/CcGenericConfigProvider.php @@ -64,7 +64,7 @@ public function getConfig() * Solo/switch card start years * * @return array - * @deprecated + * @deprecated unused */ protected function getSsStartYears() { @@ -143,7 +143,7 @@ protected function hasVerification($methodCode) * * @param string $methodCode * @return bool - * @deprecated + * @deprecated unused */ protected function hasSsCardType($methodCode) { diff --git a/app/code/Magento/Paypal/Model/Direct.php b/app/code/Magento/Paypal/Model/Direct.php index b22913c7d9048..c31c708a669d1 100644 --- a/app/code/Magento/Paypal/Model/Direct.php +++ b/app/code/Magento/Paypal/Model/Direct.php @@ -437,15 +437,8 @@ protected function _placeOrder(Payment $payment, $amount) $this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()) )->setCreditCardCvv2( $payment->getCcCid() - )->setMaestroSoloIssueNumber( - $payment->getCcSsIssue() ); - if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) { - $year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2)); - $api->setMaestroSoloIssueDate($this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year)); - } - // add shipping and billing addresses if ($order->getIsVirtual()) { $api->setAddress($order->getBillingAddress())->setSuppressShipping(true); diff --git a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php index 9bf5a60b0ec9e..4b98fe9309b76 100644 --- a/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php +++ b/app/code/Magento/Sales/Api/Data/OrderPaymentInterface.php @@ -114,7 +114,7 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt /** * Credit card SS start year. * - * @deprecated + * @deprecated unused constant */ const CC_SS_START_YEAR = 'cc_ss_start_year'; /* @@ -161,7 +161,7 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt /** * Credit card SS start month. * - * @deprecated + * @deprecated unused constant */ const CC_SS_START_MONTH = 'cc_ss_start_month'; /* @@ -216,7 +216,7 @@ interface OrderPaymentInterface extends \Magento\Framework\Api\ExtensibleDataInt /** * Credit card SS issue. * - * @deprecated + * @deprecated unused constant */ const CC_SS_ISSUE = 'cc_ss_issue'; /* @@ -472,7 +472,7 @@ public function getCcSecureVerify(); * Gets the credit card SS issue for the order payment. * * @return string|null Credit card SS issue. - * @deprecated + * @deprecated unused */ public function getCcSsIssue(); @@ -480,7 +480,7 @@ public function getCcSsIssue(); * Gets the credit card SS start month for the order payment. * * @return string|null Credit card SS start month. - * @deprecated + * @deprecated unused */ public function getCcSsStartMonth(); @@ -488,7 +488,7 @@ public function getCcSsStartMonth(); * Gets the credit card SS start year for the order payment. * * @return string|null Credit card SS start year. - * @deprecated + * @deprecated unused */ public function getCcSsStartYear(); diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php index 8d769f53b36ff..9a910e48ec0f2 100644 --- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php +++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Billing/Method/Form.php @@ -101,7 +101,7 @@ public function getQuote() * Whether switch/solo card type available * * @return true - * @deprecated + * @deprecated unused */ public function hasSsCardType() { diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index 31369455e8d74..898a205481d1a 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1703,7 +1703,7 @@ public function getCcSecureVerify() * Returns cc_ss_issue * * @return string - * @deprecated + * @deprecated unused */ public function getCcSsIssue() { @@ -1714,7 +1714,7 @@ public function getCcSsIssue() * Returns cc_ss_start_month * * @return string - * @deprecated + * @deprecated unused */ public function getCcSsStartMonth() { @@ -1725,7 +1725,7 @@ public function getCcSsStartMonth() * Returns cc_ss_start_year * * @return string - * @deprecated + * @deprecated unused */ public function getCcSsStartYear() { @@ -2090,8 +2090,7 @@ public function setCcExpMonth($ccExpMonth) /** * {@inheritdoc} - * - * @deprecated + * @deprecated unused */ public function setCcSsStartYear($ccSsStartYear) { @@ -2180,8 +2179,7 @@ public function setCcDebugResponseSerialized($ccDebugResponseSerialized) /** * {@inheritdoc} - * - * @deprecated + * @deprecated unused */ public function setCcSsStartMonth($ccSsStartMonth) { @@ -2286,8 +2284,7 @@ public function setCcDebugResponseBody($ccDebugResponseBody) /** * {@inheritdoc} - * - * @deprecated + * @deprecated unused */ public function setCcSsIssue($ccSsIssue) { From 3b0ec04dca77d8db26e9004532da06dec3dd3015 Mon Sep 17 00:00:00 2001 From: Dmytro Yushkin Date: Thu, 26 May 2016 17:23:04 +0300 Subject: [PATCH 21/57] MAGETWO-53320: [Conflict Resolution] In-Context Experience is disabled after enabling of Express Checkout in Australia --- app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml index 733fbcdb36521..4ee83da9c2ab8 100644 --- a/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml +++ b/app/code/Magento/Paypal/etc/adminhtml/rules/payment_au.xml @@ -122,6 +122,7 @@ + From 153b15cc816e4fc4f359499ef76ab7489b8ea434 Mon Sep 17 00:00:00 2001 From: "Shmyheliuk, Oleksandr" Date: Thu, 26 May 2016 17:23:42 +0300 Subject: [PATCH 22/57] MAGETWO-53412: Error during creation of international USPS shipment label with dimensions filled in inches --- .../Magento/Shipping/view/adminhtml/web/order/packaging.js | 5 ++--- .../Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js index 3a5959e1b0358..2ad2ff596a707 100644 --- a/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js +++ b/app/code/Magento/Shipping/view/adminhtml/web/order/packaging.js @@ -230,7 +230,7 @@ Packaging.prototype = { validate: function() { var dimensionElements = $("packaging_window").select( - 'input[name=container_length],input[name=container_width],input[name=container_height]' + 'input[name=container_length],input[name=container_width],input[name=container_height],input[name=container_girth]:not("._disabled")' ); var callback = null; if ( dimensionElements.any(function(element) { return !!element.value; })) { @@ -543,8 +543,7 @@ Packaging.prototype = { return; } - var girthEnabled = (packageSize[0].value == 'LARGE' && (packageContainer[0].value == 'NONRECTANGULAR' - || packageContainer[0].value == 'VARIABLE' )); + var girthEnabled = packageContainer[0].value == 'NONRECTANGULAR' || packageContainer[0].value == 'VARIABLE'; if (!girthEnabled) { packageGirth[0].value=''; diff --git a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php index 3118cd9b7669e..b0a91da7a07bc 100644 --- a/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php +++ b/app/code/Magento/Usps/Block/Rma/Adminhtml/Rma/Edit/Tab/General/Shipping/Packaging/Plugin.php @@ -69,7 +69,7 @@ public function aroundCheckSizeAndGirthParameter(\Magento\Framework\DataObject $ $girthEnabled = false; $sizeEnabled = false; if ($carrier && isset($size[0]['value'])) { - if ($size[0]['value'] == Carrier::SIZE_LARGE && in_array( + if (in_array( key($subject->getContainers()), [Carrier::CONTAINER_NONRECTANGULAR, Carrier::CONTAINER_VARIABLE] ) From fd87a6e7c9e1f9efc57dbdb5939d093059955d47 Mon Sep 17 00:00:00 2001 From: Dmytro Kvashnin Date: Thu, 26 May 2016 18:07:34 +0300 Subject: [PATCH 23/57] MAGETWO-53403: Terms and conditions agreement causes fatal error during checkout with PayPal Payments Pro method - repaired checkout agreements for set-payment-agreements --- .../Model/Checkout/Plugin/Validation.php | 12 ++++--- .../Model/Checkout/Plugin/ValidationTest.php | 6 ++-- .../view/frontend/requirejs-config.js | 3 ++ .../web/js/model/agreements-assigner.js | 36 +++++++++++++++++++ .../web/js/model/place-order-mixin.js | 27 +++----------- .../js/model/set-payment-information-mixin.js | 23 ++++++++++++ .../frontend/web/template/payment/form.html | 6 +++- 7 files changed, 82 insertions(+), 31 deletions(-) create mode 100644 app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js create mode 100644 app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js diff --git a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php index ca520a6a0acaf..a57a1f91dcf66 100644 --- a/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php +++ b/app/code/Magento/CheckoutAgreements/Model/Checkout/Plugin/Validation.php @@ -58,7 +58,7 @@ public function beforeSavePaymentInformationAndPlaceOrder( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } @@ -77,17 +77,21 @@ public function beforeSavePaymentInformation( \Magento\Quote\Api\Data\AddressInterface $billingAddress = null ) { if ($this->isAgreementEnabled()) { - $this->validateAgreements($paymentMethod->getExtensionAttributes()->getAgreementIds()); + $this->validateAgreements($paymentMethod); } } /** - * @param int[] $agreements + * @param \Magento\Quote\Api\Data\PaymentInterface $paymentMethod * @throws \Magento\Framework\Exception\CouldNotSaveException * @return void */ - protected function validateAgreements($agreements) + protected function validateAgreements(\Magento\Quote\Api\Data\PaymentInterface $paymentMethod) { + $agreements = $paymentMethod->getExtensionAttributes() === null + ? [] + : $paymentMethod->getExtensionAttributes()->getAgreementIds(); + if (!$this->agreementsValidator->isValid($agreements)) { throw new \Magento\Framework\Exception\CouldNotSaveException( __('Please agree to all the terms and conditions before placing the order.') diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php index 268a746d91998..a2440cf7641a2 100644 --- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php +++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/Checkout/Plugin/ValidationTest.php @@ -85,7 +85,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrder() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -107,7 +107,7 @@ public function testBeforeSavePaymentInformationAndPlaceOrderIfAgreementsNotVali $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(false); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); @@ -125,7 +125,7 @@ public function testBeforeSavePaymentInformation() $this->repositoryMock->expects($this->once())->method('getList')->willReturn([1]); $this->extensionAttributesMock->expects($this->once())->method('getAgreementIds')->willReturn($agreements); $this->agreementsValidatorMock->expects($this->once())->method('isValid')->with($agreements)->willReturn(true); - $this->paymentMock->expects($this->once()) + $this->paymentMock->expects(static::atLeastOnce()) ->method('getExtensionAttributes') ->willReturn($this->extensionAttributesMock); $this->model->beforeSavePaymentInformation($this->subjectMock, $cartId, $this->paymentMock, $this->addressMock); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js index 0e0bd2c2234b5..d0876cc49ce0f 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/requirejs-config.js @@ -9,6 +9,9 @@ var config = { mixins: { 'Magento_Checkout/js/action/place-order': { 'Magento_CheckoutAgreements/js/model/place-order-mixin': true + }, + 'Magento_Checkout/js/action/set-payment-information': { + 'Magento_CheckoutAgreements/js/model/set-payment-information-mixin': true } } } diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js new file mode 100644 index 0000000000000..7b2ef55762bdb --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/agreements-assigner.js @@ -0,0 +1,36 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery' +], function ($) { + 'use strict'; + + var agreementsConfig = window.checkoutConfig.checkoutAgreements; + + /** Override default place order action and add agreement_ids to request */ + return function (paymentData) { + var agreementForm, + agreementData, + agreementIds; + + if (!agreementsConfig.isEnabled) { + return; + } + + agreementForm = $('.payment-method._active div[data-role=checkout-agreements] input'); + agreementData = agreementForm.serializeArray(); + agreementIds = []; + + agreementData.forEach(function (item) { + agreementIds.push(item.value); + }); + + paymentData.extension_attributes = { + agreement_ids: agreementIds + }; + } +}); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js index b7008e8556223..ac459e573f9f2 100644 --- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/place-order-mixin.js @@ -6,35 +6,16 @@ /*global alert*/ define([ 'jquery', - 'mage/utils/wrapper' -], function ($, wrapper) { + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { 'use strict'; - var agreementsConfig = window.checkoutConfig.checkoutAgreements; - return function (placeOrderAction) { /** Override default place order action and add agreement_ids to request */ return wrapper.wrap(placeOrderAction, function (originalAction, paymentData, messageContainer) { - var agreementForm, - agreementData, - agreementIds; - - if (!agreementsConfig.isEnabled) { - return originalAction(paymentData, messageContainer); - } - - agreementForm = $('.payment-method._active form[data-role=checkout-agreements]'); - agreementData = agreementForm.serializeArray(); - agreementIds = []; - - agreementData.forEach(function (item) { - agreementIds.push(item.value); - }); - - paymentData.extension_attributes = { - agreement_ids: agreementIds - }; + agreementsAssigner(paymentData); return originalAction(paymentData, messageContainer); }); diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js new file mode 100644 index 0000000000000..7a94b958f4b0c --- /dev/null +++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/model/set-payment-information-mixin.js @@ -0,0 +1,23 @@ +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +/*jshint browser:true jquery:true*/ +/*global alert*/ +define([ + 'jquery', + 'mage/utils/wrapper', + 'Magento_CheckoutAgreements/js/model/agreements-assigner' +], function ($, wrapper, agreementsAssigner) { + 'use strict'; + + return function (placeOrderAction) { + + /** Override place-order-mixin for set-payment-information action as they differs only by method signature */ + return wrapper.wrap(placeOrderAction, function (originalAction, messageContainer, paymentData) { + agreementsAssigner(paymentData); + + return originalAction(messageContainer, paymentData); + }); + }; +}); \ No newline at end of file diff --git a/app/code/Magento/Vault/view/frontend/web/template/payment/form.html b/app/code/Magento/Vault/view/frontend/web/template/payment/form.html index b444ebbebdaf6..85ff6148bb6f0 100644 --- a/app/code/Magento/Vault/view/frontend/web/template/payment/form.html +++ b/app/code/Magento/Vault/view/frontend/web/template/payment/form.html @@ -32,7 +32,11 @@
- +
+ + + +