<commit_before><?php

use PHPUnit\Framework\TestCase;
use Unity\Component\Configuration\Drivers\ArrayFile\ArrayFile;

class ArrayFileTest extends TestCase
{
    /**
     * Tests `splitValues()` with 2 segments
     *
     * `splitValues()` should return an array containing
     * the root "database" value and the array access key
     * "user"
     */
    function testSplitValuesTwoSegments()
    {
        $driver = $this->getArrayFileDriverForTest();

        $params = $driver->splitValues('database.user');

        $this->assertInternalType('array', $params);
        $this->assertEquals('database', $params['configFileName']);
        $this->assertEquals('user', $params[0]);
    }

    /**
     * Tests `splitValues()` with 3 segments
     *
     * `splitValues()` should return an array containing
     * the root "internationalization" value and the array
     * access keys "languages" and "pt"
     */
    function testSplitValuesThreeSegments()
    {
        $driver = $this->getArrayFileDriverForTest();

        $params = $driver->splitValues('internationalization.languages.pt');

        $this->assertInternalType('array', $params);
        $this->assertEquals('internationalization', $params['configFileName']);
        $this->assertEquals('languages', $params[0]);
        $this->assertEquals('pt', $params[1]);
    }

    /**
     * Tests `testConfigFileName()` with 3 segments
     *
     * `testConfigFileName()` should return the root value
     * from the given array
     */
    function testConfigFileName()
    {
        $driver = $this->getArrayFileDriverForTest();

        $values = [
            'configFileName' => 'database'
        ];

        $configFileName = $driver->getConfigFileName($values);

        $this->assertEquals('database', $configFileName);
    }

    /**
     * Tests `unsetConfigFileName()`
     *
     * `unsetConfigFileName()` should unset the
     * "configFileName" key and value from the
     * given array
     */
    function testUnsetConfigFileName()
    {
        $driver = $this->getArrayFileDriverForTest();

        $values = ['configFileName' => 'database'];

        $driver->unsetConfigFileName($values);

        $this->assertEmpty($values);
    }

    /**
     * Tests `getFullPath`
     *
     * `getFullPath` should return the fullPath
     * constructed with the given parameters
     */
    function testGetFullPath()
    {
        $driver = $this->getArrayFileDriverForTest();

        $config = 'database';
        $source = $this->getSourceForTest();

        $fullPath = $driver->getFullPath($config, $source);

        $expected = $source . '/' . $config . '.php';

        $this->assertEquals($expected, $fullPath);
    }

    /**
     * Tests `getConfigArray`
     *
     * `getConfigArray` should return an array
     * with the configurations
     */
    function testGetConfigArray()
    {
        $driver = $this->getArrayFileDriverForTest();

        $source = $this->getSourceForTest();

        $configArray = $driver->getConfigArray($source . '/' . 'test.php');

        $this->assertInternalType('array', $configArray);
        $this->assertArrayHasKey('test_key', $configArray);
    }

    function testGetSimpleArray()
    {
        $driver = $this->getArrayFileDriverForTest();

        $source = $this->getSourceForTest();

        $config = $driver->get('database.user', $source);
        $this->assertEquals('root', $config);

        $config = $driver->get('database.psw', $source);
        $this->assertEquals('1234', $config);

        $config = $driver->get('database.db', $source);
        $this->assertEquals('example', $config);

        $config = $driver->get('database.host', $source);
        $this->assertEquals('127.0.0.1', $config);

        $config = $driver->get('database.cache_queries', $source);
        $this->assertEquals(true, $config);<commit_msg>Added testGetTheConfig test<commit_after><?php

use PHPUnit\Framework\TestCase;
use Unity\Component\Configuration\Drivers\ArrayFile\ArrayFile;

class ArrayFileTest extends TestCase
{
    /**
     * Tests `splitValues()` with 2 segments
     *
     * `splitValues()` should return an array containing
     * the root "database" value and the array access key
     * "user"
     */
    function testSplitValuesTwoSegments()
    {
        $driver = $this->getArrayFileDriverForTest();

        $params = $driver->splitValues('database.user');

        $this->assertInternalType('array', $params);
        $this->assertEquals('database', $params['configFileName']);
        $this->assertEquals('user', $params[0]);
    }

    /**
     * Tests `splitValues()` with 3 segments
     *
     * `splitValues()` should return an array containing
     * the root "internationalization" value and the array
     * access keys "languages" and "pt"
     */
    function testSplitValuesThreeSegments()
    {
        $driver = $this->getArrayFileDriverForTest();

        $params = $driver->splitValues('internationalization.languages.pt');

        $this->assertInternalType('array', $params);
        $this->assertEquals('internationalization', $params['configFileName']);
        $this->assertEquals('languages', $params[0]);
        $this->assertEquals('pt', $params[1]);
    }

    /**
     * Tests `testConfigFileName()` with 3 segments
     *
     * `testConfigFileName()` should return the root value
     * from the given array
     */
    function testConfigFileName()
    {
        $driver = $this->getArrayFileDriverForTest();

        $values = [
            'configFileName' => 'database'
        ];

        $configFileName = $driver->getConfigFileName($values);

        $this->assertEquals('database', $configFileName);
    }

    /**
     * Tests `unsetConfigFileName()`
     *
     * `unsetConfigFileName()` should unset the
     * "configFileName" key and value from the
     * given array
     */
    function testUnsetConfigFileName()
    {
        $driver = $this->getArrayFileDriverForTest();

        $values = ['configFileName' => 'database'];

        $driver->unsetConfigFileName($values);

        $this->assertEmpty($values);
    }

    /**
     * Tests `getFullPath()`
     *
     * `getFullPath()` should return the fullPath
     * constructed with the given parameters
     */
    function testGetFullPath()
    {
        $driver = $this->getArrayFileDriverForTest();

        $config = 'database';
        $source = $this->getSourceForTest();

        $fullPath = $driver->getFullPath($config, $source);

        $expected = $source . '/' . $config . '.php';

        $this->assertEquals($expected, $fullPath);
    }

    /**
     * Tests `getConfigArray()`
     *
     * `getConfigArray()` should return an array
     * with the configurations
     */
    function testGetConfigArray()
    {
        $driver = $this->getArrayFileDriverForTest();

        $source = $this->getSourceForTest();

        $configArray = $driver->getConfigArray($source . '/' . 'test.php');

        $this->assertInternalType('array', $configArray);
        $this->assertArrayHasKey('test_key', $configArray);
    }

    /**
     * Tests `getTheConfig()`
     *
     * `getConfigArray()` should return the configuration value
     */
    function testGetTheConfig()
    {
        $driver = $this->getArrayFileDriverForTest();

        $value = $driver->getTheConfig(['test_key' => 'value'], ['test_key']);

        $this->assertEquals('value', $value);
    }

    function testGetSimpleArray()
    {
        $driver = $this->getArrayFileDriverForTest();

        $source = $this->getSourceForTest();

        $config = $driver->get('database.user', $source);
        $this->assertEquals('root', $config);

        $config = $driver->get('database.psw', $source);
        $this->assertEquals('1234', $config);

        $config = $driver->get('database.db', $source);
        $this->assertEquals('example', $config);

        $config = $driver->get('database.host', $source);
        $this->assertEquals('127.0.0.1', $config);

        $config = $driver->get('database.cache_queries', $source);
        $this->assertEquals(true, $config);
{'fraction_non_alphanumeric': 0.1527349055438943, 'fraction_numerical': 0.003951105074700581, 'mean_word_length': 2.7482646922720964, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5414018', 'n_tokens_mistral': 2310, 'n_tokens_neox': 2204, 'n_words': 441}