X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fdbh_do.t;h=1511f82e64b64b94e512c8360abd98c558b683e3;hb=f5f0cb1ddc5bc6b022f08a2cd95201596a5246f0;hp=eb8bd20bacc90fbf52f00d040405be5384b983a9;hpb=38ed54cd3980bd344e13fad27ed11b935ae932aa;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/storage/dbh_do.t b/t/storage/dbh_do.t index eb8bd20..1511f82 100644 --- a/t/storage/dbh_do.t +++ b/t/storage/dbh_do.t @@ -1,16 +1,30 @@ -#!/usr/bin/perl +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } use strict; use warnings; use Test::More; -use lib qw(t/lib); + use DBICTest; my $schema = DBICTest->init_schema(); my $storage = $schema->storage; +$storage = $storage->master + if $ENV{DBICTEST_VIA_REPLICATED}; + + +# test (re)connection +for my $disconnect (0, 1) { + $schema->storage->_dbh->disconnect if $disconnect; + is_deeply ( + $schema->storage->dbh_do(sub { $_[1]->selectall_arrayref('SELECT 1') }), + [ [ 1 ] ], + 'dbh_do on fresh handle worked', + ); +} + my @args; my $test_func = sub { @args = @_ }; @@ -33,9 +47,11 @@ is_deeply ( [ $storage, $storage->dbh, "baz", "buz" ], ); -# test aliasing +# test nested aliasing my $res = 'original'; -$storage->dbh_do (sub { $_[2] = 'changed' }, $res); +$schema->storage->dbh_do (sub { + shift->dbh_do(sub { $_[3] = 'changed' }, @_) +}, $res); is ($res, 'changed', "Arguments properly aliased for dbh_do");