Skip to content

Commit 946fce2

Browse files
author
Cari Spruiell
committed
Merge remote-tracking branch 'api/MAGETWO-54051-Inline-Prevents-Frontend-Login' into pull-request
2 parents 1b981f1 + e4d858b commit 946fce2

File tree

3 files changed

+146
-2
lines changed

3 files changed

+146
-2
lines changed

app/code/Magento/Translation/Model/Inline/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,12 @@ private function _prepareTagAttributesForContent(&$content)
436436
$tagHtml = str_replace($matches[0], '', $tagHtml);
437437
$trAttr = ' ' . $this->_getHtmlAttribute(
438438
self::DATA_TRANSLATE,
439-
'[' . htmlspecialchars($matches[1]) . ',' . join(',', $trArr) . ']'
439+
'[' . htmlspecialchars($matches[1]) . ',' . str_replace("\"", "'", join(',', $trArr)) . ']'
440440
);
441441
} else {
442442
$trAttr = ' ' . $this->_getHtmlAttribute(
443443
self::DATA_TRANSLATE,
444-
'[' . join(',', $trArr) . ']'
444+
'[' . str_replace("\"", "'", join(',', $trArr)) . ']'
445445
);
446446
}
447447
$trAttr = $this->_addTranslateAttribute($trAttr);
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Translation\Test\Unit\Model\Inline;
7+
8+
/**
9+
* Class ParserTest to test \Magento\Translation\Model\Inline\Parser
10+
*/
11+
class ParserTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var \Magento\Translation\Model\Inline\Parser|\PHPUnit_Framework_MockObject_MockObject
15+
*/
16+
private $model;
17+
18+
/**
19+
* @var \Magento\Translation\Model\ResourceModel\StringUtilsFactory|\PHPUnit_Framework_MockObject_MockObject
20+
*/
21+
private $resourceMock;
22+
23+
/**
24+
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
25+
*/
26+
private $storeManagerMock;
27+
28+
/**
29+
* @var \Zend_Filter_Interface|\PHPUnit_Framework_MockObject_MockObject
30+
*/
31+
private $inputFilterMock;
32+
33+
/**
34+
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
35+
*/
36+
private $appStateMock;
37+
38+
/**
39+
* @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject
40+
*/
41+
private $appCacheMock;
42+
43+
/**
44+
* @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject
45+
*/
46+
private $translateInlineMock;
47+
48+
protected function setUp()
49+
{
50+
$this->resourceMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtilsFactory')
51+
->disableOriginalConstructor()
52+
->setMethods([])
53+
->getMock();
54+
55+
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface')
56+
->disableOriginalConstructor()
57+
->setMethods([])
58+
->getMock();
59+
60+
$this->inputFilterMock = $this->getMockBuilder('Zend_Filter_Interface')
61+
->disableOriginalConstructor()
62+
->setMethods([])
63+
->getMock();
64+
65+
$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State')
66+
->disableOriginalConstructor()
67+
->setMethods([])
68+
->getMock();
69+
70+
$this->appCacheMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface')
71+
->disableOriginalConstructor()
72+
->setMethods([])
73+
->getMock();
74+
75+
$this->translateInlineMock= $this->getMockBuilder('Magento\Framework\Translate\InlineInterface')
76+
->disableOriginalConstructor()
77+
->setMethods([])
78+
->getMock();
79+
80+
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
81+
$this->model = $objectManagerHelper->getObject(
82+
'Magento\Translation\Model\Inline\Parser',
83+
[
84+
"_resourceFactory" => $this->resourceMock,
85+
"_storeManager" => $this->storeManagerMock,
86+
"_inputFilter" => $this->inputFilterMock,
87+
"_appState" => $this->appStateMock,
88+
"_appCache" => $this->appCacheMock,
89+
"_translateInline" => $this->translateInlineMock
90+
]
91+
);
92+
}
93+
94+
public function testProcessResponseBodyStringProcessingAttributesCorrectly()
95+
{
96+
$testContent = file_get_contents(__DIR__ . '/_files/datatranslate_fixture.html');
97+
$processedAttributes = [
98+
"data-translate=\"[{'shown':'* Required Fields','translated':'* Required Fields',"
99+
. "'original':'* Required Fields','location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
100+
"data-translate=\"[{'shown':'Email','translated':'Email','original':'Email',"
101+
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"",
102+
"data-translate=\"[{'shown':'Password','translated':'Password','original':'Password',"
103+
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\""
104+
];
105+
$this->translateInlineMock->expects($this->any())->method('getAdditionalHtmlAttribute')->willReturn(null);
106+
107+
$processedContent = $this->model->processResponseBodyString($testContent);
108+
foreach ($processedAttributes as $attribute) {
109+
$this->assertContains($attribute, $processedContent, "data-translate attribute not processed correctly");
110+
}
111+
}
112+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="login-container">
2+
<div class="block block-customer-login">
3+
<div class="block-content" aria-labelledby="block-customer-login-heading">
4+
<form class="form form-login"
5+
action=""
6+
method="post"
7+
id="login-form"
8+
data-mage-init='{"validation":{}}'>
9+
<input name="form_key" type="hidden" value="" />
10+
<fieldset class="fieldset login" data-hasrequired="{{{* Required Fields}}{{* Required Fields}}{{* Required Fields}}{{theme3}}}">
11+
<div class="field note">{{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{If you have an account, sign in with your email address.}}{{theme3}}}</div>
12+
<div class="field email required">
13+
<label class="label" for="email"><span>{{{Email}}{{Email}}{{Email}}{{theme3}}}</span></label>
14+
<div class="control">
15+
<input name="login[username]" value="" autocomplete="off" id="email" type="email" class="input-text" title="{{{Email}}{{Email}}{{Email}}{{theme3}}}" data-validate="{required:true, 'validate-email':true}">
16+
</div>
17+
</div>
18+
<div class="field password required">
19+
<label for="pass" class="label"><span>{{{Password}}{{Password}}{{Password}}{{theme3}}}</span></label>
20+
<div class="control">
21+
<input name="login[password]" type="password" autocomplete="off" class="input-text" id="pass" title="{{{Password}}{{Password}}{{Password}}{{theme3}}}" data-validate="{required:true}">
22+
</div>
23+
</div>
24+
<div class="actions-toolbar">
25+
<div class="primary"><button type="submit" class="action login primary" name="send" id="send2"><span>{{{Sign In}}{{Sign In}}{{Sign In}}{{theme3}}}</span></button></div>
26+
<div class="secondary"><a class="action remind" href=""><span>{{{Forgot Your Password?}}{{Forgot Your Password?}}{{Forgot Your Password?}}{{theme3}}}</span></a></div>
27+
</div>
28+
</fieldset>
29+
</form>
30+
</div>
31+
</div>
32+
</div>

0 commit comments

Comments
 (0)