Skip to content

Commit 567da67

Browse files
ENGCOM-1456: [2.3-develop] [ForwardPort] Port of #12285 The option <var name='allowfullscreen'>false</var> for mobile device don't work in product view page gallery #15021
- Merge Pull Request #15021 from gwharton/magento2:2.3-develop-12285 - Merged commits: 1. 435b165 2. 4113f26 3. c0b9e8f 4. 05b1512 5. 2701a4f
2 parents 98e4a6e + 2701a4f commit 567da67

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Framework\Config;
8+
9+
/**
10+
* Tests Magento\Framework\Config\Convert
11+
*/
12+
class ConverterTest extends \PHPUnit\Framework\TestCase
13+
{
14+
/**
15+
* @var Converter
16+
*/
17+
private $converter;
18+
19+
/**
20+
* Tests config value "false" is not interpreted as true.
21+
*
22+
* @param string $sourceString
23+
* @param array $expected
24+
* @dataProvider parseVarElementDataProvider
25+
*/
26+
public function testParseVarElement($sourceString, $expected)
27+
{
28+
$document = new \DOMDocument();
29+
$document->loadXML($sourceString);
30+
$actual = $this->converter->convert($document);
31+
32+
self::assertEquals(
33+
$expected,
34+
$actual
35+
);
36+
}
37+
38+
/**
39+
* Data provider for testParseVarElement.
40+
*
41+
* @return array
42+
*/
43+
public function parseVarElementDataProvider()
44+
{
45+
$sourceString = <<<'XML'
46+
<?xml version="1.0"?>
47+
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
49+
<vars module="Magento_Test">
50+
<var name="str">some string</var>
51+
<var name="int-1">1</var>
52+
<var name="int-0">0</var>
53+
<var name="bool-true">true</var>
54+
<var name="bool-false">false</var>
55+
</vars>
56+
</view>
57+
XML;
58+
$expectedResult = [
59+
'vars' => [
60+
'Magento_Test' => [
61+
'str' => 'some string',
62+
'int-1' => '1',
63+
'int-0' => '0',
64+
'bool-true' => true,
65+
'bool-false' => false
66+
]
67+
]
68+
];
69+
70+
return [
71+
[
72+
$sourceString,
73+
$expectedResult
74+
],
75+
];
76+
}
77+
78+
/**
79+
* @inheritdoc
80+
*/
81+
protected function setUp()
82+
{
83+
$this->converter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
84+
->create(\Magento\Framework\Config\Converter::class);
85+
}
86+
}

lib/internal/Magento/Framework/Config/Converter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ protected function parseVarElement(\DOMElement $node)
103103
}
104104
}
105105
if (!count($result)) {
106-
$result = $node->nodeValue;
106+
$result = (strtolower($node->nodeValue) !== 'true' && strtolower($node->nodeValue) !== 'false')
107+
? $node->nodeValue
108+
: filter_var($node->nodeValue, FILTER_VALIDATE_BOOLEAN);
107109
}
108110
return $result;
109111
}

0 commit comments

Comments
 (0)