Debian Codegraph @

t/bug_015602.t

raw
1 # This is RT #15602
2 # The bug that was reported did not appear, but it did expose
3 # another bug with consecutive executes()
4
5 use 5.008;
6
7 use strict;
8 use warnings;
9
10 use Test::More;
11
12 use_ok('DBI');
13
14 my $dbh = DBI->connect( 'dbi:Mock:', '', '', { PrintError => 0 } );
15 isa_ok($dbh, 'DBI::db');
16
17 my $SQL = "select foo from bar where a = ? and b = ?";
18
19 my $s = DBD::Mock::Session->new("bugdemo",
20 {
21 statement=> $SQL,
22 bound_params=>[1,2],
23 results=>[['foo'],[1]]
24 },
25 {
26 statement=> $SQL,
27 bound_params=>[3,4],
28 results=>[['foo'],[1]],
29 },
30 );
31
32 $dbh->{mock_session} = $s;
33
34 my $sth=$dbh->prepare($SQL);
35 eval {
36 ok( !$sth->execute(3,4), "Bind failed" );
37 ok( $sth->execute(1,2), "Bind passed" );
38 };
39
40 # Shuts up warning when object is destroyed
41 undef $dbh->{mock_session};
42
43 done_testing();