<commit_before><?php
namespace Oro\Bundle\UserBundle\Tests\Functional\API;

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Finder\Iterator;

class ToolsAPI extends \PHPUnit_Framework_TestCase
{
    static protected $random = null;
    /**
     * Data provider for REST/SOAP API tests
     *
     * @param $folder
     *
     * @return array
     */
    public static function requestsApi($folder)
    {
        $parameters = array();
        $testFiles = new \RecursiveDirectoryIterator(
            __DIR__ . DIRECTORY_SEPARATOR . $folder,
            \RecursiveDirectoryIterator::SKIP_DOTS
        );
        foreach ($testFiles as $fileName => $object) {
            $parameters[$fileName] = Yaml::parse($fileName);
            if (is_null($parameters[$fileName]['response'])) {
                unset($parameters[$fileName]['response']);
            }
        }
        //generate unique value
        if (is_null(self::$random)) {
            self::$random = self::randomGen(5);
        }

        foreach ($parameters as $key => $value) {
            array_walk(
                $parameters[$key]['request'],
                array(self, 'replace'),
                self::$random
            );
            array_walk(
                $parameters[$key]['response'],
                array(self, 'replace'),
                self::$random
            );
        }
        return
            $parameters;
    }

    /**
     * Test API response
     *
     * @param array $response
     * @param array $result
     * @param $debugInfo
     */
    public static function assertEqualsResponse($response, $result, $debugInfo = '')
    {
        self::assertEquals($response['return'], $result, $debugInfo);
    }

    /**<commit_msg>BAP-136 User Bundle functional tests  - fixed SOAP tests<commit_after><?php
namespace Oro\Bundle\UserBundle\Tests\Functional\API;

use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Finder\Iterator;

class ToolsAPI extends \PHPUnit_Framework_TestCase
{
    static protected $random = null;
    /**
     * Data provider for REST/SOAP API tests
     *
     * @param $folder
     *
     * @return array
     */
    public static function requestsApi($folder)
    {
        $parameters = array();
        $testFiles = new \RecursiveDirectoryIterator(
            __DIR__ . DIRECTORY_SEPARATOR . $folder,
            \RecursiveDirectoryIterator::SKIP_DOTS
        );
        foreach ($testFiles as $fileName => $object) {
            $parameters[$fileName] = Yaml::parse($fileName);
            if (is_null($parameters[$fileName]['response'])) {
                unset($parameters[$fileName]['response']);
            }
        }
        //generate unique value
        if (is_null(self::$random)) {
            self::$random = self::randomGen(5);
        }

        foreach ($parameters as $key => $value) {
            array_walk(
                $parameters[$key]['request'],
                array(get_called_class(), 'replace'),
                self::$random
            );
            array_walk(
                $parameters[$key]['response'],
                array(get_called_class(), 'replace'),
                self::$random
            );
        }
        return
            $parameters;
    }

    /**
     * Test API response
     *
     * @param array $response
     * @param array $result
     * @param $debugInfo
     */
    public static function assertEqualsResponse($response, $result, $debugInfo = '')
    {
        self::assertEquals($response['return'], $result, $debugInfo);
    }

    /**
{'fraction_non_alphanumeric': 0.12799548914575698, 'fraction_numerical': 0.00140964195094446, 'mean_word_length': 1.917763157894737, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3846728', 'n_tokens_mistral': 945, 'n_tokens_neox': 943, 'n_words': 191}