.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Test::MockDBI 3pm" .TH Test::MockDBI 3pm "2012-09-06" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::MockDBI \- Mocked DBI interface for testing purposes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Test::MockDBI; \& \& my $mi = Test::MockDBI::get_instance(); \& \& Sets a fake return value for the rows statementhandler \& $mi\->set_retval( method => rows, retval => sub{ return scalar( @somearray ); }); \& \& $mi\->set_retval( method => \*(Aqbind_param\*(Aq, retval => undef); \& Same as: \& $mi\->bad_method(\*(Aqbind_param\*(Aq); \& \& You can also specify return values for specific sqls \& $mi\->set_retval( method => rows, retval => sub{ return scalar( @somearray ); }, sql => \*(Aqselect id from names\*(Aq); \& \& $mi\->set_retval( method => \*(Aqbind_param\*(Aq, retval => undef, sql => \*(Aqselect id from names where id < ?\*(Aq); \& Same as: \& $mi\->bad_method(\*(Aqbind_param\*(Aq, \*(Aqselect id from names where id < ?\*(Aq); .Ve .SH "PUBLIC INTERFACE" .IX Header "PUBLIC INTERFACE" .Vb 1 \& Methods available on the Test::MockDBI instance. .Ve .IP "\fIreset()\fR" 4 .IX Item "reset()" .Vb 1 \& Method for reseting all mock returnvalues \e bad_params etc .Ve .IP "\fIbad_method()\fR" 4 .IX Item "bad_method()" .Vb 1 \& This method is basically a alias for calling set_retval with the return value undef. \& \& Args: \& $method_name \- The name of the method which should return undef \& $matching_sql (Optional) \- The sql matching condition \& \& Returns: \& On success: 1 \& On failure: undef \& \& The method also supports calling the method with the following arguments: \& $method_name, $dbi_testing_type, $matching_sql \& This will issue a warning as it is deprecated. .Ve .IP "\fIbad_param()\fR" 4 .IX Item "bad_param()" .Vb 3 \& Args: \& $p_value \- The value that will cause bind_param to return undef \& $sql (Optional) \- The sql matching condition \& \& Returns: \& On success: 1 \& On failure: undef \& \& The method also supports calling the method with the following arguments: \& $dbi_testing_type, $p_num, $p_value \& This will issue a warning as it is deprecated. .Ve .IP "\fIset_retval()\fR" 4 .IX Item "set_retval()" .Vb 1 \& Method for setting a return value for the specific method. \& \& Args:(Keys in a hash) \& method \- The method that should return the provided value \& retval \- The data which should be returned \& sql (Optional) \- Matching sql. The return value will only be \& returned for the provided method if the sql matches \& a regex compiled by using this string \& \& Returnvalues: \& On success: 1 \& On failure: undef \& \& Example usage: \& \& #fetchrow_hashref will shift one hashref from the list each time its called if the sql matches the sql provided, this will happend \& #until the return list is empty. \& $inst\->set_retval( method => \*(Aqfetchrow_hashref\*(Aq, \& retval => [ { letter => \*(Aqa\*(Aq }, { letter => \*(Aqb\*(Aq }, { letter => \*(Aqc\*(Aq } ], \& sql => \*(Aqselect * from letters\*(Aq ) \& \& #execute will default return undef \& $inst\->set_retval( method => \*(Aqexecute\*(Aq, retval => undef) \& \& #Execute will return 10 for sql \*(Aqselect * from cars\*(Aq \& $inst\->set_retval( method => \*(Aqexecute\*(Aq, retval => undef); \& $inst\->set_retval( method => \*(Aqexecute\*(Aq, retval => 10, sql => \*(Aqselect * from cars\*(Aq); .Ve .IP "\fIset_inout_value()\fR" 4 .IX Item "set_inout_value()" .Vb 3 \& Special method for handling inout params. \& In this method you can provided the value that the inout param should have \& after execute is called. \& \& Args: \& $sql \- The sql that this rule should apply for \& $p_num \- The parameter number of the inout parameter \& $value \- The value that the inout parameter should have after execute \& \& Returns: \& On success: 1 \& On failure: undef \& \& Example: .Ve .SH "PRIVATE INTERFACE" .IX Header "PRIVATE INTERFACE" .Vb 1 \& Methods used by the package internally. Should not be called from an external package. .Ve .IP "\fI_clear_dbi_err_errstr()\fR" 4 .IX Item "_clear_dbi_err_errstr()" .Vb 2 \& Helper method used by the fake DBI::st and DBI::db to clear out \& the $obj\->{err} and $obj\->{errstr} on each method call. \& \& Should not be called from an external script\epackage. .Ve .IP "\fI_set_dbi_err_errstr()\fR" 4 .IX Item "_set_dbi_err_errstr()" .Vb 3 \& Helper method used by the fake DBI::st and DBI::db to set the \& $obj\->{err}, $obj\->{errstr}, $DBI::err and $DBI::errstr. \& This method also handles RaiseError and PrintError attributes. \& \& Args: \& $obj \- Instance of DBI::st or DBI::db \& %args \- A hash with the following keys: \& err \- The numeric error code to be set \& errstr \- The user friendly DBI error message. \& \& Returns: \& On success : 1 \& On failure : undef .Ve .IP "_set_fake_dbi_err_errstr" 4 .IX Item "_set_fake_dbi_err_errstr" .PD 0 .IP "\fI_has_inout_value()\fR" 4 .IX Item "_has_inout_value()" .PD .Vb 3 \& Helper method used by the DBI::db and DBI::st packages. \& The method searches to see if there is specified a value for a \& inout variable. \& \& If called in SCALAR context it return 1/undef based on if the \& parameter bound as $p_num has a predefined return value set. \& \& If called in LIST context the method returns and array with \& 1/undef in position 0 which indicates the same as when the method \& is called in SCALAR context. The second element of the list is the \& value that should be applied to the inout parameter. .Ve .IP "\fI_has_fake_retval()\fR" 4 .IX Item "_has_fake_retval()" .Vb 3 \& Method for identifing if a method has a predefined return value set. \& If the SQL parameter is provided \& this will have precedence over the default value. \& \& If the method is called in SCALAR context it will return 1\eundef based on \& if the method has a predefined return value set. \& \& If the method is called in LIST context it will return a list with 1/undef at \& index 0 which indicates the same as when called in SCALAR context. index 1 will \& contain a reference to the actual return value that should be returned by the method. \& This value may be undef. .Ve .IP "\fI_is_bad_bind_param()\fR" 4 .IX Item "_is_bad_bind_param()" .Vb 2 \& Method for identifing if a bind parameters value is predefined as unwanted. \& The configuration for the provided SQL will have precedence over the default configured behaviour. \& \& When called it will return 1\eundef based on \& if the provided value should make the bind_param method fail. .Ve .SH "CLASS INTERFACE" .IX Header "CLASS INTERFACE" .IP "\fIget_instance()\fR" 4 .IX Item "get_instance()" .Vb 1 \& Method for retrieving the current Test::MockDBI instance .Ve .PP .Vb 2 \& This is basically a copy\epaste from the DBI package itself. \& The method is used inside the prepare_cached method .Ve .PP .Vb 2 \& This is basically a copy\epaste from the DBI package itself. \& The method is used inside the prepare_cached method .Ve .PP .Vb 2 \& This is basically a copy\epaste from the DBI package itself. \& The method is used inside the prepare_cached method .Ve .PP .Vb 1 \& Mocked DBI\->connect method. \& \& The method takes the same arguments as the usual DBI\->connect method. \& It returns a $dbh which has ref DBI::db .Ve .SH "AUTHOR" .IX Header "AUTHOR" Mark Leighton Fisher, .PP Minor modifications (version 0.62 onwards) by Andreas Faafeng .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright 2004, Fisher's Creek Consulting, \s-1LLC. \s0 Copyright 2004, DeepData, Inc. .SH "LICENSE" .IX Header "LICENSE" This code is released under the same licenses as Perl itself.