-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #99 from magento-api/pull-request
[API-Ext-Ogre] P0-P1 Bugs
- Loading branch information
Showing
21 changed files
with
499 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
app/code/Magento/Translation/Test/Unit/Model/Inline/ParserTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Translation\Test\Unit\Model\Inline; | ||
|
||
/** | ||
* Class ParserTest to test \Magento\Translation\Model\Inline\Parser | ||
*/ | ||
class ParserTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var \Magento\Translation\Model\Inline\Parser|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $model; | ||
|
||
/** | ||
* @var \Magento\Translation\Model\ResourceModel\StringUtilsFactory|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $resourceMock; | ||
|
||
/** | ||
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $storeManagerMock; | ||
|
||
/** | ||
* @var \Zend_Filter_Interface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $inputFilterMock; | ||
|
||
/** | ||
* @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $appStateMock; | ||
|
||
/** | ||
* @var \Magento\Framework\App\Cache\TypeListInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $appCacheMock; | ||
|
||
/** | ||
* @var \Magento\Framework\Translate\InlineInterface|\PHPUnit_Framework_MockObject_MockObject | ||
*/ | ||
private $translateInlineMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->resourceMock = $this->getMockBuilder('Magento\Translation\Model\ResourceModel\StringUtilsFactory') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->storeManagerMock = $this->getMockBuilder('Magento\Store\Model\StoreManagerInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->inputFilterMock = $this->getMockBuilder('Zend_Filter_Interface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->appStateMock = $this->getMockBuilder('Magento\Framework\App\State') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->appCacheMock = $this->getMockBuilder('Magento\Framework\App\Cache\TypeListInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$this->translateInlineMock= $this->getMockBuilder('Magento\Framework\Translate\InlineInterface') | ||
->disableOriginalConstructor() | ||
->setMethods([]) | ||
->getMock(); | ||
|
||
$objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); | ||
$this->model = $objectManagerHelper->getObject( | ||
'Magento\Translation\Model\Inline\Parser', | ||
[ | ||
"_resourceFactory" => $this->resourceMock, | ||
"_storeManager" => $this->storeManagerMock, | ||
"_inputFilter" => $this->inputFilterMock, | ||
"_appState" => $this->appStateMock, | ||
"_appCache" => $this->appCacheMock, | ||
"_translateInline" => $this->translateInlineMock | ||
] | ||
); | ||
} | ||
|
||
public function testProcessResponseBodyStringProcessingAttributesCorrectly() | ||
{ | ||
$testContent = file_get_contents(__DIR__ . '/_files/datatranslate_fixture.html'); | ||
$processedAttributes = [ | ||
"data-translate=\"[{'shown':'* Required Fields','translated':'* Required Fields'," | ||
. "'original':'* Required Fields','location':'Tag attribute (ALT, TITLE, etc.)'}]\"", | ||
"data-translate=\"[{'shown':'Email','translated':'Email','original':'Email'," | ||
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"", | ||
"data-translate=\"[{'shown':'Password','translated':'Password','original':'Password'," | ||
. "'location':'Tag attribute (ALT, TITLE, etc.)'}]\"" | ||
]; | ||
$this->translateInlineMock->expects($this->any())->method('getAdditionalHtmlAttribute')->willReturn(null); | ||
|
||
$processedContent = $this->model->processResponseBodyString($testContent); | ||
foreach ($processedAttributes as $attribute) { | ||
$this->assertContains($attribute, $processedContent, "data-translate attribute not processed correctly"); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/code/Magento/Translation/Test/Unit/Model/Inline/_files/datatranslate_fixture.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<div class="login-container"> | ||
<div class="block block-customer-login"> | ||
<div class="block-content" aria-labelledby="block-customer-login-heading"> | ||
<form class="form form-login" | ||
action="" | ||
method="post" | ||
id="login-form" | ||
data-mage-init='{"validation":{}}'> | ||
<input name="form_key" type="hidden" value="" /> | ||
<fieldset class="fieldset login" data-hasrequired="{{{* Required Fields}}{{* Required Fields}}{{* Required Fields}}{{theme3}}}"> | ||
<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> | ||
<div class="field email required"> | ||
<label class="label" for="email"><span>{{{Email}}{{Email}}{{Email}}{{theme3}}}</span></label> | ||
<div class="control"> | ||
<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}"> | ||
</div> | ||
</div> | ||
<div class="field password required"> | ||
<label for="pass" class="label"><span>{{{Password}}{{Password}}{{Password}}{{theme3}}}</span></label> | ||
<div class="control"> | ||
<input name="login[password]" type="password" autocomplete="off" class="input-text" id="pass" title="{{{Password}}{{Password}}{{Password}}{{theme3}}}" data-validate="{required:true}"> | ||
</div> | ||
</div> | ||
<div class="actions-toolbar"> | ||
<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> | ||
<div class="secondary"><a class="action remind" href=""><span>{{{Forgot Your Password?}}{{Forgot Your Password?}}{{Forgot Your Password?}}{{theme3}}}</span></a></div> | ||
</div> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.