Пример #1
0
 protected function setUp()
 {
     $this->_mail = $this->getMock('Zend_Mail', array('send', 'addTo', 'addBcc', 'setReturnPath', 'setReplyTo'), array('utf-8'));
     $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
     $this->_model = $this->getMockBuilder('Magento\\Email\\Model\\Template')->setMethods(array('_getMail'))->setConstructorArgs(array($objectManager->get('Magento\\Framework\\Model\\Context'), $objectManager->get('Magento\\Framework\\View\\DesignInterface'), $objectManager->get('Magento\\Framework\\Registry'), $objectManager->get('Magento\\Core\\Model\\App\\Emulation'), $objectManager->get('Magento\\Store\\Model\\StoreManager'), $objectManager->create('Magento\\Framework\\App\\Filesystem'), $objectManager->create('Magento\\Framework\\View\\Asset\\Repository'), $objectManager->create('Magento\\Framework\\View\\FileSystem'), $objectManager->create('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), $objectManager->get('Magento\\Email\\Model\\Template\\FilterFactory'), $objectManager->get('Magento\\Email\\Model\\Template\\Config')))->getMock();
     $objectManager->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
     $this->_model->expects($this->any())->method('_getMail')->will($this->returnCallback(array($this, 'getMail')));
     $this->_model->setSenderName('sender')->setSenderEmail('*****@*****.**')->setTemplateSubject('Subject');
 }
Пример #2
0
 /**
  * @covers \Magento\Email\Block\Adminhtml\Template\Edit\Form::getVariables
  */
 public function testGetVariables()
 {
     $this->variablesMock->expects($this->once())->method('toOptionArray')->willReturn(['var1', 'var2', 'var3']);
     $this->variableFactoryMock->expects($this->once())->method('create')->willReturn($this->variableMock);
     $this->variableMock->expects($this->once())->method('getVariablesOptionArray')->willReturn(['custom var 1', 'custom var 2']);
     $this->registryMock->expects($this->once())->method('registry')->willReturn($this->templateMock);
     $this->templateMock->expects($this->once())->method('getId')->willReturn(1);
     $this->templateMock->expects($this->once())->method('getVariablesOptionArray')->willReturn(['template var 1', 'template var 2']);
     $this->assertEquals([['var1', 'var2', 'var3'], ['custom var 1', 'custom var 2'], ['template var 1', 'template var 2']], $this->form->getVariables());
 }
Пример #3
0
 protected function mockModel($filesystem = null)
 {
     if (!$filesystem) {
         $filesystem = $this->objectManager->create('Magento\\Framework\\Filesystem');
     }
     $this->mail = $this->getMock('Zend_Mail', ['send', 'addTo', 'addBcc', 'setReturnPath', 'setReplyTo'], ['utf-8']);
     $this->model = $this->getMockBuilder('Magento\\Email\\Model\\Template')->setMethods(['_getMail'])->setConstructorArgs([$this->objectManager->get('Magento\\Framework\\Model\\Context'), $this->objectManager->get('Magento\\Framework\\View\\DesignInterface'), $this->objectManager->get('Magento\\Framework\\Registry'), $this->objectManager->get('Magento\\Store\\Model\\App\\Emulation'), $this->objectManager->get('Magento\\Store\\Model\\StoreManager'), $this->objectManager->create('Magento\\Framework\\View\\Asset\\Repository'), $filesystem, $this->objectManager->create('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), $this->objectManager->get('Magento\\Email\\Model\\Template\\Config'), $this->objectManager->get('Magento\\Email\\Model\\TemplateFactory'), $this->objectManager->get('Magento\\Framework\\Filter\\FilterManager'), $this->objectManager->get('Magento\\Framework\\UrlInterface'), $this->objectManager->get('Magento\\Email\\Model\\Template\\FilterFactory')])->getMock();
     $this->objectManager->get('Magento\\Framework\\App\\State')->setAreaCode('frontend');
     $this->model->expects($this->any())->method('_getMail')->will($this->returnCallback([$this, 'getMail']));
     $this->model->setSenderName('sender')->setSenderEmail('*****@*****.**')->setTemplateSubject('Subject');
 }