autoload DBI method
|
1 |
use Test::More 'no_plan'; |
packaging one directory
|
2 |
use strict; |
3 |
use warnings; |
|
updated version
|
4 |
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/}; |
packaging one directory
|
5 | |
6 |
use DBIx::Custom; |
|
fixed tests
|
7 |
use DBIx::Custom::QueryBuilder; |
packaging one directory
|
8 | |
9 |
# Function for test name |
|
10 |
my $test; |
|
table object call dbi object...
|
11 |
sub test { print "# $_[0]\n" } |
packaging one directory
|
12 | |
13 |
# Variables for test |
|
14 |
my $dbi; |
|
removed DBIx::Custom::Query ...
|
15 |
my $query_builder; |
packaging one directory
|
16 | |
17 |
test 'Constructor'; |
|
removed DBIx::Custom::Query ...
|
18 |
$query_builder = DBIx::Custom::QueryBuilder->new; |
packaging one directory
|
19 |
$dbi = DBIx::Custom->new( |
20 |
user => 'a', |
|
21 |
password => 'b', |
|
data_source is DEPRECATED! I...
|
22 |
dsn => 'c', |
packaging one directory
|
23 |
filters => { |
24 |
f => 3, |
|
25 |
}, |
|
cleanup
|
26 |
default_bind_filter => 'f', |
27 |
default_fetch_filter => 'g', |
|
packaging one directory
|
28 |
result_class => 'g', |
removed DBIx::Custom::Query ...
|
29 |
query_builder => $query_builder, |
packaging one directory
|
30 |
); |
fixed DEPRECATED messages
|
31 |
delete $dbi->{tags}; |
data_source is DEPRECATED! I...
|
32 |
is_deeply($dbi,{user => 'a', password => 'b', dsn => 'c', |
update document
|
33 |
filters => {f => 3}, default_bind_filter => 'f', |
cleanup
|
34 |
default_fetch_filter => 'g', result_class => 'g', |
cleanup
|
35 |
query_builder => $query_builder}); |
packaging one directory
|
36 |
isa_ok($dbi, 'DBIx::Custom'); |
37 | ||
38 | ||
39 |
test 'Sub class constructor'; |
|
40 |
{ |
|
41 |
package DBIx::Custom::T1; |
|
42 |
use base 'DBIx::Custom'; |
|
43 |
|
|
44 |
} |
|
45 |
$dbi = DBIx::Custom::T1->new( |
|
46 |
filters => { |
|
47 |
fo => 30, |
|
48 |
}, |
|
49 |
); |
|
cleanup
|
50 |
is_deeply(scalar $dbi->filters, {fo => 30}, "filters"); |
packaging one directory
|
51 | |
52 |
test 'Sub sub class constructor default'; |
|
53 |
{ |
|
54 |
package DBIx::Custom::T1_2; |
|
55 |
use base 'DBIx::Custom::T1'; |
|
56 |
} |
|
57 |
$dbi = DBIx::Custom::T1_2->new; |
|
58 |
isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
59 | ||
60 | ||
61 |
test 'Customized sub class constructor default'; |
|
62 |
{ |
|
63 |
package DBIx::Custom::T1_3; |
|
64 |
use base 'DBIx::Custom::T1'; |
|
65 |
|
|
66 |
} |
|
67 |
$dbi = DBIx::Custom::T1_3->new; |
|
68 |
isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
69 | ||
70 | ||
71 |
test 'Customized sub class constructor'; |
|
72 |
$dbi = DBIx::Custom::T1_3->new( |
|
73 |
filters => { |
|
74 |
f => 3, |
|
75 |
}, |
|
76 |
); |
|
cleanup
|
77 |
is_deeply($dbi->filters, {f => 3}, "filters"); |
packaging one directory
|
78 |
isa_ok($dbi, 'DBIx::Custom'); |
79 | ||
80 | ||
some changed
|
81 |
test 'register_filters'; |
packaging one directory
|
82 |
$dbi = DBIx::Custom->new; |
some changed
|
83 |
$dbi->register_filter(a => sub {1}); |
cleanup
|
84 |
is($dbi->filters->{a}->(), 1); |
changed argument of tag proc...
|
85 |
$dbi->register_filter({b => sub {2}}); |
cleanup
|
86 |
is($dbi->filters->{b}->(), 2); |
changed argument of tag proc...
|
87 | |
added dbi_options attribute
|
88 |
test 'invalid attribute name'; |
89 |
eval {$dbi = DBIx::Custom->new(a => 1) }; |
|
cleanup
|
90 |
like ($@, qr/name/); |