HEX
Server: Apache
System: Linux webm019.cluster128.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: petsclubcc (68997)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/petsclubcc/magento/vendor/magento/framework/Config/Test/Unit/Data/ConfigDataTest.php
<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Framework\Config\Test\Unit\Data;

use Magento\Framework\Config\Data\ConfigData;

class ConfigDataTest extends \PHPUnit_Framework_TestCase
{
    public function testSet()
    {
        $fileKey = 'testFileKey';
        $expectedValue = [
            'test' => [
                'path' => [
                    'value1' => 'val1',
                    'value2' => 'val4',
                    'value3' => 'val3',
                ]
            ]
        ];
        $configData = new ConfigData($fileKey);

        $configData->set('test/path/value1', 'val1');
        $configData->set('test/path/value2', 'val2');
        $configData->set('test/path/value3', 'val3');
        $configData->set('test/path/value2', 'val4');

        $this->assertEquals($expectedValue, $configData->getData());
        $this->assertEquals($fileKey, $configData->getFileKey());
    }

    /**
     * @param string $key
     * @param string $expectedException
     * @dataProvider setWrongKeyDataProvider
     */
    public function testSetWrongKey($key, $expectedException)
    {

        $configData = new ConfigData('testKey');

        $this->setExpectedException('InvalidArgumentException', $expectedException);
        $configData->set($key, 'value');
    }

    public function setWrongKeyDataProvider()
    {
        return [
            'segment is empty' => [
                '/test/test/test',
                "Path '/test/test/test' is invalid. It cannot be empty nor start or end with '/'"
            ],
            'key is empty' => [
                '',
                "Path '' is invalid. It cannot be empty nor start or end with '/'"
            ],
            'access by empty value key' => [
                'test/',
                "Path 'test/' is invalid. It cannot be empty nor start or end with '/'"
            ]
        ];
    }
}