@@ -51,6 +51,11 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
51
51
*/
52
52
protected $ loggerMock ;
53
53
54
+ /**
55
+ * @var \Magento\Framework\App\State|\PHPUnit_Framework_MockObject_MockObject
56
+ */
57
+ protected $ appState ;
58
+
54
59
protected function setUp ()
55
60
{
56
61
$ this ->resolver = $ this ->getMock (
@@ -90,8 +95,8 @@ protected function setUp()
90
95
$ this ->loggerMock = $ this ->getMock (\Psr \Log \LoggerInterface::class);
91
96
$ this ->templateEngine ->expects ($ this ->any ())->method ('get ' )->willReturn ($ this ->templateEngine );
92
97
93
- $ appState = $ this ->getMock (\Magento \Framework \App \State::class, ['getAreaCode ' ], [], '' , false );
94
- $ appState ->expects ($ this ->any ())->method ('getAreaCode ' )->willReturn ('frontend ' );
98
+ $ this -> appState = $ this ->getMock (\Magento \Framework \App \State::class, ['getAreaCode ' , ' getMode ' ], [], '' , false );
99
+ $ this -> appState ->expects ($ this ->any ())->method ('getAreaCode ' )->willReturn ('frontend ' );
95
100
$ storeManagerMock = $ this ->getMock (StoreManager::class, [], [], '' , false );
96
101
$ storeMock = $ this ->getMock (Store::class, [], [], '' , false );
97
102
$ storeManagerMock ->expects ($ this ->any ())
@@ -112,7 +117,7 @@ protected function setUp()
112
117
'enginePool ' => $ this ->templateEngine ,
113
118
'resolver ' => $ this ->resolver ,
114
119
'validator ' => $ this ->validator ,
115
- 'appState ' => $ appState ,
120
+ 'appState ' => $ this -> appState ,
116
121
'logger ' => $ this ->loggerMock ,
117
122
'storeManager ' => $ storeManagerMock ,
118
123
'urlBuilder ' => $ urlBuilderMock ,
@@ -165,6 +170,30 @@ public function testFetchViewWithNoFileName()
165
170
$ this ->assertEquals ($ output , $ this ->block ->fetchView ($ template ));
166
171
}
167
172
173
+ public function testFetchViewWithNoFileNameDeveloperMode ()
174
+ {
175
+ $ template = false ;
176
+ $ templatePath = 'wrong_template_path.pthml ' ;
177
+ $ moduleName = 'Acme ' ;
178
+ $ blockName = 'acme_test_module_test_block ' ;
179
+ $ exception = "Invalid template file: ' {$ templatePath }' in module: ' {$ moduleName }' block's name: ' {$ blockName }' " ;
180
+ $ this ->block ->setTemplate ($ templatePath );
181
+ $ this ->block ->setData ('module_name ' , $ moduleName );
182
+ $ this ->block ->setNameInLayout ($ blockName );
183
+ $ this ->validator ->expects ($ this ->once ())
184
+ ->method ('isValid ' )
185
+ ->with ($ template )
186
+ ->willReturn (false );
187
+ $ this ->loggerMock ->expects ($ this ->never ())
188
+ ->method ('critical ' );
189
+ $ this ->appState ->expects ($ this ->once ())
190
+ ->method ('getMode ' )
191
+ ->willReturn (\Magento \Framework \App \State::MODE_DEVELOPER );
192
+
193
+ $ this ->setExpectedException ('\InvalidArgumentException ' , $ exception );
194
+ $ this ->block ->fetchView ($ template );
195
+ }
196
+
168
197
public function testSetTemplateContext ()
169
198
{
170
199
$ template = 'themedir/template.phtml ' ;
0 commit comments