本文整理汇总了PHP中Magento\Framework\Mail\Template\TransportBuilder::setTemplateModel方法的典型用法代码示例。如果您正苦于以下问题:PHP TransportBuilder::setTemplateModel方法的具体用法?PHP TransportBuilder::setTemplateModel怎么用?PHP TransportBuilder::setTemplateModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Mail\Template\TransportBuilder
的用法示例。
在下文中一共展示了TransportBuilder::setTemplateModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetTransport
/**
* @dataProvider getTransportDataProvider
* @param int $templateType
* @param string $messageType
* @param string $bodyText
* @param string $templateNamespace
* @return void
*/
public function testGetTransport($templateType, $messageType, $bodyText, $templateNamespace)
{
$this->builder->setTemplateModel($templateNamespace);
$vars = ['reason' => 'Reason', 'customer' => 'Customer'];
$options = ['area' => 'frontend', 'store' => 1];
$template = $this->getMock('\\Magento\\Framework\\Mail\\TemplateInterface');
$template->expects($this->once())->method('setVars')->with($this->equalTo($vars))->willReturnSelf();
$template->expects($this->once())->method('setOptions')->with($this->equalTo($options))->willReturnSelf();
$template->expects($this->once())->method('getSubject')->willReturn('Email Subject');
$template->expects($this->once())->method('getType')->willReturn($templateType);
$template->expects($this->once())->method('processTemplate')->willReturn($bodyText);
$this->templateFactoryMock->expects($this->once())->method('get')->with($this->equalTo('identifier'), $this->equalTo($templateNamespace))->willReturn($template);
$this->messageMock->expects($this->once())->method('setSubject')->with($this->equalTo('Email Subject'))->willReturnSelf();
$this->messageMock->expects($this->once())->method('setMessageType')->with($this->equalTo($messageType))->willReturnSelf();
$this->messageMock->expects($this->once())->method('setBody')->with($this->equalTo($bodyText))->willReturnSelf();
$transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface');
$this->mailTransportFactoryMock->expects($this->at(0))->method('create')->with($this->equalTo(['message' => $this->messageMock]))->willReturn($transport);
$this->objectManagerMock->expects($this->at(0))->method('create')->with($this->equalTo('Magento\\Framework\\Mail\\Message'))->willReturn($transport);
$this->builder->setTemplateIdentifier('identifier')->setTemplateVars($vars)->setTemplateOptions($options);
$this->assertInstanceOf('Magento\\Framework\\Mail\\TransportInterface', $this->builder->getTransport());
}