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