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 |
); |
data_source is DEPRECATED! I...
|
31 |
is_deeply($dbi,{user => 'a', password => 'b', dsn => 'c', |
update document
|
32 |
filters => {f => 3}, default_bind_filter => 'f', |
cleanup
|
33 |
default_fetch_filter => 'g', result_class => 'g', |
cleanup
|
34 |
query_builder => $query_builder}); |
packaging one directory
|
35 |
isa_ok($dbi, 'DBIx::Custom'); |
36 | ||
37 | ||
38 |
test 'Sub class constructor'; |
|
39 |
{ |
|
40 |
package DBIx::Custom::T1; |
|
41 |
use base 'DBIx::Custom'; |
|
42 |
|
|
43 |
} |
|
44 |
$dbi = DBIx::Custom::T1->new( |
|
45 |
filters => { |
|
46 |
fo => 30, |
|
47 |
}, |
|
48 |
); |
|
cleanup
|
49 |
is_deeply(scalar $dbi->filters, {fo => 30}, "filters"); |
packaging one directory
|
50 | |
51 |
test 'Sub sub class constructor default'; |
|
52 |
{ |
|
53 |
package DBIx::Custom::T1_2; |
|
54 |
use base 'DBIx::Custom::T1'; |
|
55 |
} |
|
56 |
$dbi = DBIx::Custom::T1_2->new; |
|
57 |
isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
58 | ||
59 | ||
60 |
test 'Customized sub class constructor default'; |
|
61 |
{ |
|
62 |
package DBIx::Custom::T1_3; |
|
63 |
use base 'DBIx::Custom::T1'; |
|
64 |
|
|
65 |
} |
|
66 |
$dbi = DBIx::Custom::T1_3->new; |
|
67 |
isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
68 | ||
69 | ||
70 |
test 'Customized sub class constructor'; |
|
71 |
$dbi = DBIx::Custom::T1_3->new( |
|
72 |
filters => { |
|
73 |
f => 3, |
|
74 |
}, |
|
75 |
); |
|
cleanup
|
76 |
is_deeply($dbi->filters, {f => 3}, "filters"); |
packaging one directory
|
77 |
isa_ok($dbi, 'DBIx::Custom'); |
78 | ||
79 | ||
some changed
|
80 |
test 'register_filters'; |
packaging one directory
|
81 |
$dbi = DBIx::Custom->new; |
some changed
|
82 |
$dbi->register_filter(a => sub {1}); |
cleanup
|
83 |
is($dbi->filters->{a}->(), 1); |
changed argument of tag proc...
|
84 |
$dbi->register_filter({b => sub {2}}); |
cleanup
|
85 |
is($dbi->filters->{b}->(), 2); |
changed argument of tag proc...
|
86 | |
added dbi_options attribute
|
87 |
test 'invalid attribute name'; |
88 |
eval {$dbi = DBIx::Custom->new(a => 1) }; |
|
cleanup
|
89 |
like ($@, qr/name/); |