コード例 #1
0
ファイル: EditTest.php プロジェクト: IlyaGluschenko/test001
 public function testGetDefaultTemplatesAsOptionsArray()
 {
     $directoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\Read', [], [], '', false);
     $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($directoryMock));
     $this->_emailConfigMock->expects($this->once())->method('getAvailableTemplates')->will($this->returnValue([['value' => 'template_b2', 'label' => 'Template B2', 'group' => 'Fixture_ModuleB'], ['value' => 'template_a', 'label' => 'Template A', 'group' => 'Fixture_ModuleA'], ['value' => 'template_b1', 'label' => 'Template B1', 'group' => 'Fixture_ModuleB']]));
     $this->assertEmpty($this->_block->getData('template_options'));
     $this->_block->setTemplate('my/custom\\template.phtml');
     $this->_block->toHtml();
     $expectedResult = ['' => [['value' => '', 'label' => '', 'group' => '']], 'Fixture_ModuleA' => [['value' => 'template_a', 'label' => 'Template A', 'group' => 'Fixture_ModuleA']], 'Fixture_ModuleB' => [['value' => 'template_b1', 'label' => 'Template B1', 'group' => 'Fixture_ModuleB'], ['value' => 'template_b2', 'label' => 'Template B2', 'group' => 'Fixture_ModuleB']]];
     $this->assertEquals($expectedResult, $this->_block->getData('template_options'), 'Options are expected to be sorted by modules and by labels of email templates within modules');
 }
コード例 #2
0
 public function testGetDefaultTemplatesAsOptionsArray()
 {
     $dirValueMap = array(array(\Magento\Framework\App\Filesystem::ROOT_DIR, 'var/www/magento\\rootdir/'), array(\Magento\Framework\App\Filesystem::APP_DIR, 'var/www/magento\\rootdir\\app/'), array(\Magento\Framework\App\Filesystem::THEMES_DIR, 'var\\www/magento\\rootdir\\app/themes/'));
     $this->directoryMock = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\Read', array(), array(), '', false);
     $this->directoryMock->expects($this->any())->method('isFile')->will($this->returnValue(false));
     $this->directoryMock->expects($this->any())->method('getRelativePath')->will($this->returnValue(''));
     $this->filesystemMock->expects($this->any())->method('getDirectoryRead')->will($this->returnValue($this->directoryMock));
     $this->filesystemMock->expects($this->any())->method('getPath')->will($this->returnValueMap($dirValueMap));
     $this->_emailConfigMock->expects($this->once())->method('getAvailableTemplates')->will($this->returnValue(array('template_b2', 'template_a', 'template_b1')));
     $this->_emailConfigMock->expects($this->exactly(3))->method('getTemplateModule')->will($this->onConsecutiveCalls('Fixture_ModuleB', 'Fixture_ModuleA', 'Fixture_ModuleB'));
     $this->_emailConfigMock->expects($this->exactly(3))->method('getTemplateLabel')->will($this->onConsecutiveCalls('Template B2', 'Template A', 'Template B1'));
     $this->assertEmpty($this->_block->getData('template_options'));
     $this->_block->setTemplate('my/custom\\template.phtml');
     $this->_block->toHtml();
     $expectedResult = array('' => array(array('value' => '', 'label' => '', 'group' => '')), 'Fixture_ModuleA' => array(array('value' => 'template_a', 'label' => 'Template A', 'group' => 'Fixture_ModuleA')), 'Fixture_ModuleB' => array(array('value' => 'template_b1', 'label' => 'Template B1', 'group' => 'Fixture_ModuleB'), array('value' => 'template_b2', 'label' => 'Template B2', 'group' => 'Fixture_ModuleB')));
     $this->assertEquals($expectedResult, $this->_block->getData('template_options'), 'Options are expected to be sorted by modules and by labels of email templates within modules');
 }