DBD-PO

 view release on metacpan or  search on metacpan

t/03_DBD-PO/02_fill_table.t  view on Meta::CPAN

#!perl 
#!perl -T

use strict;
use warnings;

use Carp qw(croak);
use English qw(-no_match_vars $OS_ERROR $INPUT_RECORD_SEPARATOR);
use Test::DBD::PO::Defaults qw(
    $PATH $TRACE $SEPARATOR $EOL
    trace_file_name $TABLE_0X $FILE_0X
);
use Test::More tests => 15 + 1;
use Test::NoWarnings;
use Test::Differences;

BEGIN {
    require_ok('DBI');
    require_ok('DBD::PO'); DBD::PO->init(':plural');
}

my ($dbh, $sth);

# connext
{
    $dbh = DBI->connect(
        "dbi:PO:f_dir=$PATH;po_charset=utf-8",
        undef,
        undef,
        {
            RaiseError => 1,
            PrintError => 0,
            AutoCommit => 1,
        },
    );
    isa_ok($dbh, 'DBI::db', 'connect');

    if ($TRACE) {
        open my $file, '>', trace_file_name();
        $dbh->trace(4, $file);
    }
}

# full row
{
    $sth = $dbh->prepare(<<"EO_SQL");
        INSERT INTO $TABLE_0X (
            msgid,
            msgstr,
            msgctxt,
            reference,
            comment,
            automatic
        ) VALUES (?, ?, ?, ?, ?, ?)
EO_SQL
    isa_ok($sth, 'DBI::st', 'prepare insert');

    my $result = $sth->execute(qw(
        id_value
        str_value
        context_value
        ref_value
        comment_value
        automatic_value
    ));
    is($result, 1, "insert full row");
}

# full row, all are arrays
{
    my $result = $sth->execute(
        "id_value1${SEPARATOR}id_value2",
        "str_value1${SEPARATOR}str_value2",
        "context_value1${SEPARATOR}context_value2",
        "ref_value1${SEPARATOR}ref_value2",



( run in 0.895 second using v1.01-cache-2.11-cpan-5a3173703d6 )