The most important changes in version 0.62 include:
Expected output:# tmd.t use strict; use warnings; # Enable testing with Test::MockDBI BEGIN { push @ARGV, "--dbitest"; } use Test::More; use Test::MockDBI qw( :all ); plan tests => 4; my $md = Test::MockDBI::get_instance(); my $dbh = DBI->connect("", "", ""); # Set of return values for given sql query my $aref_of_hrefs = [ { name => 'Huey', instrument => 'cello' }, { name => 'Dewey', instrument => 'trombone' }, { name => 'Louie', instrument => 'piano' }, ]; $md->set_retval_scalar( MOCKDBI_WILDCARD, "select name, instrument from nephews", sub { shift @$aref_of_hrefs } ); # Execute the sql query and fetch results $dbh->prepare("select name, instrument from nephews"); is_deeply( $dbh->fetchrow_hashref(), { name => 'Huey', instrument => 'cello' }, q{Expect Huey on the cello} ); is_deeply( $dbh->fetchrow_hashref(), { name => 'Dewey', instrument => 'trombone' }, q{Expect Dewey on the trombone} ); is_deeply( $dbh->fetchrow_hashref(), { name => 'Louie', instrument => 'piano' }, q{Expect Louie on the piano} ); ok(!$dbh->fetchrow_hashref(), q{Expect no more than 3 rows}); __END__
$ perl tmd.t 1..4 ok 1 - Expect Huey on the cello ok 2 - Expect Dewey on the trombone ok 3 - Expect Louie on the piano ok 4 - Expect no more than 3 rows $ prove tmd.t tmd....ok All tests successful. Files=1, Tests=4, 0 wallclock secs ( 0.07 cusr + 0.01 csys = 0.08 C +PU)
In reply to Test::MockDBI 0.62 released by andreas1234567
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |