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/framework/Shell/Test/Unit/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

namespace Magento\Framework\Shell\Test\Unit;

use Magento\Framework\Shell\ComplexParameter;
use PHPUnit\Framework\TestCase;

class ComplexParameterTest extends TestCase
{
    public function testGetFromArray()
    {
        $object = new ComplexParameter('baz');
        $this->assertSame([], $object->getFromArray(['--foo', '--bar']));
        $this->assertSame([], $object->getFromArray(['--foo', '--bar', '--baz']));
        $this->assertSame([1 => ''], $object->getFromArray(['--foo', '--bar', '--baz=1']));
    }

    /**
     * @param string $str
     * @param array $expected
     * @dataProvider getFromStringDataProvider
     */
    public function testGetFromString($str, $expected)
    {
        $object = new ComplexParameter('foo');
        $this->assertSame($expected, $object->getFromString($str));
    }

    /**
     * @return array
     */
    public function getFromStringDataProvider()
    {
        return [
            ['--not-matching', []],
            ['--foo', []],
            ['--foo=', []],
            ['--foo=1', [1 => '']],
            ['--foo=bar=1&baz=2', ['bar' => '1', 'baz' => '2']],
            ['--foo=bar[1]=2&baz[3]=4', ['bar' => [1 => '2'], 'baz' => [3 => '4']]],
            ['--foo=bar[one]=value1&bar[two]=value2', ['bar' => ['one' => 'value1', 'two' => 'value2']]],
        ];
    }

    public function testPattern()
    {
        $object = new ComplexParameter('f', '/^-%s=(bar|baz)$/');
        $this->assertSame([], $object->getFromString('-f=1'));
        $this->assertSame(['bar' => ''], $object->getFromString('-f=bar'));
        $this->assertSame(['baz' => ''], $object->getFromString('-f=baz'));
    }

    public function testMergeFromArgv()
    {
        $object = new ComplexParameter('foo');
        $server = ['argv' => ['--foo=bar=value1', '--nonfoo=value2']];
        $into = ['baz' => 'value3'];
        $this->assertSame(['baz' => 'value3', 'bar' => 'value1'], $object->mergeFromArgv($server, $into));
    }
}

Spamworldpro Mini