Skip to content

Commit 8bf902a

Browse files
Merge pull request #366 from magento-folks/bugs
Bugs: MAGETWO-58067 [GitHub]Data loss for countries multiselect on backend on website level MAGETWO-57992 Reloading page on checkout causes shipping method to go "undefined" - for mainline MAGETWO-57842 [FT] Wrong selector for Allow Gift Options for items in Shopping Cart in CheckoutWithGiftMessagesTest MAGETWO-55380 Information hint block for Zip/Postal Code should NOT block request for available shipping solution MAGETWO-56814 Unable to print Invoices and Credit memo from Sales>Orders
2 parents d0e44f9 + 2326835 commit 8bf902a

File tree

10 files changed

+207
-17
lines changed

10 files changed

+207
-17
lines changed

app/code/Magento/Backend/view/adminhtml/templates/system/shipping/applicable_country.phtml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ CountryModel.prototype = {
6161
if (applyCountryElement && applyCountryElement.id) {
6262
var specifCountryElement = $(applyCountryElement.id.replace(/sallowspecific/, 'specificcountry'));
6363
var showMethodElement = $(applyCountryElement.id.replace(/sallowspecific/, 'showmethod'));
64+
// 'Use Default' checkbox of the related county list UI element
65+
var useDefaultElement = document.getElementById(specifCountryElement.id + '_inherit');
66+
6467
//var specifErrMsgElement = $(applyCountryElement.id.replace(/sallowspecific/, 'specificerrmsg'));
6568
if (specifCountryElement) {
6669
if (applyCountryElement.value == 1) {
67-
//if specific country element selected
68-
specifCountryElement.enable();
70+
// enable related country select only if its 'Use Default' checkbox is absent or is unchecked
71+
specifCountryElement.disabled = useDefaultElement ? useDefaultElement.checked : false;
6972
if (showMethodElement) {
7073
this.showElement(showMethodElement.up(1));
7174
}

app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ define(
165165
}
166166

167167
if (!availableRate && window.checkoutConfig.selectedShippingMethod) {
168-
availableRate = true;
168+
availableRate = window.checkoutConfig.selectedShippingMethod;
169169
selectShippingMethodAction(window.checkoutConfig.selectedShippingMethod);
170170
}
171171

app/code/Magento/Checkout/view/frontend/web/js/model/shipping-rates-validator.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ define(
127127
element.on('value', function () {
128128
clearTimeout(self.validateAddressTimeout);
129129
self.validateAddressTimeout = setTimeout(function () {
130-
if (self.postcodeValidation()) {
131-
self.validateFields();
132-
}
130+
self.postcodeValidation();
131+
self.validateFields();
133132
}, delay);
134133
});
135134
observedElements.push(element);

app/code/Magento/Config/Block/System/Config/Form/Field/Select/Allowspecific.php

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,32 @@ class Allowspecific extends \Magento\Framework\Data\Form\Element\Select
2222
*/
2323
public function getAfterElementHtml()
2424
{
25-
$javaScript = "\n <script type=\"text/javascript\">require(['prototype'], function(){\n Event.observe('{$this->getHtmlId()}', 'change', function(){\n specific=\$('{$this
26-
->getHtmlId()}').value;\n \$('{$this
27-
->_getSpecificCountryElementId()}').disabled = (!specific || specific!=1);\n });\n });</script>";
28-
return $javaScript . parent::getAfterElementHtml();
25+
$elementId = $this->getHtmlId();
26+
$countryListId = $this->_getSpecificCountryElementId();
27+
$useDefaultElementId = $countryListId . '_inherit';
28+
29+
$elementJavaScript = <<<HTML
30+
<script type="text/javascript">
31+
//<![CDATA[
32+
document.getElementById('{$elementId}').addEventListener('change', function(event) {
33+
var isCountrySpecific = event.target.value == 1,
34+
specificCountriesElement = document.getElementById('{$countryListId}'),
35+
// 'Use Default' checkbox of the related county list UI element
36+
useDefaultElement = document.getElementById('{$useDefaultElementId}');
37+
38+
if (isCountrySpecific) {
39+
// enable related country select only if its 'Use Default' checkbox is absent or is unchecked
40+
specificCountriesElement.disabled = useDefaultElement ? useDefaultElement.checked : false;
41+
} else {
42+
// disable related country select if all countries are used
43+
specificCountriesElement.disabled = true;
44+
}
45+
});
46+
//]]>
47+
</script>
48+
HTML;
49+
50+
return $elementJavaScript . parent::getAfterElementHtml();
2951
}
3052

3153
/**

app/code/Magento/Config/Test/Unit/Block/System/Config/Form/Field/Select/AllowspecificTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ protected function setUp()
3737
public function testGetAfterElementHtml()
3838
{
3939
$this->_formMock->expects(
40-
$this->exactly(2)
40+
$this->once()
4141
)->method(
4242
'getHtmlIdPrefix'
4343
)->will(
4444
$this->returnValue('test_prefix_')
4545
);
4646
$this->_formMock->expects(
47-
$this->exactly(2)
47+
$this->once()
4848
)->method(
4949
'getHtmlIdSuffix'
5050
)->will(
@@ -57,7 +57,7 @@ public function testGetAfterElementHtml()
5757

5858
$actual = $this->_object->getAfterElementHtml();
5959

60-
$this->assertStringEndsWith($afterHtmlCode, $actual);
60+
$this->assertStringEndsWith('</script>' . $afterHtmlCode, $actual);
6161
$this->assertStringStartsWith('<script type="text/javascript">', trim($actual));
6262
$this->assertContains('test_prefix_spec_element_test_suffix', $actual);
6363
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Controller\Adminhtml\Order;
8+
9+
use Magento\Framework\Controller\ResultFactory;
10+
11+
abstract class PdfDocumentsMassAction extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
12+
{
13+
/**
14+
* @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
15+
*/
16+
protected $orderCollectionFactory;
17+
18+
/**
19+
* Execute action
20+
*
21+
* @return \Magento\Backend\Model\View\Result\Redirect
22+
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
23+
*/
24+
public function execute()
25+
{
26+
try {
27+
$collection = $this->filter->getCollection($this->getOrderCollection()->create());
28+
return $this->massAction($collection);
29+
} catch (\Exception $e) {
30+
$this->messageManager->addError($e->getMessage());
31+
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
32+
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
33+
return $resultRedirect->setPath($this->redirectUrl);
34+
}
35+
}
36+
37+
/**
38+
* Get Order Collection Factory
39+
*
40+
* @return \Magento\Sales\Model\ResourceModel\Order\CollectionFactory
41+
* @deprecated
42+
*/
43+
private function getOrderCollection()
44+
{
45+
if ($this->orderCollectionFactory === null) {
46+
$this->orderCollectionFactory = \Magento\Framework\App\ObjectManager::getInstance()->get(
47+
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class
48+
);
49+
}
50+
return $this->orderCollectionFactory;
51+
}
52+
}

app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfcreditmemos.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Class Pdfcreditmemos
2222
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2323
*/
24-
class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
24+
class Pdfcreditmemos extends \Magento\Sales\Controller\Adminhtml\Order\PdfDocumentsMassAction
2525
{
2626
/**
2727
* @var FileFactory

app/code/Magento/Sales/Controller/Adminhtml/Order/Pdfinvoices.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
/**
2121
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
2222
*/
23-
class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
23+
class Pdfinvoices extends \Magento\Sales\Controller\Adminhtml\Order\PdfDocumentsMassAction
2424
{
2525
/**
2626
* @var FileFactory
@@ -79,7 +79,7 @@ protected function massAction(AbstractCollection $collection)
7979
return $this->resultRedirectFactory->create()->setPath($this->getComponentRefererUrl());
8080
}
8181
return $this->fileFactory->create(
82-
sprintf('packingslip%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
82+
sprintf('invoice%s.pdf', $this->dateTime->date('Y-m-d_H-i-s')),
8383
$this->pdfInvoice->getPdf($invoicesCollection->getItems())->render(),
8484
DirectoryList::VAR_DIR,
8585
'application/pdf'
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Sales\Test\Unit\Controller\Adminhtml;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
10+
11+
class PdfDocumentsMassActionTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Sales\Controller\Adminhtml\Order\PdfDocumentsMassAction
15+
*/
16+
private $controller;
17+
18+
/**
19+
* @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $resultRedirect;
22+
23+
/**
24+
* @var \Magento\Framework\Message\Manager|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $messageManager;
27+
28+
/**
29+
* @var \PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $orderCollectionFactoryMock;
32+
33+
/**
34+
* @var \PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $orderCollectionMock;
37+
38+
/**
39+
* @var \PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $filterMock;
42+
43+
protected function setUp()
44+
{
45+
$objectManagerHelper = new ObjectManagerHelper($this);
46+
47+
$this->messageManager = $this->getMock(
48+
\Magento\Framework\Message\Manager::class,
49+
['addSuccess', 'addError'],
50+
[],
51+
'',
52+
false
53+
);
54+
55+
$this->orderCollectionMock = $this->getMock(
56+
\Magento\Sales\Model\ResourceModel\Order\Collection::class,
57+
[],
58+
[],
59+
'',
60+
false
61+
);
62+
$this->filterMock = $this->getMock(\Magento\Ui\Component\MassAction\Filter::class, [], [], '', false);
63+
64+
$this->orderCollectionFactoryMock = $this->getMock(
65+
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory::class,
66+
['create'],
67+
[],
68+
'',
69+
false
70+
);
71+
72+
$this->orderCollectionFactoryMock
73+
->expects($this->once())
74+
->method('create')
75+
->willReturn($this->orderCollectionMock);
76+
$this->resultRedirect = $this->getMock(\Magento\Backend\Model\View\Result\Redirect::class, [], [], '', false);
77+
$resultRedirectFactory = $this->getMock(
78+
\Magento\Framework\Controller\ResultFactory::class,
79+
[],
80+
[],
81+
'',
82+
false
83+
);
84+
$resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect);
85+
$this->controller = $objectManagerHelper->getObject(
86+
\Magento\Sales\Controller\Adminhtml\Order\Pdfinvoices::class,
87+
[
88+
'filter' => $this->filterMock,
89+
'resultFactory' => $resultRedirectFactory,
90+
'messageManager' => $this->messageManager
91+
]
92+
);
93+
$objectManagerHelper
94+
->setBackwardCompatibleProperty(
95+
$this->controller,
96+
'orderCollectionFactory',
97+
$this->orderCollectionFactoryMock
98+
);
99+
}
100+
101+
public function testExecute()
102+
{
103+
$exception = new \Exception();
104+
$this->filterMock
105+
->expects($this->once())
106+
->method('getCollection')
107+
->with($this->orderCollectionMock)
108+
->willThrowException($exception);
109+
$this->messageManager->expects($this->once())->method('addError');
110+
111+
$this->resultRedirect->expects($this->once())->method('setPath')->willReturnSelf();
112+
$this->controller->execute($exception);
113+
}
114+
}

dev/tests/functional/tests/app/Magento/GiftMessage/Test/Block/Cart/Item/GiftOptions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class GiftOptions extends Form
3333
*
3434
* @var string
3535
*/
36-
protected $allowGiftOptions = '//a[contains(@class,"action-gift")][ancestor::tbody[contains(.,"%s")]]';
36+
protected $allowGiftOptions = '//*[contains(@class,"action-gift")][ancestor::tbody[contains(.,"%s")]]';
3737

3838
/**
3939
* Selector for apply Gift Message button on order

0 commit comments

Comments
 (0)