diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2012-06-06 16:41:29 +0000 |
---|---|---|
committer | Lorry <lorry@roadtrain.codethink.co.uk> | 2012-09-26 13:46:50 +0000 |
commit | 7c48e67cf07ee41bfde7139a62bb232bd23a4a48 (patch) | |
tree | 6d7686b5075bd5cba253dabf2e6c302acb3a147c /t/43prof_env.t | |
download | perl-dbi-tarball-master.tar.gz |
Diffstat (limited to 't/43prof_env.t')
-rw-r--r-- | t/43prof_env.t | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/t/43prof_env.t b/t/43prof_env.t new file mode 100644 index 0000000..6726cf7 --- /dev/null +++ b/t/43prof_env.t @@ -0,0 +1,52 @@ +#!perl -w +$|=1; + +use strict; + +# +# test script for using DBI_PROFILE env var to enable DBI::Profile +# and testing non-ref assignments to $h->{Profile} +# + +BEGIN { $ENV{DBI_PROFILE} = 6 } # prior to use DBI + +use DBI; +use DBI::Profile; +use Config; +use Data::Dumper; + +BEGIN { + if ($DBI::PurePerl) { + print "1..0 # Skipped: profiling not supported for DBI::PurePerl\n"; + exit 0; + } +} + +use Test::More tests => 11; + +DBI->trace(0, "STDOUT"); + +my $dbh1 = DBI->connect("dbi:ExampleP:", '', '', { RaiseError=>1 }); +is(ref $dbh1->{Profile}, "DBI::Profile"); +is(ref $dbh1->{Profile}{Data}, 'HASH'); +is(ref $dbh1->{Profile}{Path}, 'ARRAY'); + +my $dbh2 = DBI->connect("dbi:ExampleP:", '', '', { RaiseError=>1 }); +is(ref $dbh2->{Profile}, "DBI::Profile"); +is(ref $dbh2->{Profile}{Data}, 'HASH'); +is(ref $dbh2->{Profile}{Path}, 'ARRAY'); + +is $dbh1->{Profile}, $dbh2->{Profile}, '$h->{Profile} should be shared'; + +$dbh1->do("set dummy=1"); +$dbh1->do("set dummy=2"); + +my $profile = $dbh1->{Profile}; + +my $p_data = $profile->{Data}; +is keys %$p_data, 3; # '', $sql1, $sql2 +ok $p_data->{''}; +ok $p_data->{"set dummy=1"}; +ok $p_data->{"set dummy=2"}; + +__END__ |