Skip to content

Commit

Permalink
#12285: The option <var name="allowfullscreen">false</var> for mobile…
Browse files Browse the repository at this point in the history
… device don't work in product view page gallery
  • Loading branch information
p-bystritsky committed Dec 12, 2017
1 parent 321278b commit ccc35c2
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\Config;

use Magento\Framework\ObjectManagerInterface;

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

/**
* @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->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->converter = $this->objectManager->get(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

0 comments on commit ccc35c2

Please sign in to comment.