<commit_before><?php
    /*********************************************************************************
     * Zurmo is a customer relationship management program developed by
     * Zurmo, Inc. Copyright (C) 2012 Zurmo Inc.
     *
     * Zurmo is free software; you can redistribute it and/or modify it under
     * the terms of the GNU General Public License version 3 as published by the
     * Free Software Foundation with the addition of the following permission added
     * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
     * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
     * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
     *
     * Zurmo 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.  See the GNU General Public License for more
     * details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program; if not, see http://www.gnu.org/licenses or write to the Free
     * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     * 02110-1301 USA.
     *
     * You can contact Zurmo, Inc. with a mailing address at 113 McHenry Road Suite 207,
     * Buffalo Grove, IL 60089, USA. or at email address <EMAIL>.
     ********************************************************************************/

    $basePath = realpath(dirname(__FILE__) . '/../../../');

    require_once('../PhpUnitServiceUtil.php');
    require_once 'File/Iterator.php';
    require_once('File/Iterator/Factory.php');

    if (is_file($basePath . '/protected/config/debugTest.php'))
    {
        require_once($basePath . '/protected/config/debugTest.php');
    }
    else
    {
        copy($basePath . '/protected/config/debugDIST.php', $basePath . '/protected/config/debugTest.php');
        die('Please configure functional tests in config file ' . $basePath . '/protected/config/debugTest.php');
    }

    define('SELENIUM_SERVER_PATH', $seleniumServerPath);
    define('TEST_BASE_URL', $seleniumTestBaseUrl);
    define('TEST_RESULTS_URL', $seleniumTestResultUrl);
    define('TEST_RESULTS_PATH', $seleniumTestResultsPath);
    //following is path to the user-extension.js, so as to enable the use of global variables
    define('USER_EXTENSIONS_JS_PATH', './assets/extensions/user-extensions.js');
    define('SELENIUM_SERVER_PORT', $seleniumServerPort);
    define('BROWSERS_TO_RUN', $seleniumBrowsersToRun);
    define('TEST_BASE_CONTROL_URL', $seleniumControlUrl);

    class TestSuite
    {
        public static function run()
        {
            global $argv, $argc;

            $usage = "\n"                                                                                                   .
                     "  Usage: php [options] TestSuite.php <All|Misc|moduleName|TestClassName> [options]\n"                 .
                     "\n"                                                                                                   .
                     "    All               Run all tests.\n"                                                               .
                     "    Framework         Run all tests in framework/tests/functional.\n"                                 .
                     "    Misc              Run the test suites in app/protected/tests/functional.\n"                       .
                     "    moduleName        Run the test suites in app/protected/modules/moduleName/tests/functional.\n"    .
                     "    TestClassName     Run the tests in TestClassName.html, wherever that happens to be.\n"            .
                     "    options\n"                                                                                        .
                     "    -p                port Example: -p4044\n"                                                         .
                     "    -h                host Example: -hhttp://www.sitetotest/app/\n"                                   .
                     "    -b                browser <*firefox|*iexplore> if not specified, will run all in browsers \n"     .
                     "    -c                test server control url Example: -chttp://www.sitetotest/controlUrl.php\n"      .
                     "                      Example: -b*firefox \n"                                                         .
                     "    -userExtensions   Example: -userExtensions pathToTheUserExtensionJS \n"                           .
                     "\n"                                                                                                   .
                     "  Examples:\n"                                                                                        .
                     "\n"                                                                                                   .
                     "    php TestSuiteSelenium.php accounts (Run the tests in the Accounts module.)\n"                     .
                     "    php TestSuiteSelenium.php RedBeanModelTest   (Run the test suite RedBeanModelTest.html.)\n"       .
                     "\n"                                                                                                   .
                     "  Note:\n"                                                                                            .
                     "\n"                                                                                                   ;

            PhpUnitServiceUtil::checkVersion();
            if ($argv[0] != 'TestSuite.php')
            {
                echo $usage;
                exit;
            }
            else
            {
                $whatToTest = $argv[1];
            }
            $whatToTestIsModuleDir = self::isWhatToTestAModule($whatToTest);
            $suiteNames          = array();
            $htmlTestSuiteFiles  = array();
            if ($whatToTest == 'All' || $whatToTest == 'Misc' || !$whatToTestIsModuleDir)
            {
                $compareToTest = $whatToTest;
                if ($whatToTest == 'Misc')
                {
                    $compareToTest = null;
                }
                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory($htmlTestSuiteFiles, '.', $compareToTest);
            }
            if ($whatToTest != 'Misc' && !$whatToTestIsModuleDir)
            {
                $compareToTest = $whatToTest;
                if ($whatToTest == 'Framework')
                {
                    $compareToTest = null;
                }
                $frameworkTestSuiteDirectory = '../../core/tests/functional';
                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory(
                    $htmlTestSuiteFiles, $frameworkTestSuiteDirectory, $compareToTest);
            }
            $moduleDirectoryName = '../../modules';
            if (is_dir($moduleDirectoryName))
            {
                $moduleNames = scandir($moduleDirectoryName);
                foreach ($moduleNames as $moduleName)
                {
                    if ($moduleName != '.' &&
                        $moduleName != '..')
                    {
                        $moduleFunctionalTestDirectoryName = "$moduleDirectoryName/$moduleName/tests/functional";
                        if (is_dir($moduleFunctionalTestDirectoryName))
                        {
                            if ($whatToTest          == 'All'        ||
                                // Allow specifying 'Users' for the module name 'users'.
                                $whatToTest          == $moduleName  ||
                                strtolower($whatToTest) == $moduleName  || !$whatToTestIsModuleDir)
                            {
                                if ($whatToTest          == $moduleName || strtolower($whatToTest) == $moduleName)
                                {
                                    $compareToTest = null;
                                }
                                else
                                {
                                    $compareToTest = $whatToTest;
                                }
                                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory(
                                    $htmlTestSuiteFiles, $moduleFunctionalTestDirectoryName, $compareToTest);
                            }
                        }
                    }
                }
            }
            if (count($htmlTestSuiteFiles) == 0)
            {
                echo $usage;
                echo "  No tests found for '$whatToTest'.\n\n";
                exit;
            }
            echo 'Suites to run:' . "\n";
            foreach ($htmlTestSuiteFiles as $pathToSuite)
            {
                if (in_array(basename($pathToSuite), $suiteNames))
                {
                    echo 'Cannot run tests because there are 2 test suites with the same name.' . "\n";
                    echo 'The duplicate found is here: ' . $pathToSuite . "\n";
                    exit;
                }
                $suiteNames[] = basename($pathToSuite);
                echo $pathToSuite . "\n";
            }
            echo 'Running Test Suites using Selenium RC v2:' . "\n";
            $browsersToRun = self::resolveBrowserFromParameter();
            foreach ($browsersToRun as $browserId => $browserDisplayName)
            {
                self::clearPreviousTestResultsByBrowser($browserDisplayName);
                foreach ($htmlTestSuiteFiles as $pathToSuite)
                {
                    if (!self::isInstallationTest($pathToSuite))
                    {
                        echo 'Restoring test db';
                        self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'restore'));
                        echo "Restored test db";
                        if (!self::isInstallationTest($pathToSuite))
                        {
                            echo 'Set user default time zone.';
                            self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'setUserDefaultTimezone'));
                            echo "User default time zone set.";
                        }
                        echo 'Clear cache on remote server';
                        self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('clearCache'         => '1',
                                                                'ignoreBrowserCheck' => '1'));
                    }
                    else
                    {
                        echo 'Uninstall zurmo';
                        self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'backupRemovePerInstance'));
                    }
                    echo "Cache cleared";
<commit_msg>Minor fix releted to selenium tests<commit_after><?php
    /*********************************************************************************
     * Zurmo is a customer relationship management program developed by
     * Zurmo, Inc. Copyright (C) 2012 Zurmo Inc.
     *
     * Zurmo is free software; you can redistribute it and/or modify it under
     * the terms of the GNU General Public License version 3 as published by the
     * Free Software Foundation with the addition of the following permission added
     * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
     * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
     * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
     *
     * Zurmo 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.  See the GNU General Public License for more
     * details.
     *
     * You should have received a copy of the GNU General Public License along with
     * this program; if not, see http://www.gnu.org/licenses or write to the Free
     * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     * 02110-1301 USA.
     *
     * You can contact Zurmo, Inc. with a mailing address at 113 McHenry Road Suite 207,
     * Buffalo Grove, IL 60089, USA. or at email address <EMAIL>.
     ********************************************************************************/

    $basePath = realpath(dirname(__FILE__) . '/../../../');

    require_once('../PhpUnitServiceUtil.php');
    require_once 'File/Iterator.php';
    require_once('File/Iterator/Factory.php');

    if (is_file($basePath . '/protected/config/debugTest.php'))
    {
        require_once($basePath . '/protected/config/debugTest.php');
    }
    else
    {
        copy($basePath . '/protected/config/debugDIST.php', $basePath . '/protected/config/debugTest.php');
        die('Please configure functional tests in config file ' . $basePath . '/protected/config/debugTest.php');
    }

    define('SELENIUM_SERVER_PATH', $seleniumServerPath);
    define('TEST_BASE_URL', $seleniumTestBaseUrl);
    define('TEST_RESULTS_URL', $seleniumTestResultUrl);
    define('TEST_RESULTS_PATH', $seleniumTestResultsPath);
    //following is path to the user-extension.js, so as to enable the use of global variables
    define('USER_EXTENSIONS_JS_PATH', './assets/extensions/user-extensions.js');
    define('SELENIUM_SERVER_PORT', $seleniumServerPort);
    define('BROWSERS_TO_RUN', $seleniumBrowsersToRun);
    define('TEST_BASE_CONTROL_URL', $seleniumControlUrl);

    class TestSuite
    {
        public static function run()
        {
            global $argv, $argc;

            $usage = "\n"                                                                                                   .
                     "  Usage: php [options] TestSuite.php <All|Misc|moduleName|TestClassName> [options]\n"                 .
                     "\n"                                                                                                   .
                     "    All               Run all tests.\n"                                                               .
                     "    Framework         Run all tests in framework/tests/functional.\n"                                 .
                     "    Misc              Run the test suites in app/protected/tests/functional.\n"                       .
                     "    moduleName        Run the test suites in app/protected/modules/moduleName/tests/functional.\n"    .
                     "    TestClassName     Run the tests in TestClassName.html, wherever that happens to be.\n"            .
                     "    options\n"                                                                                        .
                     "    -p                port Example: -p4044\n"                                                         .
                     "    -h                host Example: -hhttp://www.sitetotest/app/\n"                                   .
                     "    -b                browser <*firefox|*iexplore> if not specified, will run all in browsers \n"     .
                     "    -c                test server control url Example: -chttp://www.sitetotest/controlUrl.php\n"      .
                     "                      Example: -b*firefox \n"                                                         .
                     "    -userExtensions   Example: -userExtensions pathToTheUserExtensionJS \n"                           .
                     "\n"                                                                                                   .
                     "  Examples:\n"                                                                                        .
                     "\n"                                                                                                   .
                     "    php TestSuiteSelenium.php accounts (Run the tests in the Accounts module.)\n"                     .
                     "    php TestSuiteSelenium.php RedBeanModelTest   (Run the test suite RedBeanModelTest.html.)\n"       .
                     "\n"                                                                                                   .
                     "  Note:\n"                                                                                            .
                     "\n"                                                                                                   ;

            PhpUnitServiceUtil::checkVersion();
            if ($argv[0] != 'TestSuite.php')
            {
                echo $usage;
                exit;
            }
            else
            {
                $whatToTest = $argv[1];
            }
            $whatToTestIsModuleDir = self::isWhatToTestAModule($whatToTest);
            $suiteNames          = array();
            $htmlTestSuiteFiles  = array();
            if ($whatToTest == 'All' || $whatToTest == 'Misc' || !$whatToTestIsModuleDir)
            {
                $compareToTest = $whatToTest;
                if ($whatToTest == 'Misc')
                {
                    $compareToTest = null;
                }
                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory($htmlTestSuiteFiles, '.', $compareToTest);
            }
            if ($whatToTest != 'Misc' && !$whatToTestIsModuleDir)
            {
                $compareToTest = $whatToTest;
                if ($whatToTest == 'Framework')
                {
                    $compareToTest = null;
                }
                $frameworkTestSuiteDirectory = '../../core/tests/functional';
                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory(
                    $htmlTestSuiteFiles, $frameworkTestSuiteDirectory, $compareToTest);
            }
            $moduleDirectoryName = '../../modules';
            if (is_dir($moduleDirectoryName))
            {
                $moduleNames = scandir($moduleDirectoryName);
                foreach ($moduleNames as $moduleName)
                {
                    if ($moduleName != '.' &&
                        $moduleName != '..')
                    {
                        $moduleFunctionalTestDirectoryName = "$moduleDirectoryName/$moduleName/tests/functional";
                        if (is_dir($moduleFunctionalTestDirectoryName))
                        {
                            if ($whatToTest          == 'All'        ||
                                // Allow specifying 'Users' for the module name 'users'.
                                $whatToTest          == $moduleName  ||
                                strtolower($whatToTest) == $moduleName  || !$whatToTestIsModuleDir)
                            {
                                if ($whatToTest          == $moduleName || strtolower($whatToTest) == $moduleName)
                                {
                                    $compareToTest = null;
                                }
                                else
                                {
                                    $compareToTest = $whatToTest;
                                }
                                $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory(
                                    $htmlTestSuiteFiles, $moduleFunctionalTestDirectoryName, $compareToTest);
                            }
                        }
                    }
                }
            }
            if (count($htmlTestSuiteFiles) == 0)
            {
                echo $usage;
                echo "  No tests found for '$whatToTest'.\n\n";
                exit;
            }
            echo 'Suites to run:' . "\n";
            foreach ($htmlTestSuiteFiles as $pathToSuite)
            {
                if (in_array(basename($pathToSuite), $suiteNames))
                {
                    echo 'Cannot run tests because there are 2 test suites with the same name.' . "\n";
                    echo 'The duplicate found is here: ' . $pathToSuite . "\n";
                    exit;
                }
                $suiteNames[] = basename($pathToSuite);
                echo $pathToSuite . "\n";
            }
            echo 'Running Test Suites using Selenium RC v2:' . "\n";
            $browsersToRun = self::resolveBrowserFromParameter();
            foreach ($browsersToRun as $browserId => $browserDisplayName)
            {
                self::clearPreviousTestResultsByBrowser($browserDisplayName);
                foreach ($htmlTestSuiteFiles as $pathToSuite)
                {
                    if (!self::isInstallationTest($pathToSuite))
                    {
                        echo 'Restoring test db';
                        self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'restore'));
                        echo "Restored test db";
                        if (!self::isInstallationTest($pathToSuite))
                        {
                            echo 'Set user default time zone.';
                            self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'setUserDefaultTimezone'));
                            echo "User default time zone set.";
                        }
                        echo 'Clear cache on remote server';
                        self::remoteAction(self::resolveHostFromParameterAndConstant(), array('clearCache'         => '1',
                                                                'ignoreBrowserCheck' => '1'));
                    }
                    else
                    {
                        echo 'Uninstall zurmo';
                        self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'backupRemovePerInstance'));
                    }
                    echo "Cache cleared";

{'fraction_non_alphanumeric': 0.09922494592645999, 'fraction_numerical': 0.003695025234318673, 'mean_word_length': 1.0885563711650668, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 122, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5618848', 'n_tokens_mistral': 4982, 'n_tokens_neox': 4617, 'n_words': 1165}