<commit_before><?php

class DbTest extends \PHPUnit_Framework_TestCase
{
    protected static $config = array(
        'dsn' => 'sqlite:tests/data/sqlite.db',
        'user' => 'root',
        'password' => '',
        'cleanup' => false
    );

    /**
     * @var \Codeception\Module\Db
     */
    protected static $module;
    
    public static function setUpBeforeClass()
    {
        try {
            $sqlite = \Codeception\Lib\Driver\Db::create(self::$config['dsn'], self::$config['user'], self::$config['password']);
            $sqlite->cleanup();
        } catch (\Exception $e) {
            return;
        }
                    
        $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/sqlite.sql');
        $sql = preg_replace('%/\*(?:(?!\*/).)*\*/%s', "", $sql);
        $sql = explode("\n", $sql);
        $sqlite->load($sql);
        
        self::$module = new \Codeception\Module\Db();
        self::$module->_setConfig(self::$config);
        self::$module->_initialize();
    }

    public function testSeeInDatabase()
    {
        self::$module->seeInDatabase('users', array('name' => 'davert'));
    }

    public function testDontSeeInDatabase()
    {
        self::$module->dontSeeInDatabase('users', array('name' => 'user1'));
    }

    public function testDontSeeInDatabaseWithEmptyTable()
    {
        self::$module->dontSeeInDatabase('empty_table');
    }

    public function testGrabFromDatabase()
    {
        $email = self::$module->grabFromDatabase('users', 'email', array('name' => 'davert'));
        $this->assertEquals('<EMAIL>', $email);
    }
<commit_msg>Reuse connection from module<commit_after><?php

class DbTest extends \PHPUnit_Framework_TestCase
{
    protected static $config = array(
        'dsn' => 'sqlite:tests/data/sqlite.db',
        'user' => 'root',
        'password' => '',
        'cleanup' => false
    );

    /**
     * @var \Codeception\Module\Db
     */
    protected static $module;
    
    public static function setUpBeforeClass()
    {
        self::$module = new \Codeception\Module\Db();
        self::$module->_setConfig(self::$config);
        self::$module->_initialize();
        
        $sqlite = self::$module->driver;
        $sqlite->cleanup();
        $sql = file_get_contents(\Codeception\Configuration::dataDir() . '/dumps/sqlite.sql');
        $sql = preg_replace('%/\*(?:(?!\*/).)*\*/%s', "", $sql);
        $sql = explode("\n", $sql);
        $sqlite->load($sql);
    }

    public function testSeeInDatabase()
    {
        self::$module->seeInDatabase('users', array('name' => 'davert'));
    }

    public function testDontSeeInDatabase()
    {
        self::$module->dontSeeInDatabase('users', array('name' => 'user1'));
    }

    public function testDontSeeInDatabaseWithEmptyTable()
    {
        self::$module->dontSeeInDatabase('empty_table');
    }

    public function testGrabFromDatabase()
    {
        $email = self::$module->grabFromDatabase('users', 'email', array('name' => 'davert'));
        $this->assertEquals('<EMAIL>', $email);
    }

{'fraction_non_alphanumeric': 0.18492037699057523, 'fraction_numerical': 0.0006499837504062399, 'mean_word_length': 2.5874125874125875, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 38, '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': '4926365', 'n_tokens_mistral': 924, 'n_tokens_neox': 930, 'n_words': 148}