<commit_before><?php

use org\bovigo\vfs\vfsStream;

require_once 'include/utils/file_utils.php';
class file_utilsTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->rootFs = org\bovigo\vfs\vfsStream::setup('root');
        $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newDirectory('testDir'));
        $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newFile('test.txt')->withContent('Hello world!'));
    }

    public function testclean_path()
    {
        //execute the method and test if it returns expected values

        //invalid path
        $expected = '';
        $path = '';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        //a simple valid path
        $expected = '/SuiteCRM-develop/include/utils';
        $path = '\SuiteCRM-develop\include\utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        //valid network path 
        $expected = '//SuiteCRM-develop/include/utils';
        $path = '\\\\/SuiteCRM-develop/include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        $expected = '/SuiteCRM-develop/include/utils';
        $path = '/SuiteCRM-develop/./include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        $expected = '/SuiteCRM-develop/include/utils';
        $path = '/SuiteCRM-develop//include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);
    }

    public function testcreate_cache_directory()
    {
        //execute the method and test if it created file/dir exists

        $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
        $file = 'Test/';

        if ($this->rootFs->hasChild($file)  == true) {
            rmdir($cache_dir.'/'.$file);
        }

        $actual = create_cache_directory($file);
        $this->assertFileExists($actual);

        if ($this->rootFs->hasChild($file)  == true) {
            rmdir($cache_dir.'/'.$file);
        }
    }

    public function testget_module_dir_list()
    {
        //execute the method and test if it returns expected values

        $expected = array(
                'Accounts' => 'Accounts',
                'ACL' => 'ACL',
                'ACLActions' => 'ACLActions',
                'ACLRoles' => 'ACLRoles',
                'Activities' => 'Activities',
                'Administration' => 'Administration',
                'Alerts' => 'Alerts',
                'AM_ProjectTemplates' => 'AM_ProjectTemplates',
                'AM_TaskTemplates' => 'AM_TaskTemplates',
				'AOBH_BusinessHours' => 'AOBH_BusinessHours',
                'AOD_Index' => 'AOD_Index',
                'AOD_IndexEvent' => 'AOD_IndexEvent',
                'AOK_KnowledgeBase' => 'AOK_KnowledgeBase',
                'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories',
                'AOP_Case_Events' => 'AOP_Case_Events',
                'AOP_Case_Updates' => 'AOP_Case_Updates',
                'AOR_Charts' => 'AOR_Charts',
                'AOR_Conditions' => 'AOR_Conditions',
                'AOR_Fields' => 'AOR_Fields',
                'AOR_Reports' => 'AOR_Reports',
                'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports',
                'AOS_Contracts' => 'AOS_Contracts',
                'AOS_Invoices' => 'AOS_Invoices',
                'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups',
                'AOS_PDF_Templates' => 'AOS_PDF_Templates',
                'AOS_Products' => 'AOS_Products',
                'AOS_Products_Quotes' => 'AOS_Products_Quotes',
                'AOS_Product_Categories' => 'AOS_Product_Categories',
                'AOS_Quotes' => 'AOS_Quotes',
                'AOW_Actions' => 'AOW_Actions',
                'AOW_Conditions' => 'AOW_Conditions',
                'AOW_Processed' => 'AOW_Processed',
                'AOW_WorkFlow' => 'AOW_WorkFlow',
                'Audit' => 'Audit',
                'Bugs' => 'Bugs',
                'Calendar' => 'Calendar',
                'Calls' => 'Calls',
                'Calls_Reschedule' => 'Calls_Reschedule',
                'CampaignLog' => 'CampaignLog',
                'Campaigns' => 'Campaigns',
                'CampaignTrackers' => 'CampaignTrackers',
                'Cases' => 'Cases',
                'Charts' => 'Charts',
                'Configurator' => 'Configurator',
                'Connectors' => 'Connectors',
                'Contacts' => 'Contacts',
                'Currencies' => 'Currencies',
                'Delegates' => 'Delegates',
                'DocumentRevisions' => 'DocumentRevisions',
                'Documents' => 'Documents',
                'DynamicFields' => 'DynamicFields',
                'EAPM' => 'EAPM',
                'EmailAddresses' => 'EmailAddresses',
                'EmailMan' => 'EmailMan',
                'EmailMarketing' => 'EmailMarketing',
                'Emails' => 'Emails',
                'EmailTemplates' => 'EmailTemplates',
                'EmailText' => 'EmailText',
                'Employees' => 'Employees',
                'Favorites' => 'Favorites',
                'FP_events' => 'FP_events',
                'FP_Event_Locations' => 'FP_Event_Locations',
                'Groups' => 'Groups',
                'Help' => 'Help',
                'History' => 'History',
                'Home' => 'Home',
                'iCals' => 'iCals',
                'Import' => 'Import',
                'InboundEmail' => 'InboundEmail',
                'jjwg_Address_Cache' => 'jjwg_Address_Cache',
                'jjwg_Areas' => 'jjwg_Areas',
                'jjwg_Maps' => 'jjwg_Maps',
                'jjwg_Markers' => 'jjwg_Markers',
                'LabelEditor' => 'LabelEditor',
                'Leads' => 'Leads',
                'MailMerge' => 'MailMerge',
                'Meetings' => 'Meetings',
                'MergeRecords' => 'MergeRecords',
                'ModuleBuilder' => 'ModuleBuilder',
                'MySettings' => 'MySettings',
                'Notes' => 'Notes',
                'OAuth2Clients' => 'OAuth2Clients',
                'OAuth2Tokens' => 'OAuth2Tokens',
                'OAuthKeys' => 'OAuthKeys',
                'OAuthTokens' => 'OAuthTokens',
                'Opportunities' => 'Opportunities',
                'OptimisticLock' => 'OptimisticLock',
                'OutboundEmailAccounts' => 'OutboundEmailAccounts',
                'Project' => 'Project',
                'ProjectTask' => 'ProjectTask',
                'ProspectLists' => 'ProspectLists',
                'Prospects' => 'Prospects',
                'Relationships' => 'Relationships',
                'Reminders' => 'Reminders',
                'Reminders_Invitees' => 'Reminders_Invitees',
                'ResourceCalendar' => 'ResourceCalendar',
                'Releases' => 'Releases',
                'Roles' => 'Roles',
                'SavedSearch' => 'SavedSearch',
                'Schedulers' => 'Schedulers',
                'SchedulersJobs' => 'SchedulersJobs',
                'SecurityGroups' => 'SecurityGroups',
                'Spots' => 'Spots',
                'Studio' => 'Studio',
                'SugarFeed' => 'SugarFeed',<commit_msg>Update Module List test.<commit_after><?php

use org\bovigo\vfs\vfsStream;

require_once 'include/utils/file_utils.php';
class file_utilsTest extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->rootFs = org\bovigo\vfs\vfsStream::setup('root');
        $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newDirectory('testDir'));
        $this->rootFs->addChild(org\bovigo\vfs\vfsStream::newFile('test.txt')->withContent('Hello world!'));
    }

    public function testclean_path()
    {
        //execute the method and test if it returns expected values

        //invalid path
        $expected = '';
        $path = '';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        //a simple valid path
        $expected = '/SuiteCRM-develop/include/utils';
        $path = '\SuiteCRM-develop\include\utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        //valid network path 
        $expected = '//SuiteCRM-develop/include/utils';
        $path = '\\\\/SuiteCRM-develop/include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        $expected = '/SuiteCRM-develop/include/utils';
        $path = '/SuiteCRM-develop/./include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);

        $expected = '/SuiteCRM-develop/include/utils';
        $path = '/SuiteCRM-develop//include/utils';
        $actual = clean_path($path);
        $this->assertSame($expected, $actual);
    }

    public function testcreate_cache_directory()
    {
        //execute the method and test if it created file/dir exists

        $cache_dir = rtrim($GLOBALS['sugar_config']['cache_dir'], '/\\');
        $file = 'Test/';

        if ($this->rootFs->hasChild($file)  == true) {
            rmdir($cache_dir.'/'.$file);
        }

        $actual = create_cache_directory($file);
        $this->assertFileExists($actual);

        if ($this->rootFs->hasChild($file)  == true) {
            rmdir($cache_dir.'/'.$file);
        }
    }

    public function testget_module_dir_list()
    {
        //execute the method and test if it returns expected values

        $expected = array(
                'Accounts' => 'Accounts',
                'ACL' => 'ACL',
                'ACLActions' => 'ACLActions',
                'ACLRoles' => 'ACLRoles',
                'Activities' => 'Activities',
                'Administration' => 'Administration',
                'Alerts' => 'Alerts',
                'AM_ProjectTemplates' => 'AM_ProjectTemplates',
                'AM_TaskTemplates' => 'AM_TaskTemplates',
				'AOBH_BusinessHours' => 'AOBH_BusinessHours',
                'AOD_Index' => 'AOD_Index',
                'AOD_IndexEvent' => 'AOD_IndexEvent',
                'AOK_KnowledgeBase' => 'AOK_KnowledgeBase',
                'AOK_Knowledge_Base_Categories' => 'AOK_Knowledge_Base_Categories',
                'AOP_Case_Events' => 'AOP_Case_Events',
                'AOP_Case_Updates' => 'AOP_Case_Updates',
                'AOR_Charts' => 'AOR_Charts',
                'AOR_Conditions' => 'AOR_Conditions',
                'AOR_Fields' => 'AOR_Fields',
                'AOR_Reports' => 'AOR_Reports',
                'AOR_Scheduled_Reports' => 'AOR_Scheduled_Reports',
                'AOS_Contracts' => 'AOS_Contracts',
                'AOS_Invoices' => 'AOS_Invoices',
                'AOS_Line_Item_Groups' => 'AOS_Line_Item_Groups',
                'AOS_PDF_Templates' => 'AOS_PDF_Templates',
                'AOS_Products' => 'AOS_Products',
                'AOS_Products_Quotes' => 'AOS_Products_Quotes',
                'AOS_Product_Categories' => 'AOS_Product_Categories',
                'AOS_Quotes' => 'AOS_Quotes',
                'AOW_Actions' => 'AOW_Actions',
                'AOW_Conditions' => 'AOW_Conditions',
                'AOW_Processed' => 'AOW_Processed',
                'AOW_WorkFlow' => 'AOW_WorkFlow',
                'Audit' => 'Audit',
                'Bugs' => 'Bugs',
                'Calendar' => 'Calendar',
                'Calls' => 'Calls',
                'Calls_Reschedule' => 'Calls_Reschedule',
                'CampaignLog' => 'CampaignLog',
                'Campaigns' => 'Campaigns',
                'CampaignTrackers' => 'CampaignTrackers',
                'Cases' => 'Cases',
                'Charts' => 'Charts',
                'Configurator' => 'Configurator',
                'Connectors' => 'Connectors',
                'Contacts' => 'Contacts',
                'Currencies' => 'Currencies',
                'Delegates' => 'Delegates',
                'DocumentRevisions' => 'DocumentRevisions',
                'Documents' => 'Documents',
                'DynamicFields' => 'DynamicFields',
                'EAPM' => 'EAPM',
                'EmailAddresses' => 'EmailAddresses',
                'EmailMan' => 'EmailMan',
                'EmailMarketing' => 'EmailMarketing',
                'Emails' => 'Emails',
                'EmailTemplates' => 'EmailTemplates',
                'EmailText' => 'EmailText',
                'Employees' => 'Employees',
                'Favorites' => 'Favorites',
                'FP_events' => 'FP_events',
                'FP_Event_Locations' => 'FP_Event_Locations',
                'Groups' => 'Groups',
                'Help' => 'Help',
                'History' => 'History',
                'Home' => 'Home',
                'iCals' => 'iCals',
                'Import' => 'Import',
                'InboundEmail' => 'InboundEmail',
                'jjwg_Address_Cache' => 'jjwg_Address_Cache',
                'jjwg_Areas' => 'jjwg_Areas',
                'jjwg_Maps' => 'jjwg_Maps',
                'jjwg_Markers' => 'jjwg_Markers',
                'LabelEditor' => 'LabelEditor',
                'Leads' => 'Leads',
                'MailMerge' => 'MailMerge',
                'Meetings' => 'Meetings',
                'MergeRecords' => 'MergeRecords',
                'ModuleBuilder' => 'ModuleBuilder',
                'MySettings' => 'MySettings',
                'Notes' => 'Notes',
                'OAuth2Clients' => 'OAuth2Clients',
                'OAuth2Tokens' => 'OAuth2Tokens',
                'OAuthKeys' => 'OAuthKeys',
                'OAuthTokens' => 'OAuthTokens',
                'Opportunities' => 'Opportunities',
                'OptimisticLock' => 'OptimisticLock',
                'OutboundEmailAccounts' => 'OutboundEmailAccounts',
                'Project' => 'Project',
                'ProjectTask' => 'ProjectTask',
                'ProspectLists' => 'ProspectLists',
                'Prospects' => 'Prospects',
                'Relationships' => 'Relationships',
                'Reminders' => 'Reminders',
                'Reminders_Invitees' => 'Reminders_Invitees',
                'ResourceCalendar' => 'ResourceCalendar',
                'Releases' => 'Releases',
                'Roles' => 'Roles',
                'SavedSearch' => 'SavedSearch',
                'Schedulers' => 'Schedulers',
                'SchedulersJobs' => 'SchedulersJobs',
                'SecurityGroups' => 'SecurityGroups',
                'Spots' => 'Spots',
                'Studio' => 'Studio',
                'SugarFeed' => 'SugarFeed',
                'SurveyQuestionOptions' => 'SurveyQuestionOptions',
                'SurveyQuestionResponses' => 'SurveyQuestionResponses',
                'SurveyQuestions' => 'SurveyQuestions',
                'SurveyResponses' => 'SurveyResponses',
                'Surveys' => 'Surveys',
{'fraction_non_alphanumeric': 0.14821751053441243, 'fraction_numerical': 0.0005350812654671928, 'mean_word_length': 1.7958115183246073, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 250, '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': '2878658', 'n_tokens_mistral': 4696, 'n_tokens_neox': 4344, 'n_words': 672}