<commit_before><?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;
use Pontikis\Database\Dacapo;

final class PostgresqlCUDTest extends TestCase
{
    protected static $db;

    protected static $mc;

    ////////////////////////////////////////////////////////////////////
    // Basic setup - it runs once in Class (before tests)             //
    ////////////////////////////////////////////////////////////////////
    public static function setUpBeforeClass()
    {
        self::$db = [
            'rdbms'     => Dacapo::RDBMS_POSTGRES,
            'db_server' => $GLOBALS['POSTGRES_SERVER_NAME'],
            'db_user'   => $GLOBALS['POSTGRES_USER'],
            'db_passwd' => $GLOBALS['<PASSWORD>'],
            'db_name'   => $GLOBALS['POSTGRES_DBNAME'],
        ];

        self::$mc = [
            'mc_pool'       => [
                [
                    'mc_server' => '127.0.0.1',
                    'mc_port'   => '11211',
                    'mc_weight' => 0,
                ],
            ],
            'use_memcached' => true,
        ];

        $ds = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $ds->setDbSchema($GLOBALS['POSTGRES_DBSCHEMA']);

        $sql = 'DROP TABLE IF EXISTS customers CASCADE;
CREATE TABLE customers (
    id integer NOT NULL,
    lastname character varying(100) NOT NULL,
    firstname character varying(100) NOT NULL,
    fathername character varying(100),
    gender integer,
    address character varying(200)
);
ALTER TABLE customers OWNER TO testdb;
CREATE SEQUENCE customers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;
ALTER TABLE customers_id_seq OWNER TO testdb;
ALTER SEQUENCE customers_id_seq OWNED BY customers.id;
ALTER TABLE ONLY customers
    ADD CONSTRAINT customers_pkey PRIMARY KEY (id);';

        $ds->execute($sql);
    }

    ////////////////////////////////////////////////////////////////////
    // Basic setup - it runs once in Class (after tests)              //
    ////////////////////////////////////////////////////////////////////
    public static function tearDownAfterClass()
    {
        $ds  = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $ds->setDbSchema($GLOBALS['POSTGRES_DBSCHEMA']);
        $sql = 'DROP TABLE IF EXISTS customers CASCADE;';
        //$ds->execute($sql);
    }

    ////////////////////////////////////////////////////////////////////
    // Test instance                                                  //
    ////////////////////////////////////////////////////////////////////
    public function testSelect01()
    {
        $ds          = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $sql         = 'SELECT * FROM test.customers';
        $bind_params = [];
        $ds->select($sql, $bind_params);
        $this->assertSame(
            0,
            $ds->getNumRows()
        );
    }
}<commit_msg>PHPUnit tests - Create Update Delete (CUD) #6<commit_after><?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;
use Pontikis\Database\Dacapo;

final class PostgresqlCUDTest extends TestCase
{
    protected static $db;

    protected static $mc;

    ////////////////////////////////////////////////////////////////////
    // Basic setup - it runs once in Class (before tests)             //
    ////////////////////////////////////////////////////////////////////
    public static function setUpBeforeClass()
    {
        self::$db = [
            'rdbms'     => Dacapo::RDBMS_POSTGRES,
            'db_server' => $GLOBALS['POSTGRES_SERVER_NAME'],
            'db_user'   => $GLOBALS['POSTGRES_USER'],
            'db_passwd' => $GLOBALS['<PASSWORD>'],
            'db_name'   => $GLOBALS['POSTGRES_DBNAME'],
        ];

        self::$mc = [
            'mc_pool'       => [
                [
                    'mc_server' => '127.0.0.1',
                    'mc_port'   => '11211',
                    'mc_weight' => 0,
                ],
            ],
            'use_memcached' => true,
        ];

        $ds = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $ds->setDbSchema($GLOBALS['POSTGRES_DBSCHEMA']);

        $sql = 'DROP TABLE IF EXISTS customers CASCADE;
CREATE TABLE customers (
    id integer NOT NULL,
    lastname character varying(100) NOT NULL,
    firstname character varying(100) NOT NULL,
    fathername character varying(100),
    gender integer,
    address character varying(200)
);
ALTER TABLE customers OWNER TO testdb;
CREATE SEQUENCE customers_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;
ALTER TABLE customers_id_seq OWNER TO testdb;
ALTER SEQUENCE customers_id_seq OWNED BY customers.id;
ALTER TABLE ONLY customers
    ADD CONSTRAINT customers_pkey PRIMARY KEY (id);';

        $ds->execute($sql);
    }

    ////////////////////////////////////////////////////////////////////
    // Basic setup - it runs once in Class (after tests)              //
    ////////////////////////////////////////////////////////////////////
    public static function tearDownAfterClass()
    {
        $ds  = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $ds->setDbSchema($GLOBALS['POSTGRES_DBSCHEMA']);
        $sql = 'DROP TABLE IF EXISTS customers CASCADE;';
        $ds->execute($sql);
    }

    ////////////////////////////////////////////////////////////////////
    // Test instance                                                  //
    ////////////////////////////////////////////////////////////////////
    public function testSelect01()
    {
        $ds          = new Dacapo(self::$db, self::$mc);
        $ds->setPgConnectForceNew(true);
        $sql         = 'SELECT * FROM test.customers';
        $bind_params = [];
        $ds->select($sql, $bind_params);
        $this->assertSame(
            0,
            $ds->getNumRows()
        );
    }
}
{'fraction_non_alphanumeric': 0.2399334442595674, 'fraction_numerical': 0.010482529118136439, 'mean_word_length': 1.300420972062763, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2332878', 'n_tokens_mistral': 1682, 'n_tokens_neox': 1598, 'n_words': 366}