Cleanup shebang lines of all maint/example scripts, remove from tests entirely
[dbsrgits/DBIx-Class.git] / t / storage / dbh_do.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8
9 my $schema = DBICTest->init_schema();
10 my $storage = $schema->storage;
11
12 my @args;
13 my $test_func = sub { @args = @_ };
14
15 $storage->dbh_do($test_func, "foo", "bar");
16 is_deeply (
17   \@args,
18   [ $storage, $storage->dbh, "foo", "bar" ],
19 );
20
21
22 my $storage_class = ref $storage;
23 {
24   no strict 'refs';
25   local *{$storage_class .'::__test_method'} = $test_func;
26   $storage->dbh_do("__test_method", "baz", "buz");
27 }
28
29 is_deeply (
30   \@args,
31   [ $storage, $storage->dbh, "baz", "buz" ],
32 );
33
34 # test aliasing
35 my $res = 'original';
36 $storage->dbh_do (sub { $_[2] = 'changed' }, $res);
37
38 is ($res, 'changed', "Arguments properly aliased for dbh_do");
39
40 done_testing;