Skip to content

Commit a189658

Browse files
author
Oleh Posyniak
committed
MAGETWO-44455: Email Templates - When new email template created, clicking Preview button, display empty page.
1 parent c8d0759 commit a189658

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,38 @@ public function testToHtml($requestParamMap)
4646
'revertDesign'
4747
])
4848
->disableOriginalConstructor()
49-
->getMock()
50-
;
49+
->getMock();
5150
$template->expects($this->once())
5251
->method('getProcessedTemplate')
5352
->with($this->equalTo([]))
54-
->will($this->returnValue(self::MALICIOUS_TEXT));
55-
$designConfigData = [
56-
'area' => \Magento\Framework\App\Area::AREA_FRONTEND,
57-
'store' => $storeId
58-
];
53+
->willReturn(self::MALICIOUS_TEXT);
54+
$designConfigData = [];
5955
$template->expects($this->atLeastOnce())
6056
->method('getDesignConfig')
61-
->will($this->returnValue(new \Magento\Framework\DataObject(
57+
->willReturn(new \Magento\Framework\DataObject(
6258
$designConfigData
63-
)));
59+
));
6460
$emailFactory = $this->getMock('Magento\Email\Model\TemplateFactory', ['create'], [], '', false);
6561
$emailFactory->expects($this->once())
6662
->method('create')
67-
->with($this->equalTo(['data' => $designConfigData]))
68-
->will($this->returnValue($template));
63+
->with([])
64+
->willReturn($template);
6965

7066
$request = $this->getMock('Magento\Framework\App\RequestInterface');
71-
$request->expects($this->any())->method('getParam')->will($this->returnValueMap($requestParamMap));
67+
$request->expects($this->any())->method('getParam')->willReturnMap($requestParamMap);
7268
$eventManage = $this->getMock('Magento\Framework\Event\ManagerInterface');
7369
$scopeConfig = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface');
7470
$design = $this->getMock('Magento\Framework\View\DesignInterface');
7571
$store = $this->getMock('Magento\Store\Model\Store', ['getId', '__wakeup'], [], '', false);
76-
$store->expects($this->any())->method('getId')->will($this->returnValue($storeId));
72+
$store->expects($this->any())->method('getId')->willReturn($storeId);
7773
$storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManagerInterface')
7874
->disableOriginalConstructor()
7975
->getMock();
8076
$storeManager->expects($this->atLeastOnce())
8177
->method('getDefaultStoreView')
82-
->will($this->returnValue($store));
83-
$storeManager->expects($this->any())->method('getDefaultStoreView')->will($this->returnValue(null));
84-
$storeManager->expects($this->any())->method('getStores')->will($this->returnValue([$store]));
78+
->willReturn($store);
79+
$storeManager->expects($this->any())->method('getDefaultStoreView')->willReturn(null);
80+
$storeManager->expects($this->any())->method('getStores')->willReturn([$store]);
8581
$appState = $this->getMockBuilder('Magento\Framework\App\State')
8682
->setConstructorArgs([
8783
$scopeConfig
@@ -94,12 +90,12 @@ public function testToHtml($requestParamMap)
9490
['getRequest', 'getEventManager', 'getScopeConfig', 'getDesignPackage', 'getStoreManager', 'getAppState'],
9591
[], '', false
9692
);
97-
$context->expects($this->any())->method('getRequest')->will($this->returnValue($request));
98-
$context->expects($this->any())->method('getEventManager')->will($this->returnValue($eventManage));
99-
$context->expects($this->any())->method('getScopeConfig')->will($this->returnValue($scopeConfig));
100-
$context->expects($this->any())->method('getDesignPackage')->will($this->returnValue($design));
101-
$context->expects($this->any())->method('getStoreManager')->will($this->returnValue($storeManager));
102-
$context->expects($this->once())->method('getAppState')->will($this->returnValue($appState));
93+
$context->expects($this->any())->method('getRequest')->willReturn($request);
94+
$context->expects($this->any())->method('getEventManager')->willReturn($eventManage);
95+
$context->expects($this->any())->method('getScopeConfig')->willReturn($scopeConfig);
96+
$context->expects($this->any())->method('getDesignPackage')->willReturn($design);
97+
$context->expects($this->any())->method('getStoreManager')->willReturn($storeManager);
98+
$context->expects($this->once())->method('getAppState')->willReturn($appState);
10399

104100
$maliciousCode = $this->getMock(
105101
'Magento\Framework\Filter\Input\MaliciousCode',
@@ -108,8 +104,10 @@ public function testToHtml($requestParamMap)
108104
'',
109105
false
110106
);
111-
$maliciousCode->expects($this->once())->method('filter')->with($this->equalTo($requestParamMap[1][2]))
112-
->will($this->returnValue(self::MALICIOUS_TEXT));
107+
$maliciousCode->expects($this->once())
108+
->method('filter')
109+
->with($this->equalTo($requestParamMap[1][2]))
110+
->willReturn(self::MALICIOUS_TEXT);
113111

114112
$preview = $this->objectManagerHelper->getObject(
115113
'Magento\Email\Block\Adminhtml\Template\Preview',

0 commit comments

Comments
 (0)