File: bug_0001.t

package info (click to toggle)
libdbd-mock-perl 1.43-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 416 kB
  • sloc: perl: 1,135; makefile: 2
file content (38 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This is RT #15602
# The bug that was reported did not appear, but it did expose
# another bug with consecutive executes()

use strict;

use Test::More tests => 4;

use_ok('DBI');

my $dbh = DBI->connect( 'dbi:Mock:', '', '', { PrintError => 0 } );
isa_ok($dbh, 'DBI::db');

my $SQL = "select foo from bar where a = ? and b = ?";

my $s = DBD::Mock::Session->new("bugdemo",
    {
      statement=> $SQL,
      bound_params=>[1,2],
      results=>[['foo'],[1]]
    },
    {
      statement=> $SQL,
      bound_params=>[3,4],
      results=>[['foo'],[1]],
    },
);

$dbh->{mock_session} = $s;

my $sth=$dbh->prepare($SQL);
eval {
    ok( !$sth->execute(3,4), "Bind failed" );
    ok( $sth->execute(1,2), "Bind passed" );
};

# Shuts up warning when object is destroyed
undef $dbh->{mock_session};