<commit_before><?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

use Codeception\Test\Metadata;
use Codeception\TestInterface;

class Acceptance extends \Codeception\Module
{
    public function seePageHas($text, $selector = null)
    {
        try {
            $this->getModule('\SuiteCRM\Test\Driver\WebDriver')->see($text, $selector);
        } catch (\PHPUnit_Framework_AssertionFailedError $f) {
            return false;
        }
        return true;
    }

    public function _beforeSuite()
    {
        $directories = array(
            "custom/modulebuilder/builds/CompanyTestModule",
            "custom/modulebuilder/packages/CompanyTestModule",
            "modules/Test_CompanyTestModule"
        );
        
        foreach ($directories as $_index => $directory) {
            if (is_dir($directory)) {
                $this->getModule('Filesystem')->deleteDir($directory);
            }
        }

        $files = array(
            "custom/application/Ext/Include/modules.ext.php",
            "custom/Extension/application/Ext/Include/CompanyTestModule.php"
        );

        foreach ($files as $_index => $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }

    public function _afterSuite()
    {
        $directories = array(
            "custom/modulebuilder/builds/CompanyTestModule/",
            "custom/modulebuilder/packages/CompanyTestModule/",
            "modules/Test_CompanyTestModule/"
        );

        foreach ($directories as $_index => $directory) {
            if (is_dir($directory)) {
                $this->getModule('Filesystem')->deleteDir($directory);
            }
        }

        $files = array(
            "custom/application/Ext/Include/modules.ext.php",
            "custom/Extension/application/Ext/Include/CompanyTestModule.php"
        );

        foreach ($files as $_index => $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
}<commit_msg>DRY up the acceptance file cleaner.<commit_after><?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

use Codeception\Test\Metadata;
use Codeception\TestInterface;

class Acceptance extends \Codeception\Module
{
    public function seePageHas($text, $selector = null)
    {
        try {
            $this->getModule('\SuiteCRM\Test\Driver\WebDriver')->see($text, $selector);
        } catch (\PHPUnit_Framework_AssertionFailedError $f) {
            return false;
        }
        return true;
    }

    public function _beforeSuite()
    {
        $this->deleteModuleFiles('CompanyTestModule');
    }

    public function _afterSuite()
    {
        $this->deleteModuleFiles('CompanyTestModule');
    }

    /**
     * Deletes module files and directories created by the module builder.
     * This allows the acceptance tests to be re-run.
     * @param string $module
     */
    private function deleteModuleFiles($module) {
        $directories = array(
            "custom/modulebuilder/builds/{$module}",
            "custom/modulebuilder/packages/{$module}",
            "modules/Test_{$module}"
        );
        
        $files = array(
            "custom/application/Ext/Include/modules.ext.php",
            "custom/Extension/application/Ext/Include/{$module}.php"
        );

        foreach ($directories as $_index => $directory) {
            if (is_dir($directory)) {
                $this->getModule('Filesystem')->deleteDir($directory);
            }
        }

        foreach ($files as $_index => $file) {
            if (file_exists($file)) {
                unlink($file);
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11858638743455498, 'fraction_numerical': 0.0, 'mean_word_length': 2.0086614173228345, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '6184990', 'n_tokens_mistral': 1018, 'n_tokens_neox': 999, 'n_words': 206}