@@ -111,6 +111,16 @@ class FilterTest extends \PHPUnit\Framework\TestCase
111
111
*/
112
112
private $ pubDirectoryRead ;
113
113
114
+ /**
115
+ * @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filter\VariableResolver\StrategyResolver
116
+ */
117
+ private $ variableResolver ;
118
+
119
+ /**
120
+ * @var array
121
+ */
122
+ private $ directiveProcessors ;
123
+
114
124
protected function setUp ()
115
125
{
116
126
$ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
@@ -178,6 +188,30 @@ protected function setUp()
178
188
$ this ->pubDirectoryRead = $ this ->getMockBuilder (\Magento \Framework \Filesystem \Directory \Read::class)
179
189
->disableOriginalConstructor ()
180
190
->getMock ();
191
+ $ this ->variableResolver =
192
+ $ this ->getMockBuilder (\Magento \Framework \Filter \VariableResolver \StrategyResolver::class)
193
+ ->disableOriginalConstructor ()
194
+ ->getMock ();
195
+
196
+ $ this ->directiveProcessors = [
197
+ 'depend ' =>
198
+ $ this ->getMockBuilder (\Magento \Framework \Filter \DirectiveProcessor \DependDirective::class)
199
+ ->disableOriginalConstructor ()
200
+ ->getMock (),
201
+ 'if ' =>
202
+ $ this ->getMockBuilder (\Magento \Framework \Filter \DirectiveProcessor \IfDirective::class)
203
+ ->disableOriginalConstructor ()
204
+ ->getMock (),
205
+ 'template ' =>
206
+ $ this ->getMockBuilder (\Magento \Framework \Filter \DirectiveProcessor \TemplateDirective::class)
207
+ ->disableOriginalConstructor ()
208
+ ->getMock (),
209
+ 'legacy ' =>
210
+ $ this ->getMockBuilder (\Magento \Framework \Filter \DirectiveProcessor \LegacyDirective::class)
211
+ ->disableOriginalConstructor ()
212
+ ->getMock (),
213
+ ];
214
+
181
215
}
182
216
183
217
/**
@@ -204,6 +238,8 @@ protected function getModel($mockedMethods = null)
204
238
$ this ->configVariables ,
205
239
[],
206
240
$ this ->cssInliner ,
241
+ $ this ->directiveProcessors ,
242
+ $ this ->variableResolver ,
207
243
$ this ->cssProcessor ,
208
244
$ this ->pubDirectory
209
245
]
@@ -351,43 +387,6 @@ public function testApplyInlineCssThrowsExceptionWhenDesignParamsNotSet()
351
387
$ filter ->applyInlineCss ('test ' );
352
388
}
353
389
354
- /**
355
- * Ensure that after filter callbacks are reset after exception is thrown during filtering
356
- */
357
- public function testAfterFilterCallbackGetsResetWhenExceptionTriggered ()
358
- {
359
- $ value = '{{var random_var}} ' ;
360
- $ exception = new \Exception ('Test exception ' );
361
- $ exceptionResult = sprintf (__ ('Error filtering template: %s ' ), $ exception ->getMessage ());
362
-
363
- $ this ->appState ->expects ($ this ->once ())
364
- ->method ('getMode ' )
365
- ->will ($ this ->returnValue (\Magento \Framework \App \State::MODE_DEVELOPER ));
366
- $ this ->logger ->expects ($ this ->once ())
367
- ->method ('critical ' )
368
- ->with ($ exception );
369
-
370
- $ filter = $ this ->getModel (['varDirective ' , 'resetAfterFilterCallbacks ' ]);
371
- $ filter ->expects ($ this ->once ())
372
- ->method ('varDirective ' )
373
- ->will ($ this ->throwException ($ exception ));
374
-
375
- // Callbacks must be reset after exception is thrown
376
- $ filter ->expects ($ this ->once ())
377
- ->method ('resetAfterFilterCallbacks ' );
378
-
379
- // Build arbitrary object to pass into the addAfterFilterCallback method
380
- $ callbackObject = $ this ->getMockBuilder ('stdObject ' )
381
- ->setMethods (['afterFilterCallbackMethod ' ])
382
- ->getMock ();
383
- // Callback should never run due to exception happening during filtering
384
- $ callbackObject ->expects ($ this ->never ())
385
- ->method ('afterFilterCallbackMethod ' );
386
- $ filter ->addAfterFilterCallback ([$ callbackObject , 'afterFilterCallbackMethod ' ]);
387
-
388
- $ this ->assertEquals ($ exceptionResult , $ filter ->filter ($ value ));
389
- }
390
-
391
390
public function testConfigDirectiveAvailable ()
392
391
{
393
392
$ path = "web/unsecure/base_url " ;
0 commit comments