protected function _getTemplates() { if (!$this->_magentoTemplates) { $this->_magentoTemplates = $this->_magentoTemplatesSource->getAvailableTemplates(); } return $this->_magentoTemplates; }
public function testToOptionArray() { $collection = $this->getMock('Magento\\Email\\Model\\Resource\\Template\\Collection', [], [], '', false); $collection->expects($this->once())->method('toOptionArray')->will($this->returnValue([['value' => 'template_one', 'label' => 'Template One'], ['value' => 'template_two', 'label' => 'Template Two']])); $this->_coreRegistry->expects($this->once())->method('registry')->with('config_system_email_template')->will($this->returnValue($collection)); $this->_emailConfig->expects($this->once())->method('getTemplateLabel')->with('template_new')->will($this->returnValue('Template New')); $expectedResult = [['value' => 'template_new', 'label' => 'Template New (Default)'], ['value' => 'template_one', 'label' => 'Template One'], ['value' => 'template_two', 'label' => 'Template Two']]; $this->_model->setPath('template/new'); $this->assertEquals($expectedResult, $this->_model->toOptionArray()); }
/** * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory * @param \Magento\Email\Model\Template\Config $emailConfig * @param array $data */ public function __construct(\Magento\Framework\Registry $coreRegistry, \Magento\Email\Model\ResourceModel\Template\CollectionFactory $templatesFactory, \Magento\Email\Model\Template\Config $emailConfig, array $data = []) { parent::__construct($coreRegistry, $templatesFactory, $emailConfig, $data); $this->_coreRegistry = $coreRegistry; $this->_emailConfig = $emailConfig; }