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/amasty/base/Test/Unit/Utils/Http/Response/Entity/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/amasty/base/Test/Unit/Utils/Http/Response/Entity/ConfigPoolTest.php
<?php

declare(strict_types=1);

/**
 * @author Amasty Team
 * @copyright Copyright (c) Amasty (https://www.amasty.com)
 * @package Magento 2 Base Package
 */

namespace Amasty\Base\Test\Unit\Utils\Http\Response\Entity;

use Amasty\Base\Utils\Http\Response\Entity\Config;
use Amasty\Base\Utils\Http\Response\Entity\ConfigPool;
use Amasty\Base\Utils\Http\Url\UrlComparator;
use Magento\Framework\Exception\NotFoundException;
use PHPUnit\Framework\TestCase;

class ConfigPoolTest extends TestCase
{
    /**
     * @var ConfigPool|\PHPUnit\Framework\MockObject\MockObject
     */
    private $model;

    /**
     * @var UrlComparator|\PHPUnit\Framework\MockObject\MockObject
     */
    private $urlComparatorMock;

    /**
     * @var string
     */
    private $configMockPath = 'path';

    /**
     * @var Config|\PHPUnit\Framework\MockObject\MockObject
     */
    private $configMock;

    protected function setUp(): void
    {
        $this->urlComparatorMock = $this->createPartialMock(UrlComparator::class, ['isEqual']);
        $this->configMock = $this->createMock(Config::class);

        $this->model = new ConfigPool(
            $this->urlComparatorMock,
            [$this->configMockPath => $this->configMock]
        );
    }

    public function testGet()
    {
        $path = 'path';
        $this->urlComparatorMock
            ->expects($this->once())
            ->method('isEqual')
            ->with($path, $this->configMockPath)
            ->willReturn(true);

        $this->assertEquals($this->configMock, $this->model->get($path));
    }

    public function testGetNotFound()
    {
        $path = 'path1';
        $this->urlComparatorMock
            ->expects($this->once())
            ->method('isEqual')
            ->with($path, $this->configMockPath)
            ->willReturn(false);

        $this->expectException(NotFoundException::class);
        $this->model->get($path);
    }
}

Spamworldpro Mini