public function testGetThemeTemplates() { $themeDirectory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->setMethods(['search'])->getMockForAbstractClass(); $templates = (require __DIR__ . '/Config/_files/email_templates_merged.php'); $templateId = 'template_one'; $template = $templates[$templateId]; $area = $template['area']; $searchThemePath = '*/*'; $foundThemePath = 'Vendor/custom_theme'; $module = $template['module']; $filename = $template['file']; $themeDirectory->expects($this->once())->method('search')->with("{$area}/{$searchThemePath}/{$module}/email/{$filename}")->will($this->returnValue(["{$area}/{$foundThemePath}/{$module}/email/{$filename}"])); $this->fileSystem->expects($this->once())->method('getDirectoryRead')->will($this->returnValue($themeDirectory)); $this->_model = $this->getMockBuilder('\\Magento\\Email\\Model\\Template\\Config')->setConstructorArgs([$this->_dataStorage, $this->_moduleReader, $this->fileSystem, $this->viewFileSystem])->setMethods(null)->getMock(); foreach ($this->_model->getThemeTemplates($templateId) as $templateOptions) { $this->assertEquals(sprintf('%s (%s)', $template['label'], $foundThemePath), $templateOptions['label']); $this->assertEquals(sprintf('%s/%s', $templateId, $foundThemePath), $templateOptions['value']); $this->assertEquals($template['module'], $templateOptions['group']); } }
public function testGetThemeTemplates() { $templates = (require __DIR__ . '/Config/_files/email_templates_merged.php'); $templateId = 'template_one'; $template = $templates[$templateId]; $foundThemePath = 'Vendor/custom_theme'; $theme = $this->getMock('\\Magento\\Framework\\View\\Design\\Theme\\ThemePackage', [], [], '', false); $theme->expects($this->any())->method('getArea')->willReturn('frontend'); $theme->expects($this->any())->method('getVendor')->willReturn('Vendor'); $theme->expects($this->any())->method('getName')->willReturn('custom_theme'); $theme->expects($this->any())->method('getPath')->willReturn('/theme/path'); $this->themePackages->expects($this->once())->method('getThemes')->willReturn([$theme]); $dir = $this->getMockForAbstractClass('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface'); $this->readDirFactory->expects($this->once())->method('create')->with('/theme/path')->willReturn($dir); $dir->expects($this->once())->method('isExist')->willReturn(true); $actualTemplates = $this->model->getThemeTemplates($templateId); $this->assertNotEmpty($actualTemplates); foreach ($actualTemplates as $templateOptions) { $this->assertEquals(sprintf('%s (%s)', $template['label'], $foundThemePath), $templateOptions['label']); $this->assertEquals(sprintf('%s/%s', $templateId, $foundThemePath), $templateOptions['value']); $this->assertEquals($template['module'], $templateOptions['group']); } }