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