<commit_before><?php

require_once (__DIR__."/../../module_system/system/class_testbase.php");

class class_test_databaseMultiInsert extends class_testbase {


    public function tearDown() {
        $this->flushDBCache();
        if(in_array(_dbprefix_."temp_autotest", class_carrier::getInstance()->getObjDB()->getTables())) {
            $strQuery = "DROP TABLE "._dbprefix_."temp_autotest";
            class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array());
        }

        parent::tearDown();
    }

    public function testInserts() {

        $objDB = class_carrier::getInstance()->getObjDB();

        echo "testing database...\n";
        echo "current driver: ".class_carrier::getInstance()->getObjConfig()->getConfig("dbdriver")."\n";


        echo "\tcreating a new table...\n";

        $arrFields = array();
        $arrFields["temp_id"]       = array("char20", false);
        $arrFields["temp_char100"]  = array("char100", true);
        $arrFields["temp_char254"]  = array("char254", true);

        $this->assertTrue($objDB->createTable("temp_autotest", $arrFields, array("temp_id")), "testDataBase createTable");

        echo "\tcreating 50 records...\n";

        $arrValues = array();
        for($intI = 1; $intI <= 50; $intI++) {
            $arrValues[] = array(generateSystemid(), "text long ".$intI, "text ".$intI);
        }

        $this->assertTrue($objDB->multiInsert("temp_autotest", array("temp_id", "temp_char254", "temp_char100"), $arrValues));

        $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM "._dbprefix_."temp_autotest", array());
        $this->assertEquals($arrRow["COUNT(*)"], 50);

        for($intI = 1; $intI <= 50; $intI++) {
            $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM "._dbprefix_."temp_autotest WHERE temp_char100 = ?", array("text ".$intI));
            $this->assertEquals($arrRow["COUNT(*)"], 1);

            $arrRow = $objDB->getPRow("SELECT * FROM "._dbprefix_."temp_autotest WHERE temp_char100 = ?", array("text ".$intI));
            $this->assertEquals($arrRow["temp_char254"], "text long ".$intI);
        }


        $strQuery = "TRUNCATE TABLE "._dbprefix_."temp_autotest";
        $this->assertTrue($objDB->_pQuery($strQuery, array()), "testDataBase truncateTable");
        $objDB->flushQueryCache();

        $strQuery = "SELECT COUNT(*) FROM "._dbprefix_."temp_autotest";
        $this->assertEquals(0, $objDB->getPRow($strQuery, array())["COUNT(*)"], "testDataBase countLimitReach");

        $objDB->flushQueryCache();
        echo "\tcreating 1200 records...\n";
<commit_msg>UPDATE: module_system | db-unittest -> fixed the sql syntax of a unittest<commit_after><?php

require_once (__DIR__."/../../module_system/system/class_testbase.php");

class class_test_databaseMultiInsert extends class_testbase {


    public function tearDown() {
        $this->flushDBCache();
        if(in_array(_dbprefix_."temp_autotest", class_carrier::getInstance()->getObjDB()->getTables())) {
            $strQuery = "DROP TABLE "._dbprefix_."temp_autotest";
            class_carrier::getInstance()->getObjDB()->_pQuery($strQuery, array());
        }

        parent::tearDown();
    }

    public function testInserts() {

        $objDB = class_carrier::getInstance()->getObjDB();

        echo "testing database...\n";
        echo "current driver: ".class_carrier::getInstance()->getObjConfig()->getConfig("dbdriver")."\n";


        echo "\tcreating a new table...\n";

        $arrFields = array();
        $arrFields["temp_id"]       = array("char20", false);
        $arrFields["temp_char100"]  = array("char100", true);
        $arrFields["temp_char254"]  = array("char254", true);

        $this->assertTrue($objDB->createTable("temp_autotest", $arrFields, array("temp_id")), "testDataBase createTable");

        echo "\tcreating 50 records...\n";

        $arrValues = array();
        for($intI = 1; $intI <= 50; $intI++) {
            $arrValues[] = array(generateSystemid(), "text long ".$intI, "text ".$intI);
        }

        $this->assertTrue($objDB->multiInsert("temp_autotest", array("temp_id", "temp_char254", "temp_char100"), $arrValues));

        $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM "._dbprefix_."temp_autotest", array());
        $this->assertEquals($arrRow["COUNT(*)"], 50);

        for($intI = 1; $intI <= 50; $intI++) {
            $arrRow = $objDB->getPRow("SELECT COUNT(*) FROM "._dbprefix_."temp_autotest WHERE temp_char100 = ?", array("text ".$intI));
            $this->assertEquals($arrRow["COUNT(*)"], 1);

            $arrRow = $objDB->getPRow("SELECT * FROM "._dbprefix_."temp_autotest WHERE temp_char100 = ?", array("text ".$intI));
            $this->assertEquals($arrRow["temp_char254"], "text long ".$intI);
        }


        $strQuery = "DELETE FROM "._dbprefix_."temp_autotest";
        $this->assertTrue($objDB->_pQuery($strQuery, array()), "testDataBase truncateTable");
        $objDB->flushQueryCache();

        $strQuery = "SELECT COUNT(*) FROM "._dbprefix_."temp_autotest";
        $this->assertEquals(0, $objDB->getPRow($strQuery, array())["COUNT(*)"], "testDataBase countLimitReach");

        $objDB->flushQueryCache();
        echo "\tcreating 1200 records...\n";

{'fraction_non_alphanumeric': 0.1874641696923371, 'fraction_numerical': 0.017198547678196063, 'mean_word_length': 3.304276315789474, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6609000', 'n_tokens_mistral': 1724, 'n_tokens_neox': 1590, 'n_words': 281}