<commit_before><?php
namespace TYPO3\Flow\Tests\Functional\Configuration;

/*
 * This file is part of the TYPO3.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Configuration\ConfigurationManager;
use TYPO3\Flow\Configuration\ConfigurationSchemaValidator;
use TYPO3\Flow\Package\PackageManagerInterface;
use TYPO3\Flow\Package\PackageManager;
use TYPO3\Flow\Core\ApplicationContext;
use TYPO3\Flow\Error\Error;
use TYPO3\Flow\Error\Result;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Tests\FunctionalTestCase;

/**
 * Testcase for Configuration Validation
 */
class ConfigurationValidationTest extends FunctionalTestCase
{

    /**
     * @var array<string>
     */
    protected $contextNames = ['Development', 'Production', 'Testing'];

    /**
     * @var array<string>
     */
    protected $configurationTypes = ['Caches', 'Objects', 'Policy', 'Routes', 'Settings'];

    /**
     * @var array<string>
     */
    protected $schemaPackageKeys = ['TYPO3.Flow'];

    /**
     * @var array<string>
     */
    protected $configurationPackageKeys = ['TYPO3.Flow', 'Neos.FluidAdaptor', 'TYPO3.Eel', 'TYPO3.Kickstart'];

    /**
     *
     * @var ConfigurationSchemaValidator
     */
    protected $configurationSchemaValidator;

    /**
     * @var ConfigurationManager
     */
    protected $originalConfigurationManager;

    /**
     * @var ConfigurationManager
     */
    protected $mockConfigurationManager;

    /**
     * @var PackageManager
     */
    protected $mockPackageManager;

    /**
     * @return void
     */
    public function setUp()
    {
        parent::setUp();

        //
        // create a mock packageManager that only returns the the packages that contain schema files
        //

        $schemaPackages = [];
        $configurationPackages = [];

        // get all packages and select the ones we want to test
        $temporaryPackageManager = $this->objectManager->get(PackageManagerInterface::class);
        foreach ($temporaryPackageManager->getActivePackages() as $package) {
            if (in_array($package->getPackageKey(), $this->getSchemaPackageKeys())) {
                $schemaPackages[$package->getPackageKey()] = $package;
            }
            if (in_array($package->getPackageKey(), $this->getConfigurationPackageKeys())) {
                $configurationPackages[$package->getPackageKey()] = $package;
            }
        }

        $this->mockPackageManager = $this->getMock(PackageManager::class, ['getActivePackages']);
        $this->mockPackageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue($schemaPackages));

        //
        // create mock configurationManager and store the original one
        //

        $this->originalConfigurationManager = $this->objectManager->get(ConfigurationManager::class);

        $yamlConfigurationSource = $this->objectManager->get(\TYPO3\Flow\Tests\Functional\Configuration\Fixtures\RootDirectoryIgnoringYamlSource::class);

        $this->mockConfigurationManager = clone ($this->originalConfigurationManager);
        $this->mockConfigurationManager->setPackages($configurationPackages);
        $this->inject($this->mockConfigurationManager, 'configurationSource', $yamlConfigurationSource);

        $this->objectManager->setInstance(ConfigurationManager::class, $this->mockConfigurationManager);

        //
        // create the configurationSchemaValidator
        //

        $this->configurationSchemaValidator = $this->objectManager->get(ConfigurationSchemaValidator::class);
        $this->inject($this->configurationSchemaValidator, 'configurationManager', $this->mockConfigurationManager);
    }

    /**
     * @return void
     */
    public function tearDown()
    {<commit_msg>TASK: Use createMock instead of getMock to avoid deprecation warnings<commit_after><?php
namespace TYPO3\Flow\Tests\Functional\Configuration;

/*
 * This file is part of the TYPO3.Flow package.
 *
 * (c) Contributors of the Neos Project - www.neos.io
 *
 * This package is Open Source Software. For the full copyright and license
 * information, please view the LICENSE file which was distributed with this
 * source code.
 */

use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Configuration\ConfigurationManager;
use TYPO3\Flow\Configuration\ConfigurationSchemaValidator;
use TYPO3\Flow\Package\PackageManagerInterface;
use TYPO3\Flow\Package\PackageManager;
use TYPO3\Flow\Core\ApplicationContext;
use TYPO3\Flow\Error\Error;
use TYPO3\Flow\Error\Result;
use TYPO3\Flow\Reflection\ObjectAccess;
use TYPO3\Flow\Tests\FunctionalTestCase;

/**
 * Testcase for Configuration Validation
 */
class ConfigurationValidationTest extends FunctionalTestCase
{

    /**
     * @var array<string>
     */
    protected $contextNames = ['Development', 'Production', 'Testing'];

    /**
     * @var array<string>
     */
    protected $configurationTypes = ['Caches', 'Objects', 'Policy', 'Routes', 'Settings'];

    /**
     * @var array<string>
     */
    protected $schemaPackageKeys = ['TYPO3.Flow'];

    /**
     * @var array<string>
     */
    protected $configurationPackageKeys = ['TYPO3.Flow', 'Neos.FluidAdaptor', 'TYPO3.Eel', 'TYPO3.Kickstart'];

    /**
     *
     * @var ConfigurationSchemaValidator
     */
    protected $configurationSchemaValidator;

    /**
     * @var ConfigurationManager
     */
    protected $originalConfigurationManager;

    /**
     * @var ConfigurationManager
     */
    protected $mockConfigurationManager;

    /**
     * @var PackageManager
     */
    protected $mockPackageManager;

    /**
     * @return void
     */
    public function setUp()
    {
        parent::setUp();

        //
        // create a mock packageManager that only returns the the packages that contain schema files
        //

        $schemaPackages = [];
        $configurationPackages = [];

        // get all packages and select the ones we want to test
        $temporaryPackageManager = $this->objectManager->get(PackageManagerInterface::class);
        foreach ($temporaryPackageManager->getActivePackages() as $package) {
            if (in_array($package->getPackageKey(), $this->getSchemaPackageKeys())) {
                $schemaPackages[$package->getPackageKey()] = $package;
            }
            if (in_array($package->getPackageKey(), $this->getConfigurationPackageKeys())) {
                $configurationPackages[$package->getPackageKey()] = $package;
            }
        }

        $this->mockPackageManager = $this->createMock(PackageManager::class);
        $this->mockPackageManager->expects($this->any())->method('getActivePackages')->will($this->returnValue($schemaPackages));

        //
        // create mock configurationManager and store the original one
        //

        $this->originalConfigurationManager = $this->objectManager->get(ConfigurationManager::class);

        $yamlConfigurationSource = $this->objectManager->get(\TYPO3\Flow\Tests\Functional\Configuration\Fixtures\RootDirectoryIgnoringYamlSource::class);

        $this->mockConfigurationManager = clone ($this->originalConfigurationManager);
        $this->mockConfigurationManager->setPackages($configurationPackages);
        $this->inject($this->mockConfigurationManager, 'configurationSource', $yamlConfigurationSource);

        $this->objectManager->setInstance(ConfigurationManager::class, $this->mockConfigurationManager);

        //
        // create the configurationSchemaValidator
        //

        $this->configurationSchemaValidator = $this->objectManager->get(ConfigurationSchemaValidator::class);
        $this->inject($this->configurationSchemaValidator, 'configurationManager', $this->mockConfigurationManager);
    }

    /**
     * @return void
     */
    public function tearDown()
    {
{'fraction_non_alphanumeric': 0.12400398406374502, 'fraction_numerical': 0.004233067729083665, 'mean_word_length': 3.270600744284955, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3837086', 'n_tokens_mistral': 2132, 'n_tokens_neox': 2078, 'n_words': 418}