Skip to content

Commit 549a491

Browse files
committed
Fix unit test after merge.
1 parent a8c0ab9 commit 549a491

File tree

1 file changed

+36
-37
lines changed

1 file changed

+36
-37
lines changed

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ class FilterTest extends \PHPUnit\Framework\TestCase
111111
*/
112112
private $pubDirectoryRead;
113113

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+
114124
protected function setUp()
115125
{
116126
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -178,6 +188,30 @@ protected function setUp()
178188
$this->pubDirectoryRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Read::class)
179189
->disableOriginalConstructor()
180190
->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+
181215
}
182216

183217
/**
@@ -204,6 +238,8 @@ protected function getModel($mockedMethods = null)
204238
$this->configVariables,
205239
[],
206240
$this->cssInliner,
241+
$this->directiveProcessors,
242+
$this->variableResolver,
207243
$this->cssProcessor,
208244
$this->pubDirectory
209245
]
@@ -351,43 +387,6 @@ public function testApplyInlineCssThrowsExceptionWhenDesignParamsNotSet()
351387
$filter->applyInlineCss('test');
352388
}
353389

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-
391390
public function testConfigDirectiveAvailable()
392391
{
393392
$path = "web/unsecure/base_url";

0 commit comments

Comments
 (0)