Skip to content

Commit

Permalink
MAGETWO-63881: Accept public PRs #8327, #8336, #8307
Browse files Browse the repository at this point in the history
- add unit test for AbstractTemplate Exception
  • Loading branch information
vrann committed Feb 2, 2017
1 parent c289d0c commit e55eeed
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,67 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
$this->assertEquals($expectedResult, $model->getProcessedTemplate($variables));
}

/**
* @expectedException \LogicException
*/
public function testGetProcessedTemplateException() {
$filterTemplate = $this->getMockBuilder(\Magento\Email\Model\Template\Filter::class)
->setMethods([
'setUseSessionInUrl',
'setPlainTemplateMode',
'setIsChildTemplate',
'setDesignParams',
'setVariables',
'setStoreId',
'filter',
'getStoreId',
'getInlineCssFiles',
])
->disableOriginalConstructor()
->getMock();
$filterTemplate->expects($this->once())
->method('setUseSessionInUrl')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setPlainTemplateMode')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setIsChildTemplate')
->will($this->returnSelf());
$filterTemplate->expects($this->once())
->method('setDesignParams')
->will($this->returnSelf());
$filterTemplate->expects($this->any())
->method('setStoreId')
->will($this->returnSelf());
$filterTemplate->expects($this->any())
->method('getStoreId')
->will($this->returnValue(1));

$model = $this->getModelMock([
'getDesignParams',
'applyDesignConfig',
'getTemplateText',
'isPlain',
]);

$designParams = [
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
'theme' => 'themeId',
'locale' => 'localeId',
];
$model->expects($this->any())
->method('getDesignParams')
->will($this->returnValue($designParams));
$model->setTemplateFilter($filterTemplate);
$model->setTemplateType(\Magento\Framework\App\TemplateTypesInterface::TYPE_TEXT);

$filterTemplate->expects($this->once())
->method('filter')
->will($this->throwException(new \Exception));
$model->getProcessedTemplate([]);
}

/**
* @return array
*/
Expand Down

0 comments on commit e55eeed

Please sign in to comment.