cleanup (removed undocumente...
|
1 |
use Test::More tests => 11; |
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; |
|
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 |
} |
|
46 |
$dbi = DBIx::Custom::T1->new( |
|
47 |
filters => { |
|
48 |
fo => 30, |
|
49 |
}, |
|
50 |
); |
|
51 |
is_deeply(scalar $dbi->filters, {fo => 30}, "$test : filters"); |
|
52 | ||
53 |
test 'Sub sub class constructor default'; |
|
54 |
{ |
|
55 |
package DBIx::Custom::T1_2; |
|
56 |
use base 'DBIx::Custom::T1'; |
|
57 |
} |
|
58 |
$dbi = DBIx::Custom::T1_2->new; |
|
59 |
isa_ok($dbi, 'DBIx::Custom::T1_2'); |
|
60 | ||
61 | ||
62 |
test 'Customized sub class constructor default'; |
|
63 |
{ |
|
64 |
package DBIx::Custom::T1_3; |
|
65 |
use base 'DBIx::Custom::T1'; |
|
66 |
|
|
67 |
} |
|
68 |
$dbi = DBIx::Custom::T1_3->new; |
|
69 |
isa_ok($dbi, 'DBIx::Custom::T1_3'); |
|
70 | ||
71 | ||
72 |
test 'Customized sub class constructor'; |
|
73 |
$dbi = DBIx::Custom::T1_3->new( |
|
74 |
filters => { |
|
75 |
f => 3, |
|
76 |
}, |
|
77 |
); |
|
catch up with Object::Simple...
|
78 |
is_deeply($dbi->filters, {f => 3}, "$test : filters"); |
packaging one directory
|
79 |
isa_ok($dbi, 'DBIx::Custom'); |
80 | ||
81 | ||
some changed
|
82 |
test 'register_filters'; |
packaging one directory
|
83 |
$dbi = DBIx::Custom->new; |
some changed
|
84 |
$dbi->register_filter(a => sub {1}); |
packaging one directory
|
85 |
is($dbi->filters->{a}->(), 1, $test); |
changed argument of tag proc...
|
86 |
$dbi->register_filter({b => sub {2}}); |
87 |
is($dbi->filters->{b}->(), 2, $test); |
|
88 | ||
89 | ||
added experimental expand me...
|
90 |
test 'expand'; |
91 |
{ |
|
92 |
$dbi = DBIx::Custom->new; |
|
93 |
my $source = {books => {title => 'Perl', author => 'Ken'}}; |
|
94 |
is_deeply({$dbi->expand($source)}, |
|
95 |
{'books.title' => 'Perl', 'books.author' => 'Ken'}); |
|
96 |
} |
|
97 |
{ |
|
98 |
$dbi = DBIx::Custom->new; |
|
99 |
my %source = (books => {title => 'Perl', author => 'Ken'}); |
|
100 |
is_deeply({$dbi->expand(%source)}, |
|
101 |
{'books.title' => 'Perl', 'books.author' => 'Ken'}); |
|
102 |
} |
|
103 |