<commit_before><?php

/*
 *  This file is part of SplashSync Project.
 *
 *  Copyright (C) Splash Sync  <www.splashsync.com>
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  For the full copyright and license information, please view the LICENSE
 *  file that was distributed with this source code.
 */

namespace Splash\Tests\Tools;

use ArrayObject;
use Exception;
use Splash\Client\Splash;

/**
 * Abstract Base Class for Splash Modules Tests
 */
abstract class AbstractBaseCase extends TestCase
{
    use Traits\SettingsTrait;
    use Traits\ObjectsValidatorTrait;
    use Traits\ObjectsAssertionsTrait;

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

        //====================================================================//
        // BOOT or REBOOT MODULE
        Splash::reboot();
    }

    /**
     * Check if Sequence Name Is to be tested or Not
     *
     * @param string $sequenceName Sequence Name
     *
     * @return bool
     */
    public static function isAllowedSequence(string $sequenceName): bool
    {
        static $allowed;

        //====================================================================//
        //   Filter Tested Sequence Name  =>> Skip
        if (!isset($allowed)) {
            if (defined("SPLASH_SEQUENCE") && is_string(SPLASH_SEQUENCE)) {
                $allowed = (array) explode(",", SPLASH_SEQUENCE);
            } else {
                $allowed = array();
            }
        }

        return (empty($allowed) || !in_array($sequenceName, $allowed, true));
    }

    /**
     * Check if Object Type Is to be tested or Not
     *
     * @param string $objectType Object Type Name
     *
     * @throws Exception
     *
     * @return bool
     */
    public static function isAllowedObjectType(string $objectType): bool
    {
        //====================================================================//
        //   Filter Tested Object Types  =>> Skip
        if (defined("SPLASH_TYPES") && is_string(SPLASH_TYPES)) {
            $allowed = (array) explode(",", SPLASH_TYPES);
            if (!empty($allowed) && !in_array($objectType, $allowed, true)) {
                return false;
            }
        }
        //====================================================================//
        //   If Object Type Is Disabled Type  =>> Skip
        if (Splash::object($objectType)->isDisabled()) {
            return false;
        }

        return true;
    }

    /**
     * Check if Object Field ID Is to be tested or Not
     *
     * @param string $identifier Object Field Identifier
     *
     * @return bool
     */
    public static function isAllowedObjectField(string $identifier): bool
    {
        static $allowed;

        //====================================================================//
        //   Filter Tested Object Fields  =>> Skip
        if (!isset($allowed)) {
            if (defined("SPLASH_FIELDS") && is_string(SPLASH_FIELDS)) {
                $allowed = (array) explode(",", SPLASH_FIELDS);
            } else {
                $allowed = array();
            }
        }

        return (empty($allowed) || !in_array($identifier, $allowed, true));
    }

    /**
     * GENERATE FAKE SPLASH SERVER HOST URL
     *
     * @see SERVER_NAME parameter that must be defined in PhpUnit Configuration File
     *<commit_msg>FIX: PhpUnit Fields Filter<commit_after><?php

/*
 *  This file is part of SplashSync Project.
 *
 *  Copyright (C) Splash Sync  <www.splashsync.com>
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 *  For the full copyright and license information, please view the LICENSE
 *  file that was distributed with this source code.
 */

namespace Splash\Tests\Tools;

use ArrayObject;
use Exception;
use Splash\Client\Splash;

/**
 * Abstract Base Class for Splash Modules Tests
 */
abstract class AbstractBaseCase extends TestCase
{
    use Traits\SettingsTrait;
    use Traits\ObjectsValidatorTrait;
    use Traits\ObjectsAssertionsTrait;

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

        //====================================================================//
        // BOOT or REBOOT MODULE
        Splash::reboot();
    }

    /**
     * Check if Sequence Name Is to be tested or Not
     *
     * @param string $sequenceName Sequence Name
     *
     * @return bool
     */
    public static function isAllowedSequence(string $sequenceName): bool
    {
        static $allowed;

        //====================================================================//
        //   Filter Tested Sequence Name  =>> Skip
        if (!isset($allowed)) {
            if (defined("SPLASH_SEQUENCE") && is_string(SPLASH_SEQUENCE)) {
                $allowed = (array) explode(",", SPLASH_SEQUENCE);
            } else {
                $allowed = array();
            }
        }

        return (empty($allowed) || !in_array($sequenceName, $allowed, true));
    }

    /**
     * Check if Object Type Is to be tested or Not
     *
     * @param string $objectType Object Type Name
     *
     * @throws Exception
     *
     * @return bool
     */
    public static function isAllowedObjectType(string $objectType): bool
    {
        //====================================================================//
        //   Filter Tested Object Types  =>> Skip
        if (defined("SPLASH_TYPES") && is_string(SPLASH_TYPES)) {
            $allowed = (array) explode(",", SPLASH_TYPES);
            if (!empty($allowed) && !in_array($objectType, $allowed, true)) {
                return false;
            }
        }
        //====================================================================//
        //   If Object Type Is Disabled Type  =>> Skip
        if (Splash::object($objectType)->isDisabled()) {
            return false;
        }

        return true;
    }

    /**
     * Check if Object Field ID Is to be tested or Not
     *
     * @param string $identifier Object Field Identifier
     *
     * @return bool
     */
    public static function isAllowedObjectField(string $identifier): bool
    {
        static $allowed;

        //====================================================================//
        //   Filter Tested Object Fields  =>> Skip
        if (!isset($allowed)) {
            if (defined("SPLASH_FIELDS") && is_string(SPLASH_FIELDS)) {
                $allowed = (array) explode(",", SPLASH_FIELDS);
            } else {
                $allowed = array();
            }
        }

        return (empty($allowed) || in_array($identifier, $allowed, true));
    }

    /**
     * GENERATE FAKE SPLASH SERVER HOST URL
     *
     * @see SERVER_NAME parameter that must be defined in PhpUnit Configuration File
     *
{'fraction_non_alphanumeric': 0.1942020827469744, 'fraction_numerical': 0.0, 'mean_word_length': 2.281163434903047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '2246952', 'n_tokens_mistral': 1895, 'n_tokens_neox': 1829, 'n_words': 543}