Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
ThemeUninstallerTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class ThemeUninstallerTest extends \PHPUnit\Framework\TestCase
11 {
15  private $themePackageInfo;
16 
20  private $remove;
21 
25  private $themeProvider;
26 
30  private $themeUninstaller;
31 
35  private $output;
36 
37  protected function setUp()
38  {
39  $this->themePackageInfo = $this->createMock(\Magento\Theme\Model\Theme\ThemePackageInfo::class);
40  $this->remove = $this->createMock(\Magento\Framework\Composer\Remove::class);
41  $this->themeProvider = $this->createMock(\Magento\Theme\Model\Theme\ThemeProvider::class);
42  $this->themeUninstaller = new ThemeUninstaller($this->themePackageInfo, $this->remove, $this->themeProvider);
43  $this->output = $this->getMockForAbstractClass(
44  \Symfony\Component\Console\Output\OutputInterface::class,
45  [],
46  '',
47  false
48  );
49  }
50 
51  public function testUninstallRegistry()
52  {
53  $this->output->expects($this->atLeastOnce())->method('writeln');
54  $this->themePackageInfo->expects($this->never())->method($this->anything());
55  $this->remove->expects($this->never())->method($this->anything());
56  $theme = $this->createMock(\Magento\Theme\Model\Theme::class);
57  $theme->expects($this->exactly(3))->method('delete');
58  $this->themeProvider->expects($this->exactly(3))->method('getThemeByFullPath')->willReturn($theme);
59  $this->themeUninstaller->uninstallRegistry(
60  $this->output,
61  ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']
62  );
63  }
64 
65  public function testUninstallCode()
66  {
67  $this->output->expects($this->atLeastOnce())->method('writeln');
68  $this->themePackageInfo->expects($this->at(0))->method('getPackageName')->willReturn('packageA');
69  $this->themePackageInfo->expects($this->at(1))->method('getPackageName')->willReturn('packageB');
70  $this->themePackageInfo->expects($this->at(2))->method('getPackageName')->willReturn('packageC');
71  $this->remove->expects($this->once())
72  ->method('remove')
73  ->with(['packageA', 'packageB', 'packageC'])
74  ->willReturn('');
75  $this->themeProvider->expects($this->never())->method($this->anything());
76  $this->themeUninstaller->uninstallCode(
77  $this->output,
78  ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']
79  );
80  }
81 }
output($string, $level=INFO, $label='')
$theme