#!perl -w
use_ok(
'Database::test5'
);
my
$test5
= new_ok(
'Database::test5'
=> [
directory
=>
"$Bin/../data"
]);
cmp_ok(
$test5
->Name(101),
'eq'
,
'John Doe'
,
'CSV AUTOLOAD works found'
);
my
$res
=
$test5
->fetchrow_hashref(
entry
=>
'102'
);
if
(
$ENV
{
'TEST_VERBOSE'
}) {
diag(Data::Dumper->new([\
$res
])->Dump());
}
cmp_ok(
$res
->{
'ID'
},
'=='
,
'102'
,
'fetchrow_hashref'
);
cmp_ok(
$res
->{
'Age'
},
'=='
, 35,
'fetchrow_hashref'
);
my
@all_records
=
$test5
->selectall_hash();
diag(Data::Dumper->new([\
@all_records
])->Dump())
if
(
$ENV
{
'TEST_VERBOSE'
});
is(
scalar
@all_records
, 5,
'Fetched all records'
);
my
$john_doe
=
$test5
->fetchrow_hashref(
id
=> 101);
is(
$john_doe
->{
'name'
},
'John Doe'
,
'Fetched John Doe'
);
my
@young_people
=
$test5
->execute(
query
=>
'SELECT * FROM test5 WHERE age < 30'
);
is(
scalar
(
@young_people
), 2,
'Fetched young people'
);
my
@names
=
$test5
->name();
is(
scalar
(
@names
), 5,
'Fetched all names'
);