Skip to content

Commit 8c4ba3c

Browse files
authored
Merge pull request #2171 from magento-chaika/MAGETWO-88191
Fixed issues: - MAGETWO-88191 Type mismatch in translation js dataprovider
2 parents 598410c + 53a2709 commit 8c4ba3c

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

app/code/Magento/Translation/Model/Js/DataProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function getData($themePath)
113113
}
114114
} catch (\Exception $e) {
115115
throw new LocalizedException(
116-
sprintf(__('Error while translating phrase "%s" in file %s.'), $phrase, $filePath[0])
116+
__('Error while translating phrase "%s" in file %s.', $phrase, $filePath[0])
117117
);
118118
}
119119
}
@@ -145,7 +145,7 @@ protected function getPhrases($content)
145145
}
146146
if (false === $result) {
147147
throw new LocalizedException(
148-
sprintf(__('Error while generating js translation dictionary: "%s"'), error_get_last())
148+
__('Error while generating js translation dictionary: "%s"', error_get_last())
149149
);
150150
}
151151
}

app/code/Magento/Translation/Test/Unit/Model/Js/DataProviderTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Translation\Test\Unit\Model\Js;
78

89
use Magento\Framework\App\State;
@@ -148,4 +149,39 @@ public function testGetData()
148149

149150
$this->assertEquals($expectedResult, $this->model->getData($themePath));
150151
}
152+
153+
/**
154+
* @expectedException \Magento\Framework\Exception\LocalizedException
155+
*/
156+
public function testGetDataThrowingException()
157+
{
158+
$themePath = 'blank';
159+
$areaCode = 'adminhtml';
160+
161+
$patterns = ['~\$\.mage\.__\(([\'"])(.+?)\1\)~'];
162+
163+
$this->fileReadMock->expects($this->once())
164+
->method('readAll')
165+
->willReturn('content1$.mage.__("hello1")content1');
166+
167+
$this->appStateMock->expects($this->once())
168+
->method('getAreaCode')
169+
->willReturn($areaCode);
170+
$this->filesUtilityMock->expects($this->any())
171+
->method('getJsFiles')
172+
->willReturn(['test']);
173+
$this->filesUtilityMock->expects($this->any())
174+
->method('getStaticHtmlFiles')
175+
->willReturn(['test']);
176+
177+
$this->configMock->expects($this->any())
178+
->method('getPatterns')
179+
->willReturn($patterns);
180+
181+
$this->translateMock->expects($this->once())
182+
->method('render')
183+
->willThrowException(new \Exception('Test exception'));
184+
185+
$this->model->getData($themePath);
186+
}
151187
}

0 commit comments

Comments
 (0)