Esempio n. 1
0
 public function testToHtmlWithSubscriber()
 {
     $this->request->expects($this->any())->method('getParam')->willReturnMap([['id', null, 2], ['store', null, 1], ['subscriber', null, 3]]);
     $subscriber = $this->getMock('Magento\\Newsletter\\Model\\Subscriber', [], [], '', false);
     $subscriber->expects($this->atLeastOnce())->method('load')->with(3)->willReturnSelf();
     $this->subscriberFactory->expects($this->atLeastOnce())->method('create')->willReturn($subscriber);
     $this->template->expects($this->atLeastOnce())->method('emulateDesign')->with(1);
     $this->template->expects($this->atLeastOnce())->method('revertDesign');
     $this->appState->expects($this->atLeastOnce())->method('emulateAreaCode')->with(\Magento\Newsletter\Model\Template::DEFAULT_DESIGN_AREA, [$this->template, 'getProcessedTemplate'], [['subscriber' => $subscriber]])->willReturn('Processed Template');
     $this->assertEquals('Processed Template', $this->preview->toHtml());
 }
 public function testToHtmlWithId()
 {
     $this->request->expects($this->any())->method('getParam')->will($this->returnValueMap([['id', null, 1], ['store_id', null, 0]]));
     $this->queue->expects($this->once())->method('load')->will($this->returnSelf());
     $this->template->expects($this->any())->method('isPlain')->will($this->returnValue(true));
     /** @var \Magento\Store\Model\Store $store */
     $this->storeManager->expects($this->once())->method('getDefaultStoreView')->will($this->returnValue(null));
     $store = $this->getMock('Magento\\Store\\Model\\Store', ['getId'], [], '', false);
     $this->storeManager->expects($this->once())->method('getStores')->will($this->returnValue([0 => $store]));
     $result = $this->preview->toHtml();
     $this->assertEquals('<pre></pre>', $result);
 }