DBIx-Custom / t / dbix-custom-core.t /
Newer Older
103 lines | 2.324kb
cleanup (removed undocumente...
yuki-kimoto authored on 2010-11-10
1
use Test::More tests => 11;
packaging one directory
yuki-kimoto authored on 2009-11-16
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
my $dbi;
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
16
my $query_builder;
packaging one directory
yuki-kimoto authored on 2009-11-16
17

            
18
test 'Constructor';
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
19
$query_builder = DBIx::Custom::QueryBuilder->new;
packaging one directory
yuki-kimoto authored on 2009-11-16
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
yuki-kimoto authored on 2010-04-28
28
    default_bind_filter => 'f',
29
    default_fetch_filter => 'g',
packaging one directory
yuki-kimoto authored on 2009-11-16
30
    result_class => 'g',
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
31
    query_builder => $query_builder,
packaging one directory
yuki-kimoto authored on 2009-11-16
32
);
33
is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c', 
update document
yuki-kimoto authored on 2010-05-27
34
                filters => {f => 3}, default_bind_filter => 'f',
cleanup
yuki-kimoto authored on 2010-04-28
35
                default_fetch_filter => 'g', result_class => 'g',
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
36
                query_builder => $query_builder}, $test);
packaging one directory
yuki-kimoto authored on 2009-11-16
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...
yuki-kimoto authored on 2010-01-18
78
is_deeply($dbi->filters, {f => 3}, "$test : filters");
packaging one directory
yuki-kimoto authored on 2009-11-16
79
isa_ok($dbi, 'DBIx::Custom');
80

            
81

            
some changed
yuki-kimoto authored on 2010-05-02
82
test 'register_filters';
packaging one directory
yuki-kimoto authored on 2009-11-16
83
$dbi = DBIx::Custom->new;
some changed
yuki-kimoto authored on 2010-05-02
84
$dbi->register_filter(a => sub {1});
packaging one directory
yuki-kimoto authored on 2009-11-16
85
is($dbi->filters->{a}->(), 1, $test);
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
86
$dbi->register_filter({b => sub {2}});
87
is($dbi->filters->{b}->(), 2, $test);
88

            
89

            
added experimental expand me...
yuki-kimoto authored on 2010-10-20
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