|
3 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
4 | 4 | * See COPYING.txt for license details.
|
5 | 5 | */
|
| 6 | + |
6 | 7 | namespace Magento\Translation\Test\Unit\Model\Js;
|
7 | 8 |
|
8 | 9 | use Magento\Framework\App\State;
|
@@ -148,4 +149,39 @@ public function testGetData()
|
148 | 149 |
|
149 | 150 | $this->assertEquals($expectedResult, $this->model->getData($themePath));
|
150 | 151 | }
|
| 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 | + } |
151 | 187 | }
|
0 commit comments