Skip to content

Commit 1992627

Browse files
author
Stanislav Idolov
committed
Merge remote-tracking branch 'magento2ce/develop' into ce_publication
2 parents 57ab446 + 2f09fad commit 1992627

File tree

67 files changed

+1132
-631
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1132
-631
lines changed

app/code/Magento/Backend/view/adminhtml/layout/default.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
<referenceContainer name="page.formkey">
4343
<block class="Magento\Backend\Block\Admin\Formkey" name="formkey" as="formkey" template="Magento_Backend::admin/formkey.phtml"/>
4444
</referenceContainer>
45-
<referenceContainer name="page.js.translate">
46-
<block class="Magento\Framework\View\Element\Template" name="js_translate" as="js_translate" template="Magento_Backend::page/js/translate.phtml"/>
47-
</referenceContainer>
4845
<referenceContainer name="main.top">
4946
<block class="Magento\Theme\Block\Html\Title" name="page.title" template="title.phtml"/>
5047
</referenceContainer>

app/code/Magento/Backend/view/adminhtml/templates/page/js/translate.phtml

Lines changed: 0 additions & 52 deletions
This file was deleted.

app/code/Magento/Checkout/view/frontend/web/js/view/billing-address.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ define(
110110
this.source.set('params.invalid', false);
111111
fields.trigger('change');
112112
this.source.trigger('billingAddress.data.validate');
113+
if (!customer.isLoggedIn()()) {
114+
this.source.trigger('customerDetails.data.validate');
115+
}
113116
this.validateAdditionalAddressFields();
114117
},
115118
validateAdditionalAddressFields: function() {

app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php

Lines changed: 104 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010

1111
class FormTest extends \PHPUnit_Framework_TestCase
1212
{
13+
/**
14+
* @var \PHPUnit_Framework_MockObject_MockBuilder
15+
*/
16+
protected $_objectBuilder;
17+
1318
/**
1419
* @var \Magento\Config\Block\System\Config\Form
1520
*/
16-
protected $_object;
21+
protected $object;
1722

1823
/**
1924
* @var \PHPUnit_Framework_MockObject_MockObject
@@ -166,39 +171,93 @@ protected function setUp()
166171
'context' => $context,
167172
];
168173

169-
$this->_object = $helper->getObject('Magento\Config\Block\System\Config\Form', $data);
170-
$this->_object->setData('scope_id', 1);
174+
$objectArguments = $helper->getConstructArguments('Magento\Config\Block\System\Config\Form', $data);
175+
$this->_objectBuilder = $this->getMockBuilder('Magento\Config\Block\System\Config\Form')
176+
->setConstructorArgs($objectArguments)
177+
->setMethods(['something']);
178+
$this->object = $helper->getObject('Magento\Config\Block\System\Config\Form', $data);
179+
$this->object->setData('scope_id', 1);
171180
}
172181

173-
public function testInitFormWithoutSection()
182+
/**
183+
* @param bool $sectionIsVisible
184+
* @dataProvider initFormDataProvider
185+
*/
186+
public function testInitForm($sectionIsVisible)
174187
{
188+
/** @var \Magento\Config\Block\System\Config\Form | \PHPUnit_Framework_MockObject_MockObject $object */
189+
$object = $this->_objectBuilder->setMethods(['_initGroup'])->getMock();
190+
$object->setData('scope_id', 1);
175191
$this->_formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_formMock));
176-
$this->_formMock->expects($this->once())->method('setParent')->with($this->_object);
192+
$this->_formMock->expects($this->once())->method('setParent')->with($object);
177193
$this->_formMock->expects($this->once())->method('setBaseUrl')->with('base_url');
178194
$this->_urlModelMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('base_url'));
179195

196+
$sectionMock = $this->getMockBuilder('\Magento\Config\Model\Config\Structure\Element\Section')
197+
->disableOriginalConstructor()
198+
->getMock();
199+
if ($sectionIsVisible) {
200+
$sectionMock->expects($this->once())
201+
->method('isVisible')
202+
->willReturn(true);
203+
$sectionMock->expects($this->once())
204+
->method('getChildren')
205+
->willReturn([
206+
$this->getMock(
207+
'Magento\Config\Model\Config\Structure\Element\Group',
208+
[],
209+
[],
210+
'',
211+
false,
212+
false
213+
)
214+
]);
215+
}
216+
180217
$this->_systemConfigMock->expects(
181218
$this->once()
182219
)->method(
183220
'getElement'
184221
)->with(
185222
'section_code'
186223
)->will(
187-
$this->returnValue(null)
224+
$this->returnValue($sectionIsVisible ? $sectionMock : null)
188225
);
189226

190-
$this->_object->initForm();
191-
$this->assertEquals($this->_formMock, $this->_object->getForm());
227+
if ($sectionIsVisible) {
228+
$object->expects($this->once())
229+
->method('_initGroup');
230+
} else {
231+
$object->expects($this->never())
232+
->method('_initGroup');
233+
}
234+
235+
236+
$object->initForm();
237+
$this->assertEquals($this->_formMock, $object->getForm());
238+
}
239+
240+
public function initFormDataProvider()
241+
{
242+
return [
243+
[false],
244+
[true]
245+
];
192246
}
193247

194248
/**
195-
* @return void
249+
* @param bool $shouldCloneFields
250+
* @param array $prefixes
251+
* @param int $callNum
252+
* @dataProvider initGroupDataProvider
196253
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
197254
*/
198-
public function testInitGroup()
255+
public function testInitGroup($shouldCloneFields, $prefixes, $callNum)
199256
{
257+
/** @var \Magento\Config\Block\System\Config\Form | \PHPUnit_Framework_MockObject_MockObject $object */
258+
$object = $this->_objectBuilder->setMethods(['initFields'])->getMock();
200259
$this->_formFactoryMock->expects($this->any())->method('create')->will($this->returnValue($this->_formMock));
201-
$this->_formMock->expects($this->once())->method('setParent')->with($this->_object);
260+
$this->_formMock->expects($this->once())->method('setParent')->with($object);
202261
$this->_formMock->expects($this->once())->method('setBaseUrl')->with('base_url');
203262
$this->_urlModelMock->expects($this->any())->method('getBaseUrl')->will($this->returnValue('base_url'));
204263

@@ -227,8 +286,6 @@ public function testInitGroup()
227286
false
228287
);
229288

230-
$cloneModelMock->expects($this->once())->method('getPrefixes')->will($this->returnValue([]));
231-
232289
$groupMock = $this->getMock(
233290
'Magento\Config\Model\Config\Structure\Element\Group',
234291
[],
@@ -243,8 +300,7 @@ public function testInitGroup()
243300
$groupMock->expects($this->once())->method('getComment')->will($this->returnValue('comment'));
244301
$groupMock->expects($this->once())->method('isExpanded')->will($this->returnValue(false));
245302
$groupMock->expects($this->once())->method('populateFieldset');
246-
$groupMock->expects($this->once())->method('shouldCloneFields')->will($this->returnValue(true));
247-
$groupMock->expects($this->once())->method('getCloneModel')->will($this->returnValue($cloneModelMock));
303+
$groupMock->expects($this->once())->method('shouldCloneFields')->will($this->returnValue($shouldCloneFields));
248304
$groupMock->expects($this->once())->method('getData')->will($this->returnValue('some group data'));
249305
$groupMock->expects(
250306
$this->once()
@@ -300,9 +356,40 @@ public function testInitGroup()
300356
)->will(
301357
$this->returnValue($formFieldsetMock)
302358
);
303-
$this->_object->initForm();
359+
360+
if ($shouldCloneFields) {
361+
$cloneModelMock->expects($this->once())->method('getPrefixes')->will($this->returnValue($prefixes));
362+
363+
$groupMock->expects($this->once())->method('getCloneModel')->will($this->returnValue($cloneModelMock));
364+
}
365+
366+
if ($shouldCloneFields && $prefixes) {
367+
$object->expects($this->exactly($callNum))
368+
->method('initFields')
369+
->with(
370+
$formFieldsetMock,
371+
$groupMock,
372+
$sectionMock,
373+
$prefixes[0]['field'],
374+
$prefixes[0]['label']
375+
);
376+
} else {
377+
$object->expects($this->exactly($callNum))
378+
->method('initFields')
379+
->with($formFieldsetMock, $groupMock, $sectionMock);
380+
}
381+
382+
$object->initForm();
304383
}
305384

385+
public function initGroupDataProvider()
386+
{
387+
return [
388+
[true, [['field' => 'field', 'label' => 'label']], 1],
389+
[true, [], 0],
390+
[false, [['field' => 'field', 'label' => 'label']], 1],
391+
];
392+
}
306393
/**
307394
* @dataProvider initFieldsDataProvider
308395
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -460,7 +547,7 @@ public function testInitFields($backendConfigValue, $configValue, $configPath, $
460547

461548
$fieldMock->expects($this->once())->method('populateInput');
462549

463-
$this->_object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix);
550+
$this->object->initFields($fieldsetMock, $groupMock, $sectionMock, $fieldPrefix, $labelPrefix);
464551
}
465552

466553
/**

app/code/Magento/Customer/Block/CustomerData.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@ public function getCookieLifeTime()
1818
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
1919
);
2020
}
21+
22+
/**
23+
* Get url for customer data ajax requests. Returns url with protocol matching used to request page.
24+
*
25+
* @param string $route
26+
* @return string Customer data url.
27+
*/
28+
public function getCustomerDataUrl($route)
29+
{
30+
return $this->getUrl($route, ['_secure' => $this->getRequest()->isSecure()]);
31+
}
2132
}

app/code/Magento/Customer/etc/frontend/di.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
<argument name="secureUrlList" xsi:type="array">
1212
<item name="customer" xsi:type="string">/customer/</item>
1313
</argument>
14+
<argument name="excludedUrlList" xsi:type="array">
15+
<item name="customer_sections" xsi:type="string">/customer/section/load</item>
16+
</argument>
1417
</arguments>
1518
</type>
1619
<type name="Magento\Framework\View\Layout">

app/code/Magento/Customer/view/frontend/templates/js/customer-data.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<?php
1212
echo $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode([
1313
'*' => ['Magento_Customer/js/customer-data' => [
14-
'sectionLoadUrl' => $block->getUrl('customer/section/load'),
14+
'sectionLoadUrl' => $block->getCustomerDataUrl('customer/section/load'),
1515
'cookieLifeTime' => $block->getCookieLifeTime(),
1616
]],
1717
]);

app/code/Magento/Developer/Console/Command/XmlConverterCommand.php

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Symfony\Component\Console\Input\InputInterface;
1313
use Symfony\Component\Console\Output\OutputInterface;
1414
use Magento\Developer\Model\Tools\Formatter;
15+
use Magento\Framework\DomDocument\DomDocumentFactory;
16+
use Magento\Framework\XsltProcessor\XsltProcessorFactory;
1517

1618
/**
1719
* Class XmlConverterCommand
@@ -40,39 +42,30 @@ class XmlConverterCommand extends Command
4042
private $formatter;
4143

4244
/**
43-
* @var \DOMDocument
45+
* @var DomDocumentFactory
4446
*/
45-
private $domXml;
47+
private $domFactory;
4648

4749
/**
48-
* @var \DOMDocument
50+
* @var XsltProcessorFactory
4951
*/
50-
private $domXsl;
51-
52-
/**
53-
* @var \XSLTProcessor
54-
*/
55-
private $xsltProcessor;
52+
private $xsltProcessorFactory;
5653

5754
/**
5855
* Inject dependencies
5956
*
6057
* @param Formatter $formatter
61-
* @param \DOMDocument $domXml
62-
* @param \DOMDocument $domXsl
63-
* @param \XSLTProcessor $xsltProcessor
64-
* @SuppressWarnings(Magento.TypeDuplication)
58+
* @param DomDocumentFactory $domFactory
59+
* @param XsltProcessorFactory $xsltProcessorFactory
6560
*/
6661
public function __construct(
6762
Formatter $formatter,
68-
\DOMDocument $domXml,
69-
\DOMDocument $domXsl,
70-
\XSLTProcessor $xsltProcessor
63+
DomDocumentFactory $domFactory,
64+
XsltProcessorFactory $xsltProcessorFactory
7165
) {
7266
$this->formatter = $formatter;
73-
$this->domXml = $domXml;
74-
$this->domXsl = $domXsl;
75-
$this->xsltProcessor = $xsltProcessor;
67+
$this->domFactory = $domFactory;
68+
$this->xsltProcessorFactory = $xsltProcessorFactory;
7669

7770
parent::__construct();
7871
}
@@ -113,16 +106,20 @@ protected function configure()
113106
protected function execute(InputInterface $input, OutputInterface $output)
114107
{
115108
try {
109+
$domXml = $this->domFactory->create();
110+
$domXsl = $this->domFactory->create();
111+
$xsltProcessor = $this->xsltProcessorFactory->create();
112+
116113
$xmlFile = $input->getArgument(self::XML_FILE_ARGUMENT);
117-
$this->domXml->preserveWhiteSpace = true;
118-
$this->domXml->load($xmlFile);
114+
$domXml->preserveWhiteSpace = true;
115+
$domXml->load($xmlFile);
119116

120-
$this->domXsl->preserveWhiteSpace = true;
121-
$this->domXsl->load($input->getArgument(self::PROCESSOR_ARGUMENT));
117+
$domXsl->preserveWhiteSpace = true;
118+
$domXsl->load($input->getArgument(self::PROCESSOR_ARGUMENT));
122119

123-
$this->xsltProcessor->registerPHPFunctions();
124-
$this->xsltProcessor->importStylesheet($this->domXsl);
125-
$transformedDoc = $this->xsltProcessor->transformToXml($this->domXml);
120+
$xsltProcessor->registerPHPFunctions();
121+
$xsltProcessor->importStylesheet($domXsl);
122+
$transformedDoc = $xsltProcessor->transformToXml($domXml);
126123
$result = $this->formatter->format($transformedDoc);
127124

128125
if ($input->getOption(self::OVERWRITE_OPTION)) {

app/code/Magento/Developer/Model/View/Asset/PreProcessor/DeveloperChain.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class DeveloperChain extends Chain
1515
* @param string $origContent
1616
* @param string $origContentType
1717
* @param null $origAssetPath
18+
* @codeCoverageIgnore
1819
*/
1920
public function __construct(
2021
LocalInterface $asset,

0 commit comments

Comments
 (0)