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', |
|
version 0.0901
|
29 |
options => {d => 1, e => 2}, |
packaging one directory
|
30 |
filters => { |
31 |
f => 3, |
|
32 |
}, |
|
cleanup
|
33 |
default_bind_filter => 'f', |
34 |
default_fetch_filter => 'g', |
|
packaging one directory
|
35 |
result_class => 'g', |
removed register_format()
|
36 |
sql_template => $SQL_TMPL->{0}, |
packaging one directory
|
37 |
); |
38 |
is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c', |
|
cleanup
|
39 |
options => {d => 1, e => 2}, filters => {f => 3}, default_bind_filter => 'f', |
40 |
default_fetch_filter => 'g', result_class => 'g', |
|
removed register_format()
|
41 |
sql_template => $SQL_TMPL->{0}}, $test); |
packaging one directory
|
42 |
isa_ok($dbi, 'DBIx::Custom'); |
43 | ||
44 | ||
45 |
test 'Sub class constructor'; |
|
46 |
{ |
|
47 |
package DBIx::Custom::T1; |
|
48 |
use base 'DBIx::Custom'; |
|
49 |
|
|
50 |
__PACKAGE__ |
|
catch up with Object::Simple...
|
51 |
->filters({f => 3}) |
packaging one directory
|
52 |
; |
53 |
} |
|
54 |
$dbi = DBIx::Custom::T1->new( |
|
55 |
filters => { |
|
56 |
fo => 30, |
|
57 |
}, |
|
58 |
); |
|
59 |
is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters"); |
|
60 | ||
61 |
test 'Sub class constructor default'; |
|
62 |
$dbi = DBIx::Custom::T1->new; |
|
catch up with Object::Simple...
|
63 |
is_deeply($dbi->filters, {f => 3}, "$test : filters"); |
packaging one directory
|
64 |
isa_ok($dbi, 'DBIx::Custom::T1'); |
65 | ||
66 | ||
67 |
test 'Sub sub class constructor default'; |
|
68 |
{ |
|
69 |
package DBIx::Custom::T1_2; |
|
70 |
use base 'DBIx::Custom::T1'; |
|
71 |
} |
|
72 |
$dbi = DBIx::Custom::T1_2->new; |
|
73 |
is_deeply(scalar $dbi->filters, {f => 3}, "$test : filters"); |
|
74 |
isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
75 | ||
76 | ||
77 |
test 'Customized sub class constructor default'; |
|
78 |
{ |
|
79 |
package DBIx::Custom::T1_3; |
|
80 |
use base 'DBIx::Custom::T1'; |
|
81 |
|
|
82 |
__PACKAGE__ |
|
catch up with Object::Simple...
|
83 |
->filters({fo => 30}) |
packaging one directory
|
84 |
; |
85 |
} |
|
86 |
$dbi = DBIx::Custom::T1_3->new; |
|
87 |
is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters"); |
|
88 |
isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
89 | ||
90 | ||
91 |
test 'Customized sub class constructor'; |
|
92 |
$dbi = DBIx::Custom::T1_3->new( |
|
93 |
filters => { |
|
94 |
f => 3, |
|
95 |
}, |
|
96 |
); |
|
catch up with Object::Simple...
|
97 |
is_deeply($dbi->filters, {f => 3}, "$test : filters"); |
packaging one directory
|
98 |
isa_ok($dbi, 'DBIx::Custom'); |
99 | ||
100 | ||
some changed
|
101 |
test 'register_filters'; |
packaging one directory
|
102 |
$dbi = DBIx::Custom->new; |
some changed
|
103 |
$dbi->register_filter(a => sub {1}); |
packaging one directory
|
104 |
is($dbi->filters->{a}->(), 1, $test); |
105 | ||
version 0.0901
|
106 |
test 'Accessor'; |
107 |
$dbi = DBIx::Custom->new; |
|
catch up with Object::Simple...
|
108 |
$dbi->options({opt1 => 1, opt2 => 2}); |
version 0.0901
|
109 |
is_deeply(scalar $dbi->options, {opt1 => 1, opt2 => 2}, "$test : options"); |