packaging one directory
|
1 |
use Test::More 'no_plan'; |
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; |
|
10 |
sub test { |
|
11 |
$test = shift; |
|
12 |
} |
|
13 | ||
14 |
# Variables for test |
|
15 |
our $SQL_TMPL = { |
|
fixed tests
|
16 |
0 => DBIx::Custom::QueryBuilder->new->tag_start(0), |
17 |
1 => DBIx::Custom::QueryBuilder->new->tag_start(1), |
|
18 |
2 => DBIx::Custom::QueryBuilder->new->tag_start(2) |
|
packaging one directory
|
19 |
}; |
20 |
my $dbi; |
|
21 | ||
22 |
test 'Constructor'; |
|
23 |
$dbi = DBIx::Custom->new( |
|
24 |
user => 'a', |
|
25 |
database => 'a', |
|
26 |
password => 'b', |
|
27 |
data_source => 'c', |
|
28 |
filters => { |
|
29 |
f => 3, |
|
30 |
}, |
|
cleanup
|
31 |
default_bind_filter => 'f', |
32 |
default_fetch_filter => 'g', |
|
packaging one directory
|
33 |
result_class => 'g', |
fixed tests
|
34 |
sql_builder => $SQL_TMPL->{0}, |
packaging one directory
|
35 |
); |
36 |
is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c', |
|
update document
|
37 |
filters => {f => 3}, default_bind_filter => 'f', |
cleanup
|
38 |
default_fetch_filter => 'g', result_class => 'g', |
fixed tests
|
39 |
sql_builder => $SQL_TMPL->{0}}, $test); |
packaging one directory
|
40 |
isa_ok($dbi, 'DBIx::Custom'); |
41 | ||
42 | ||
43 |
test 'Sub class constructor'; |
|
44 |
{ |
|
45 |
package DBIx::Custom::T1; |
|
46 |
use base 'DBIx::Custom'; |
|
47 |
|
|
48 |
__PACKAGE__ |
|
catch up with Object::Simple...
|
49 |
->filters({f => 3}) |
packaging one directory
|
50 |
; |
51 |
} |
|
52 |
$dbi = DBIx::Custom::T1->new( |
|
53 |
filters => { |
|
54 |
fo => 30, |
|
55 |
}, |
|
56 |
); |
|
57 |
is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters"); |
|
58 | ||
59 |
test 'Sub class constructor default'; |
|
60 |
$dbi = DBIx::Custom::T1->new; |
|
catch up with Object::Simple...
|
61 |
is_deeply($dbi->filters, {f => 3}, "$test : filters"); |
packaging one directory
|
62 |
isa_ok($dbi, 'DBIx::Custom::T1'); |
63 | ||
64 | ||
65 |
test 'Sub sub class constructor default'; |
|
66 |
{ |
|
67 |
package DBIx::Custom::T1_2; |
|
68 |
use base 'DBIx::Custom::T1'; |
|
69 |
} |
|
70 |
$dbi = DBIx::Custom::T1_2->new; |
|
71 |
is_deeply(scalar $dbi->filters, {f => 3}, "$test : filters"); |
|
72 |
isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
73 | ||
74 | ||
75 |
test 'Customized sub class constructor default'; |
|
76 |
{ |
|
77 |
package DBIx::Custom::T1_3; |
|
78 |
use base 'DBIx::Custom::T1'; |
|
79 |
|
|
80 |
__PACKAGE__ |
|
catch up with Object::Simple...
|
81 |
->filters({fo => 30}) |
packaging one directory
|
82 |
; |
83 |
} |
|
84 |
$dbi = DBIx::Custom::T1_3->new; |
|
85 |
is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters"); |
|
86 |
isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
87 | ||
88 | ||
89 |
test 'Customized sub class constructor'; |
|
90 |
$dbi = DBIx::Custom::T1_3->new( |
|
91 |
filters => { |
|
92 |
f => 3, |
|
93 |
}, |
|
94 |
); |
|
catch up with Object::Simple...
|
95 |
is_deeply($dbi->filters, {f => 3}, "$test : filters"); |
packaging one directory
|
96 |
isa_ok($dbi, 'DBIx::Custom'); |
97 | ||
98 | ||
some changed
|
99 |
test 'register_filters'; |
packaging one directory
|
100 |
$dbi = DBIx::Custom->new; |
some changed
|
101 |
$dbi->register_filter(a => sub {1}); |
packaging one directory
|
102 |
is($dbi->filters->{a}->(), 1, $test); |
changed argument of tag proc...
|
103 |
$dbi->register_filter({b => sub {2}}); |
104 |
is($dbi->filters->{b}->(), 2, $test); |
|
105 | ||
106 |