Skip to content

Commit ba93925

Browse files
MAGETWO-85549: #12285: The option <var name="allowfullscreen">false</var> for mobile device don't work in product view page gallery #1006
2 parents 32acf60 + 4574c6d commit ba93925

File tree

2 files changed

+97
-1
lines changed

2 files changed

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

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)