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