当前位置: 首页>>代码示例>>PHP>>正文


PHP TransportBuilder::setTemplateModel方法代码示例

本文整理汇总了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());
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:29,代码来源:TransportBuilderTest.php


注:本文中的Magento\Framework\Mail\Template\TransportBuilder::setTemplateModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。