| 1 |
use 5.008; |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
|
| 6 |
use Test::More; |
| 7 |
|
| 8 |
BEGIN { |
| 9 |
use_ok('DBD::Mock'); |
| 10 |
use_ok('DBI'); |
| 11 |
} |
| 12 |
|
| 13 |
# test misc. attributes |
| 14 |
|
| 15 |
{ |
| 16 |
my $dbh = DBI->connect('DBI:Mock:', 'user', 'pass'); |
| 17 |
isa_ok($dbh, 'DBI::db'); |
| 18 |
|
| 19 |
$dbh->{mock_add_resultset} = [[ 'Foo', 'Bar', 'Baz' ],[ 1, 1, 1 ]]; |
| 20 |
|
| 21 |
my $sth = eval { $dbh->prepare('SELECT Foo, Bar, Baz FROM FooBarBaz') }; |
| 22 |
ok(!$@, '... $sth handle prepared ok'); |
| 23 |
isa_ok($sth, 'DBI::st'); |
| 24 |
|
| 25 |
is($sth->{Statement}, 'SELECT Foo, Bar, Baz FROM FooBarBaz', '... got the right statement'); |
| 26 |
is($sth->{Database}, $dbh, '... got the right Database handle'); |
| 27 |
|
| 28 |
is($sth->{NUM_OF_FIELDS}, 3, '... got the right number of fields'); |
| 29 |
is($sth->{NUM_OF_PARAMS}, 0, '... got the right number of params'); |
| 30 |
|
| 31 |
is_deeply( |
| 32 |
$sth->{NAME}, |
| 33 |
[ 'Foo', 'Bar', 'Baz' ], |
| 34 |
'... got the right NAME attributes'); |
| 35 |
|
| 36 |
is_deeply( |
| 37 |
$sth->{NAME_lc}, |
| 38 |
[ 'foo', 'bar', 'baz' ], |
| 39 |
'... got the right NAME_lc attributes'); |
| 40 |
|
| 41 |
is_deeply( |
| 42 |
$sth->{NAME_uc}, |
| 43 |
[ 'FOO', 'BAR', 'BAZ' ], |
| 44 |
'... got the right NAME_uc attributes'); |
| 45 |
|
| 46 |
is_deeply( |
| 47 |
$sth->{NAME_hash}, |
| 48 |
{ Foo => 0, Bar => 1, Baz => 2 }, |
| 49 |
'... got the right NAME_hash attributes'); |
| 50 |
|
| 51 |
is_deeply( |
| 52 |
$sth->{NAME_hash_lc}, |
| 53 |
{ foo => 0, bar => 1, baz => 2 }, |
| 54 |
'... got the right NAME_hash_lc attributes'); |
| 55 |
|
| 56 |
is_deeply( |
| 57 |
$sth->{NAME_hash_uc}, |
| 58 |
{ FOO => 0, BAR => 1, BAZ => 2 }, |
| 59 |
'... got the right NAME_hash_uc attributes'); |
| 60 |
} |
| 61 |
|
| 62 |
done_testing(); |