Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-theme/Test/Unit/Model/Theme/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-theme/Test/Unit/Model/Theme/ThemeUninstallerTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Theme\Test\Unit\Model\Theme;

use Magento\Framework\Composer\Remove;
use Magento\Theme\Model\Theme;
use Magento\Theme\Model\Theme\ThemePackageInfo;
use Magento\Theme\Model\Theme\ThemeProvider;
use Magento\Theme\Model\Theme\ThemeUninstaller;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Output\OutputInterface;

class ThemeUninstallerTest extends TestCase
{
    /**
     * @var ThemePackageInfo|MockObject
     */
    private $themePackageInfo;

    /**
     * @var Remove|MockObject
     */
    private $remove;

    /**
     * @var ThemeProvider|MockObject
     */
    private $themeProvider;

    /**
     * @var ThemeUninstaller
     */
    private $themeUninstaller;

    /**
     * @var OutputInterface|MockObject
     */
    private $output;

    /**
     * @inheritdoc
     */
    protected function setUp(): void
    {
        $this->themePackageInfo = $this->createMock(ThemePackageInfo::class);
        $this->remove = $this->createMock(Remove::class);
        $this->themeProvider = $this->createMock(ThemeProvider::class);
        $this->themeUninstaller = new ThemeUninstaller($this->themePackageInfo, $this->remove, $this->themeProvider);
        $this->output = $this->getMockForAbstractClass(
            OutputInterface::class,
            [],
            '',
            false
        );
    }

    /**
     * @return void
     */
    public function testUninstallRegistry(): void
    {
        $this->output->expects($this->atLeastOnce())->method('writeln');
        $this->themePackageInfo->expects($this->never())->method($this->anything());
        $this->remove->expects($this->never())->method($this->anything());
        $theme = $this->createMock(Theme::class);
        $theme->expects($this->exactly(3))->method('delete');
        $this->themeProvider->expects($this->exactly(3))->method('getThemeByFullPath')->willReturn($theme);
        $this->themeUninstaller->uninstallRegistry(
            $this->output,
            ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']
        );
    }

    /**
     * @return void
     */
    public function testUninstallCode(): void
    {
        $this->output->expects($this->atLeastOnce())->method('writeln');
        $this->themePackageInfo
            ->method('getPackageName')
            ->willReturnOnConsecutiveCalls('packageA', 'packageB', 'packageC');
        $this->remove->expects($this->once())
            ->method('remove')
            ->with(['packageA', 'packageB', 'packageC'])
            ->willReturn('');
        $this->themeProvider->expects($this->never())->method($this->anything());
        $this->themeUninstaller->uninstallCode(
            $this->output,
            ['frontend/Magento/ThemeA', 'frontend/Magento/ThemeB', 'frontend/Magento/ThemeC']
        );
    }
}

Spamworldpro Mini