Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit e109b58

Browse files
author
Sergey Shvets
committed
MAGETWO-75790: Type mismatch in translation js dataprovider
unit test added
1 parent dde105b commit e109b58

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

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)