Skip to content

Commit 7b3a73a

Browse files
author
Kopylova,Olga(okopylova)
committed
Merge pull request #318 from magento-ogre/MAGETWO-37728-lost-option-in-generator
[Ogres] Two bug-fixes + [Folks] bug-fixes
2 parents aaa8291 + fc7ed09 commit 7b3a73a

File tree

17 files changed

+151
-104
lines changed

17 files changed

+151
-104
lines changed

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/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/Test/Unit/Console/Command/XmlConverterCommandTest.php

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Magento\Developer\Console\Command\XmlConverterCommand;
1010
use Symfony\Component\Console\Tester\CommandTester;
1111
use Magento\Developer\Model\Tools\Formatter;
12+
use Magento\Framework\DomDocument\DomDocumentFactory;
13+
use Magento\Framework\XsltProcessor\XsltProcessorFactory;
1214

1315
class XmlConverterCommandTest extends \PHPUnit_Framework_TestCase
1416
{
@@ -23,35 +25,44 @@ class XmlConverterCommandTest extends \PHPUnit_Framework_TestCase
2325
private $command;
2426

2527
/**
26-
* @var \DOMDocument|\PHPUnit_Framework_MockObject_MockObject
28+
* @var DomDocumentFactory|\PHPUnit_Framework_MockObject_MockObject
2729
*/
28-
private $domXml;
30+
private $domFactory;
2931

3032
/**
31-
* @var \DOMDocument|\PHPUnit_Framework_MockObject_MockObject
33+
* @var XsltProcessorFactory|\PHPUnit_Framework_MockObject_MockObject
3234
*/
33-
private $domXsl;
34-
35-
/**
36-
* @var \XSLTProcessor|\PHPUnit_Framework_MockObject_MockObject
37-
*/
38-
private $xsltProcessor;
35+
private $xsltProcessorFactory;
3936

4037
public function setUp()
4138
{
4239
$this->formatter = $this->getMock('Magento\Developer\Model\Tools\Formatter', [], [], '', false);
43-
$this->domXml = $this->getMock('DOMDocument', [], [], '', false);
44-
$this->domXsl = $this->getMock('DOMDocument', [], [], '', false);
45-
$this->xsltProcessor = $this->getMock('XSLTProcessor', [], [], '', false);
46-
$this->command = new XmlConverterCommand($this->formatter, $this->domXml, $this->domXsl, $this->xsltProcessor);
40+
$this->domFactory = $this->getMock('Magento\Framework\DomDocument\DomDocumentFactory', [], [], '', false);
41+
$this->xsltProcessorFactory = $this->getMock(
42+
'Magento\Framework\XsltProcessor\XsltProcessorFactory',
43+
[],
44+
[],
45+
'',
46+
false
47+
);
48+
49+
$this->command = new XmlConverterCommand($this->formatter, $this->domFactory, $this->xsltProcessorFactory);
4750
}
4851

4952
public function testExecute()
5053
{
51-
$this->domXml->expects($this->once())->method('load')->with('file.xml');
52-
$this->domXsl->expects($this->once())->method('load')->with('file.xsl');
54+
$domXml = $this->getMock('DOMDocument', [], [], '', false);
55+
$domXsl = clone $domXml;
56+
$domXml->expects($this->once())->method('load')->with('file.xml');
57+
$domXsl->expects($this->once())->method('load')->with('file.xsl');
58+
59+
$this->domFactory->expects($this->at(0))->method('create')->willReturn($domXml);
60+
$this->domFactory->expects($this->at(1))->method('create')->willReturn($domXsl);
61+
62+
$xsltProcessor = $this->getMock('XSLTProcessor', [], [], '', false);
63+
$xsltProcessor->expects($this->once())->method('transformToXml')->with($domXml)->willReturn('XML');
5364

54-
$this->xsltProcessor->expects($this->once())->method('transformToXml')->with($this->domXml)->willReturn('XML');
65+
$this->xsltProcessorFactory->expects($this->once())->method('create')->willReturn($xsltProcessor);
5566

5667
$this->formatter->expects($this->once())->method('format')->with('XML')->willReturn('result');
5768

app/code/Magento/Developer/etc/di.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,4 @@
3232
</argument>
3333
</arguments>
3434
</type>
35-
<type name="Magento\Developer\Console\Command\XmlConverterCommand">
36-
<arguments>
37-
<argument name="domXml" xsi:type="object" shared="false">DOMDocument</argument>
38-
<argument name="domXsl" xsi:type="object" shared="false">DOMDocument</argument>
39-
</arguments>
40-
</type>
4135
</config>

app/code/Magento/Webapi/Model/Soap/Server.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ class Server
3131
*/
3232
protected $_configScope;
3333

34-
/**
35-
* @var \Magento\Framework\DomDocument\Factory
36-
*/
37-
protected $_domDocumentFactory;
38-
3934
/**
4035
* @var \Magento\Webapi\Controller\Soap\Request
4136
*/
@@ -67,7 +62,6 @@ class Server
6762
* @param \Magento\Framework\App\AreaList $areaList
6863
* @param \Magento\Framework\Config\ScopeInterface $configScope
6964
* @param \Magento\Webapi\Controller\Soap\Request $request
70-
* @param \Magento\Framework\DomDocument\Factory $domDocumentFactory
7165
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
7266
* @param \Magento\Webapi\Model\Soap\ServerFactory $soapServerFactory
7367
* @param \Magento\Framework\Reflection\TypeProcessor $typeProcessor
@@ -78,7 +72,6 @@ public function __construct(
7872
\Magento\Framework\App\AreaList $areaList,
7973
\Magento\Framework\Config\ScopeInterface $configScope,
8074
\Magento\Webapi\Controller\Soap\Request $request,
81-
\Magento\Framework\DomDocument\Factory $domDocumentFactory,
8275
\Magento\Store\Model\StoreManagerInterface $storeManager,
8376
\Magento\Webapi\Model\Soap\ServerFactory $soapServerFactory,
8477
\Magento\Framework\Reflection\TypeProcessor $typeProcessor,
@@ -94,7 +87,6 @@ public function __construct(
9487
$this->_areaList = $areaList;
9588
$this->_configScope = $configScope;
9689
$this->_request = $request;
97-
$this->_domDocumentFactory = $domDocumentFactory;
9890
$this->_storeManager = $storeManager;
9991
$this->_soapServerFactory = $soapServerFactory;
10092
$this->_typeProcessor = $typeProcessor;

app/code/Magento/Webapi/Test/Unit/Model/Soap/ServerTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ class ServerTest extends \PHPUnit_Framework_TestCase
1818
/** @var \Magento\Webapi\Controller\Soap\Request */
1919
protected $_requestMock;
2020

21-
/** @var \Magento\Framework\DomDocument\Factory */
22-
protected $_domDocumentFactory;
23-
2421
/** @var \Magento\Store\Model\StoreManagerInterface */
2522
protected $_storeManagerMock;
2623

@@ -67,10 +64,6 @@ protected function setUp()
6764
'Magento\Webapi\Controller\Soap\Request'
6865
)->disableOriginalConstructor()->getMock();
6966

70-
$this->_domDocumentFactory = $this->getMockBuilder(
71-
'Magento\Framework\DomDocument\Factory'
72-
)->disableOriginalConstructor()->getMock();
73-
7467
$this->_soapServerFactory = $this->getMockBuilder(
7568
'Magento\Webapi\Model\Soap\ServerFactory'
7669
)->disableOriginalConstructor()->getMock();
@@ -90,7 +83,6 @@ protected function setUp()
9083
$areaListMock,
9184
$configScopeMock,
9285
$this->_requestMock,
93-
$this->_domDocumentFactory,
9486
$this->_storeManagerMock,
9587
$this->_soapServerFactory,
9688
$this->_typeProcessor,

dev/tests/static/testsuite/Magento/Test/Integrity/Readme/_files/blacklist/ce.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ lib/internal/Magento/Framework/App/Utility
3737
lib/internal/Magento/Framework/Url
3838
lib/internal/Magento/Framework/UrlInterface
3939
lib/internal/Magento/Framework/Xml
40+
lib/internal/Magento/Framework/XsltProcessor
4041
lib/internal/Magento/Framework
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DomDocument;
7+
8+
/**
9+
* DOM document factory
10+
*/
11+
class DomDocumentFactory
12+
{
13+
/**
14+
* Create empty DOM document instance.
15+
*
16+
* @return \DOMDocument
17+
*/
18+
public function create()
19+
{
20+
return new \DOMDocument();
21+
}
22+
}

lib/internal/Magento/Framework/DomDocument/Factory.php

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

lib/internal/Magento/Framework/Url/SecurityInfo.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface
1616
*/
1717
protected $secureUrlsList = [];
1818

19+
/**
20+
* List of patterns excluded form secure url list
21+
*/
22+
protected $excludedUrlsList = [];
23+
1924
/**
2025
* List of already checked urls
2126
*
@@ -25,10 +30,12 @@ class SecurityInfo implements \Magento\Framework\Url\SecurityInfoInterface
2530

2631
/**
2732
* @param string[] $secureUrlList
33+
* @param string[] $excludedUrlList
2834
*/
29-
public function __construct($secureUrlList = [])
35+
public function __construct($secureUrlList = [], $excludedUrlList = [])
3036
{
3137
$this->secureUrlsList = $secureUrlList;
38+
$this->excludedUrlsList = $excludedUrlList;
3239
}
3340

3441
/**
@@ -41,6 +48,11 @@ public function isSecure($url)
4148
{
4249
if (!isset($this->secureUrlsCache[$url])) {
4350
$this->secureUrlsCache[$url] = false;
51+
foreach ($this->excludedUrlsList as $match) {
52+
if (strpos($url, (string)$match) === 0) {
53+
return $this->secureUrlsCache[$url];
54+
}
55+
}
4456
foreach ($this->secureUrlsList as $match) {
4557
if (strpos($url, (string)$match) === 0) {
4658
$this->secureUrlsCache[$url] = true;

0 commit comments

Comments
 (0)