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-elasticsearch/Test/Unit/Setup/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

namespace Magento\Elasticsearch\Test\Unit\Setup;

use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Search\Setup\InstallConfig;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class InstallConfigTest extends TestCase
{
    /**
     * @var InstallConfig
     */
    private $installConfig;

    /**
     * @var WriterInterface|MockObject
     */
    private $configWriterMock;

    /**
     * @inheritdoc
     */
    protected function setup(): void
    {
        $this->configWriterMock = $this->getMockBuilder(WriterInterface::class)->getMockForAbstractClass();

        $objectManager = new ObjectManager($this);
        $this->installConfig = $objectManager->getObject(
            InstallConfig::class,
            [
                'configWriter' => $this->configWriterMock,
                'searchConfigMapping' => [
                    'elasticsearch-host' => 'elasticsearch5_server_hostname',
                    'elasticsearch-port' => 'elasticsearch5_server_port',
                    'elasticsearch-timeout' => 'elasticsearch5_server_timeout',
                    'elasticsearch-index-prefix' => 'elasticsearch5_index_prefix',
                    'elasticsearch-enable-auth' => 'elasticsearch5_enable_auth',
                    'elasticsearch-username' => 'elasticsearch5_username',
                    'elasticsearch-password' => 'elasticsearch5_password'
                ]
            ]
        );
    }

    /**
     * @return void
     */
    public function testConfigure(): void
    {
        $inputOptions = [
            'search-engine' => 'elasticsearch5',
            'elasticsearch-host' => 'localhost',
            'elasticsearch-port' => '9200'
        ];

        $this->configWriterMock
            ->method('save')
            ->withConsecutive(
                ['catalog/search/engine', 'elasticsearch5'],
                ['catalog/search/elasticsearch5_server_hostname', 'localhost'],
                ['catalog/search/elasticsearch5_server_port', '9200']
            );

        $this->installConfig->configure($inputOptions);
    }

    /**
     * @return void
     */
    public function testConfigureWithEmptyInput(): void
    {
        $this->configWriterMock->expects($this->never())->method('save');
        $this->installConfig->configure([]);
    }
}

Spamworldpro Mini