Skip to content

[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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php declare(strict_types=1);
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\Config;

/**
* Tests Magento\Framework\Config\Convert
*/
class ConverterTest extends \PHPUnit\Framework\TestCase
{
/**
* @var Converter
*/
private $converter;

/**
* Tests config value "false" is not interpreted as true.
*
* @param string $sourceString
* @param array $expected
* @dataProvider parseVarElementDataProvider
*/
public function testParseVarElement($sourceString, $expected)
{
$document = new \DOMDocument();
$document->loadXML($sourceString);
$actual = $this->converter->convert($document);

self::assertEquals(
$expected,
$actual
);
}

/**
* Data provider for testParseVarElement.
*
* @return array
*/
public function parseVarElementDataProvider()
{
$sourceString = <<<'XML'
<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
<vars module="Magento_Test">
<var name="str">some string</var>
<var name="int-1">1</var>
<var name="int-0">0</var>
<var name="bool-true">true</var>
<var name="bool-false">false</var>
</vars>
</view>
XML;
$expectedResult = [
'vars' => [
'Magento_Test' => [
'str' => 'some string',
'int-1' => '1',
'int-0' => '0',
'bool-true' => true,
'bool-false' => false
]
]
];

return [
[
$sourceString,
$expectedResult
],
];
}

/**
* @inheritdoc
*/
protected function setUp()
{
$this->converter = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
->create(\Magento\Framework\Config\Converter::class);
}
}
4 changes: 3 additions & 1 deletion lib/internal/Magento/Framework/Config/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ protected function parseVarElement(\DOMElement $node)
}
}
if (!count($result)) {
$result = $node->nodeValue;
$result = (strtolower($node->nodeValue) !== 'true' && strtolower($node->nodeValue) !== 'false')
? $node->nodeValue
: filter_var($node->nodeValue, FILTER_VALIDATE_BOOLEAN);
}
return $result;
}
Expand Down