Debian Codegraph @

t/bug_082243.t

raw
1 # This is test for bug rt#82243 - Bug with Regex in DBD::Mock::Session
2 use 5.008;
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 BEGIN {
10 use_ok('DBD::Mock');
11 use_ok('DBI');
12 }
13
14 {
15 my $dbh = DBI->connect('dbi:Mock:', '', '', { RaiseError => 1, PrintError => 0 });
16 isa_ok($dbh, 'DBI::db');
17
18 my $session = DBD::Mock::Session->new((
19 {
20 statement => 'SELECT bar FROM foo WHERE baz = ?',
21 bound_params => [ qr/^125$/ ],
22 results => [[ 'bar' ], [ 15 ]]
23 },
24 ));
25 isa_ok($session, 'DBD::Mock::Session');
26
27 $dbh->{mock_session} = $session;
28
29 my $sth = $dbh->prepare('SELECT bar FROM foo WHERE baz = ?');
30 $sth->execute(125);
31 my ($result) = $sth->fetchrow_array();
32 is($result, 15, 'Regex matching on bound_params should work as expected.');
33
34 # Shuts up warning when object is destroyed
35 undef $dbh->{mock_session};
36 }
37
38 done_testing();