@@ -13,22 +13,27 @@ class PreviewTest extends \PHPUnit_Framework_TestCase
1313 protected $ objectManager ;
1414
1515 /**
16- * @var \Magento\Newsletter\Model\Template
16+ * @var \Magento\Newsletter\Model\Template|\PHPUnit_Framework_MockObject_MockObject
1717 */
1818 protected $ template ;
1919
2020 /**
21- * @var \Magento\Framework\App\RequestInterface
21+ * @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
2222 */
2323 protected $ request ;
2424
2525 /**
26- * @var \Magento\Newsletter\Model\Queue
26+ * @var \Magento\Newsletter\Model\Subscriber|\PHPUnit_Framework_MockObject_MockObject
27+ */
28+ protected $ subscriber ;
29+
30+ /**
31+ * @var \Magento\Newsletter\Model\Queue|\PHPUnit_Framework_MockObject_MockObject
2732 */
2833 protected $ queue ;
2934
3035 /**
31- * @var \Magento\Store\Model\StoreManagerInterface
36+ * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
3237 */
3338 protected $ storeManager ;
3439
@@ -39,30 +44,44 @@ class PreviewTest extends \PHPUnit_Framework_TestCase
3944
4045 public function setUp ()
4146 {
42- $ templateFactory = $ this ->getMock ('Magento\Newsletter\Model\TemplateFactory ' , ['create ' ], [], '' , false );
43- $ this ->template = $ this ->getMock ('Magento\Newsletter\Model\Template ' , [], [], '' , false );
44- $ templateFactory ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->template ));
45- $ queueFactory = $ this ->getMock ('Magento\Newsletter\Model\QueueFactory ' , ['create ' ], [], '' , false );
46- $ this ->queue = $ this ->getMock ('Magento\Newsletter\Model\Queue ' , ['load ' ], [], '' , false );
47- $ queueFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ this ->queue ));
48-
47+ $ context = $ this ->getMock ('Magento\Backend\Block\Template\Context ' , [], [], '' , false );
48+ $ eventManager = $ this ->getMock ('Magento\Framework\Event\ManagerInterface ' , [], [], '' , false );
49+ $ context ->expects ($ this ->once ())->method ('getEventManager ' )->will ($ this ->returnValue ($ eventManager ));
50+ $ scopeConfig = $ this ->getMock ('Magento\Framework\App\Config\ScopeConfigInterface ' , [], [], '' , false );
51+ $ context ->expects ($ this ->once ())->method ('getScopeConfig ' )->will ($ this ->returnValue ($ scopeConfig ));
4952 $ this ->request = $ this ->getMock ('Magento\Framework\App\Request\Http ' , [], [], '' , false );
53+ $ context ->expects ($ this ->once ())->method ('getRequest ' )->will ($ this ->returnValue ($ this ->request ));
5054 $ this ->storeManager = $ this ->getMock (
5155 'Magento\Store\Model\StoreManager ' ,
5256 ['getStores ' , 'getDefaultStoreView ' ],
5357 [],
5458 '' ,
5559 false
5660 );
61+ $ context ->expects ($ this ->once ())->method ('getStoreManager ' )->will ($ this ->returnValue ($ this ->storeManager ));
62+ $ appState = $ this ->getMock ('Magento\Framework\App\State ' , [], [], '' , false );
63+ $ context ->expects ($ this ->once ())->method ('getAppState ' )->will ($ this ->returnValue ($ appState ));
64+
65+ $ templateFactory = $ this ->getMock ('Magento\Newsletter\Model\TemplateFactory ' , ['create ' ], [], '' , false );
66+ $ this ->template = $ this ->getMock ('Magento\Newsletter\Model\Template ' , [], [], '' , false );
67+ $ templateFactory ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->template ));
68+
69+ $ subscriberFactory = $ this ->getMock ('Magento\Newsletter\Model\SubscriberFactory ' , ['create ' ], [], '' , false );
70+ $ this ->subscriber = $ this ->getMock ('Magento\Newsletter\Model\Subscriber ' , [], [], '' , false );
71+ $ subscriberFactory ->expects ($ this ->once ())->method ('create ' )->will ($ this ->returnValue ($ this ->subscriber ));
72+
73+ $ queueFactory = $ this ->getMock ('Magento\Newsletter\Model\QueueFactory ' , ['create ' ], [], '' , false );
74+ $ this ->queue = $ this ->getMock ('Magento\Newsletter\Model\Queue ' , ['load ' ], [], '' , false );
75+ $ queueFactory ->expects ($ this ->any ())->method ('create ' )->will ($ this ->returnValue ($ this ->queue ));
5776
5877 $ this ->objectManager = new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this );
5978 $ this ->preview = $ this ->objectManager ->getObject (
6079 'Magento\Newsletter\Block\Adminhtml\Queue\Preview ' ,
6180 [
81+ 'context ' => $ context ,
6282 'templateFactory ' => $ templateFactory ,
83+ 'subscriberFactory ' => $ subscriberFactory ,
6384 'queueFactory ' => $ queueFactory ,
64- 'request ' => $ this ->request ,
65- 'storeManager ' => $ this ->storeManager
6685 ]
6786 );
6887 }
0 commit comments