<commit_before><?php
class Kwf_Test_SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
{
    protected $backupStaticAttributes = false;
    protected $autoStop = false;
    protected $_unitTestCookie;
    protected $_domain = null;

    protected function initTestDb($bootstrapFile)
    {
        Kwf_Test_SeparateDb::createSeparateTestDb($bootstrapFile);
        $dbName = Kwf_Test_SeparateDb::getDbName();
        $this->createCookie('test_special_db='.$dbName, 'path=/, max_age=60*5');
        Kwf_Registry::set('db', Kwf_Test::getTestDb($dbName));
        Kwf_Model_Abstract::clearInstances();
    }

    public static function suite($className)
    {
        self::$browsers = array();
        if (Kwf_Registry::get('config')->server->testBrowser) { 
            foreach (Kwf_Registry::get('config')->server->testBrowser as $b) {
                if (!$b->browser) continue; //deaktiviert
                $b = $b->toArray();
                if (isset($b['port'])) $b['port'] = (int)$b['port'];
                if (isset($b['timeout'])) $b['timeout'] = (int)$b['timeout'];
                self::$browsers[] = $b;
            }
        }
        return parent::suite($className);
    }

    public function tearDown()
    {
        Kwf_Test_SeparateDb::restoreTestDb(); // macht das nur wenns eine gibt
        parent::tearDown();
    }

    protected function setUp()
    {
        if (!$cfg = Kwf_Registry::get('testServerConfig')) {
            throw new Kwf_Exception("testServerConfig not set");
        }
        $d = $this->_domain;
        if (!$d) {
            $domain = $cfg->server->domain;
        } else {
            if (!isset($cfg->kwc->domains->$d)) {
                throw new Kwf_Exception("Domain '$d' not found in config");
            }
            $domain = $cfg->kwc->domains->$d->domain;
        }
        $this->setBrowserUrl('http://'.$domain.'/');

        $this->_unitTestCookie = md5(uniqid('testId', true));

        $this->captureScreenshotOnFailure = Kwf_Setup::getConfigSection()=='vivid-test-server';
        $this->screenshotPath = '/mnt/screenshots';
        $this->screenshotUrl = 'http://screenshots.vivid';
        parent::setUp();

    }

    protected function runTest()<commit_msg>clear cache before running selenium test<commit_after><?php
class Kwf_Test_SeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase
{
    protected $backupStaticAttributes = false;
    protected $autoStop = false;
    protected $_unitTestCookie;
    protected $_domain = null;

    protected function initTestDb($bootstrapFile)
    {
        Kwf_Test_SeparateDb::createSeparateTestDb($bootstrapFile);
        $dbName = Kwf_Test_SeparateDb::getDbName();
        $this->createCookie('test_special_db='.$dbName, 'path=/, max_age=60*5');
        Kwf_Registry::set('db', Kwf_Test::getTestDb($dbName));
        Kwf_Model_Abstract::clearInstances();
    }

    public static function suite($className)
    {
        self::$browsers = array();
        if (Kwf_Registry::get('config')->server->testBrowser) { 
            foreach (Kwf_Registry::get('config')->server->testBrowser as $b) {
                if (!$b->browser) continue; //deaktiviert
                $b = $b->toArray();
                if (isset($b['port'])) $b['port'] = (int)$b['port'];
                if (isset($b['timeout'])) $b['timeout'] = (int)$b['timeout'];
                self::$browsers[] = $b;
            }
        }
        return parent::suite($className);
    }

    public function tearDown()
    {
        Kwf_Test_SeparateDb::restoreTestDb(); // macht das nur wenns eine gibt
        parent::tearDown();
    }

    protected function setUp()
    {
        if (!$cfg = Kwf_Registry::get('testServerConfig')) {
            throw new Kwf_Exception("testServerConfig not set");
        }

        Kwf_Util_Apc::callClearCacheByCli(array('type'=>'user'));
        Kwf_Cache::factory('Core', 'Memcached', array(
            'lifetime'=>null,
            'automatic_cleaning_factor' => false,
            'automatic_serialization'=>true))->clean();

        $d = $this->_domain;
        if (!$d) {
            $domain = $cfg->server->domain;
        } else {
            if (!isset($cfg->kwc->domains->$d)) {
                throw new Kwf_Exception("Domain '$d' not found in config");
            }
            $domain = $cfg->kwc->domains->$d->domain;
        }
        $this->setBrowserUrl('http://'.$domain.'/');

        $this->_unitTestCookie = md5(uniqid('testId', true));

        $this->captureScreenshotOnFailure = Kwf_Setup::getConfigSection()=='vivid-test-server';
        $this->screenshotPath = '/mnt/screenshots';
        $this->screenshotUrl = 'http://screenshots.vivid';
        parent::setUp();

    }

    protected function runTest()
{'fraction_non_alphanumeric': 0.15924369747899159, 'fraction_numerical': 0.0016806722689075631, 'mean_word_length': 2.5689655172413794, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 52, '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': '7221952', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1413, 'n_words': 238}