Commit | Line | Data |
3ff1602f |
1 | use strict; |
492bb85a |
2 | use warnings; |
3ff1602f |
3 | |
492bb85a |
4 | use Test::More; |
3ff1602f |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | |
9 | my $schema = DBICTest->init_schema(); |
10 | my $storage = $schema->storage; |
11 | |
492bb85a |
12 | my @args; |
13 | my $test_func = sub { @args = @_ }; |
3ff1602f |
14 | |
492bb85a |
15 | $storage->dbh_do($test_func, "foo", "bar"); |
16 | is_deeply ( |
17 | \@args, |
18 | [ $storage, $storage->dbh, "foo", "bar" ], |
3ff1602f |
19 | ); |
20 | |
492bb85a |
21 | |
3ff1602f |
22 | my $storage_class = ref $storage; |
23 | { |
492bb85a |
24 | no strict 'refs'; |
25 | local *{$storage_class .'::__test_method'} = $test_func; |
26 | $storage->dbh_do("__test_method", "baz", "buz"); |
3ff1602f |
27 | } |
3ff1602f |
28 | |
492bb85a |
29 | is_deeply ( |
30 | \@args, |
31 | [ $storage, $storage->dbh, "baz", "buz" ], |
32 | ); |
33 | |
38ed54cd |
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 | |
492bb85a |
40 | done_testing; |