DBIx-Custom / t / dbix-custom-core.t /
Newer Older
106 lines | 2.394kb
packaging one directory
yuki-kimoto authored on 2009-11-16
1
use Test::More 'no_plan';
2
use strict;
3
use warnings;
4

            
5
use DBIx::Custom;
fixed tests
yuki-kimoto authored on 2010-08-06
6
use DBIx::Custom::QueryBuilder;
packaging one directory
yuki-kimoto authored on 2009-11-16
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
yuki-kimoto authored on 2010-08-06
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
yuki-kimoto authored on 2009-11-16
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
yuki-kimoto authored on 2010-04-28
31
    default_bind_filter => 'f',
32
    default_fetch_filter => 'g',
packaging one directory
yuki-kimoto authored on 2009-11-16
33
    result_class => 'g',
fixed tests
yuki-kimoto authored on 2010-08-06
34
    sql_builder => $SQL_TMPL->{0},
packaging one directory
yuki-kimoto authored on 2009-11-16
35
);
36
is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c', 
update document
yuki-kimoto authored on 2010-05-27
37
                filters => {f => 3}, default_bind_filter => 'f',
cleanup
yuki-kimoto authored on 2010-04-28
38
                default_fetch_filter => 'g', result_class => 'g',
fixed tests
yuki-kimoto authored on 2010-08-06
39
                sql_builder => $SQL_TMPL->{0}}, $test);
packaging one directory
yuki-kimoto authored on 2009-11-16
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...
yuki-kimoto authored on 2010-01-18
49
      ->filters({f => 3})
packaging one directory
yuki-kimoto authored on 2009-11-16
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...
yuki-kimoto authored on 2010-01-18
61
is_deeply($dbi->filters, {f => 3}, "$test : filters");
packaging one directory
yuki-kimoto authored on 2009-11-16
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...
yuki-kimoto authored on 2010-01-18
81
      ->filters({fo => 30})
packaging one directory
yuki-kimoto authored on 2009-11-16
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...
yuki-kimoto authored on 2010-01-18
95
is_deeply($dbi->filters, {f => 3}, "$test : filters");
packaging one directory
yuki-kimoto authored on 2009-11-16
96
isa_ok($dbi, 'DBIx::Custom');
97

            
98

            
some changed
yuki-kimoto authored on 2010-05-02
99
test 'register_filters';
packaging one directory
yuki-kimoto authored on 2009-11-16
100
$dbi = DBIx::Custom->new;
some changed
yuki-kimoto authored on 2010-05-02
101
$dbi->register_filter(a => sub {1});
packaging one directory
yuki-kimoto authored on 2009-11-16
102
is($dbi->filters->{a}->(), 1, $test);
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
103
$dbi->register_filter({b => sub {2}});
104
is($dbi->filters->{b}->(), 2, $test);
105

            
106