DBD-PO

 view release on metacpan or  search on metacpan

t/03_DBD-PO/06_obsolete.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 => 21 + 1;
use Test::NoWarnings;
use Test::Differences;

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

my $dbh;

# 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);
    }
}

# obsolete
{
    my $sth_update = $dbh->prepare(<<"EO_SQL");
        UPDATE $TABLE_0X
        SET    obsolete=?
        WHERE  msgid=?
EO_SQL
    isa_ok($sth_update, 'DBI::st', 'prepare update');

    my $sth_select = $dbh->prepare(<<"EO_SQL");
        SELECT obsolete
        FROM   $TABLE_0X
        WHERE  msgid=?
EO_SQL
    isa_ok($sth_select, 'DBI::st', 'prepare select');

    my @data = (
        {
            test     => 'obsolete=1, id_value1\nid_value2',
            id       => "id_value1${SEPARATOR}id_value2",
            set      => 1,
            get      => [1],
            callback => sub { check_file(shift, 1, 0) },
        },
        {
            test     => 'obsolete=0, id_value1\nid_value2',
            id       => "id_value1${SEPARATOR}id_value2",
            set      => 0,
            get      => [0],
            callback => sub { check_file(shift) },
        },
        {



( run in 0.692 second using v1.01-cache-2.11-cpan-5511b514fd6 )