#!perl -w
$|=1;
BEGIN {
plan
skip_all
=>
'$h->{Kids} attribute not supported for DBI::PurePerl'
if
$DBI::PurePerl
&&
$DBI::PurePerl
;
plan
tests
=> 20;
}
my
$dbh
= DBI->
connect
(
'dbi:ExampleP:dummy'
,
''
,
''
,
{
PrintError
=> 1,
RaiseError
=> 0
});
isa_ok(
$dbh
,
'DBI::db'
);
cmp_ok(
$dbh
->{Kids},
'=='
, 0,
'... database handle has 0 Kid(s) at start'
);
cmp_ok(
$dbh
->{ActiveKids},
'=='
, 0,
'... database handle has 0 ActiveKid(s) at start'
);
do
{
my
$sth
=
$dbh
->prepare(
'select uid from ./'
);
isa_ok(
$sth
,
"DBI::st"
);
cmp_ok(
$dbh
->{Kids},
'=='
, 1,
'... database handle has 1 Kid(s) after $dbh->prepare'
);
cmp_ok(
$dbh
->{ActiveKids},
'=='
, 0,
'... database handle has 0 ActiveKid(s) after $dbh->prepare'
);
$sth
->execute();
cmp_ok(
$dbh
->{Kids},
'=='
, 1,
'... database handle has 1 Kid(s) after $sth->execute'
);
cmp_ok(
$dbh
->{ActiveKids},
'=='
, 1,
'... database handle has 1 ActiveKid(s) after $sth->execute'
);
$sth
->finish();
cmp_ok(
$dbh
->{Kids},
'=='
, 1,
'... database handle has 1 Kid(s) after $sth->finish'
);
cmp_ok(
$dbh
->{ActiveKids},
'=='
, 0,
'... database handle has 0 ActiveKid(s) after $sth->finish'
);
};
cmp_ok(
$dbh
->{Kids},
'=='
, 0,
'... database handle has 0 Kid(s) after $sth is destroyed'
);
cmp_ok(
$dbh
->{ActiveKids},
'=='
, 0,
'... database handle has 0 ActiveKid(s) after $sth is destroyed'
);
my
$drh
=
$dbh
->{Driver};
isa_ok(
$drh
,
"DBI::dr"
);
cmp_ok(
$drh
->{Kids},
'=='
, 1,
'... driver handle has 1 Kid(s)'
);
cmp_ok(
$drh
->{ActiveKids},
'=='
, 1,
'... driver handle has 1 ActiveKid(s)'
);
$dbh
->disconnect;
cmp_ok(
$drh
->{Kids},
'=='
, 1,
'... driver handle has 1 Kid(s) after $dbh->disconnect'
);
cmp_ok(
$drh
->{ActiveKids},
'=='
, 0,
'... driver handle has 0 ActiveKid(s) after $dbh->disconnect'
);
undef
$dbh
;
ok(!
defined
(
$dbh
),
'... lets be sure that $dbh is not undefined'
);
cmp_ok(
$drh
->{Kids},
'=='
, 0,
'... driver handle has 0 Kid(s) after undef $dbh'
);
cmp_ok(
$drh
->{ActiveKids},
'=='
, 0,
'... driver handle has 0 ActiveKid(s) after undef $dbh'
);