DBIx-Custom / t / dbix-custom-core.t /
Newer Older
88 lines | 1.938kb
autoload DBI method
Yuki Kimoto authored on 2011-01-26
1
use Test::More 'no_plan';
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;
table object call dbi object...
Yuki Kimoto authored on 2011-01-25
10
sub test { print "# $_[0]\n" }
packaging one directory
yuki-kimoto authored on 2009-11-16
11

            
12
# Variables for test
13
my $dbi;
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
14
my $query_builder;
packaging one directory
yuki-kimoto authored on 2009-11-16
15

            
16
test 'Constructor';
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
17
$query_builder = DBIx::Custom::QueryBuilder->new;
packaging one directory
yuki-kimoto authored on 2009-11-16
18
$dbi = DBIx::Custom->new(
19
    user => 'a',
20
    password => 'b',
21
    data_source => 'c',
22
    filters => {
23
        f => 3,
24
    },
cleanup
yuki-kimoto authored on 2010-04-28
25
    default_bind_filter => 'f',
26
    default_fetch_filter => 'g',
packaging one directory
yuki-kimoto authored on 2009-11-16
27
    result_class => 'g',
removed DBIx::Custom::Query ...
yuki-kimoto authored on 2010-08-12
28
    query_builder => $query_builder,
packaging one directory
yuki-kimoto authored on 2009-11-16
29
);
added dbi_options attribute
kimoto authored on 2010-12-20
30
is_deeply($dbi,{user => 'a', password => 'b', data_source => 'c', 
update document
yuki-kimoto authored on 2010-05-27
31
                filters => {f => 3}, default_bind_filter => 'f',
cleanup
yuki-kimoto authored on 2010-04-28
32
                default_fetch_filter => 'g', result_class => 'g',
cleanup
Yuki Kimoto authored on 2011-01-23
33
                query_builder => $query_builder});
packaging one directory
yuki-kimoto authored on 2009-11-16
34
isa_ok($dbi, 'DBIx::Custom');
35

            
36

            
37
test 'Sub class constructor';
38
{
39
    package DBIx::Custom::T1;
40
    use base 'DBIx::Custom';
41
    
42
}
43
$dbi = DBIx::Custom::T1->new(
44
    filters => {
45
        fo => 30,
46
    },
47
);
cleanup
Yuki Kimoto authored on 2011-01-23
48
is_deeply(scalar $dbi->filters, {fo => 30}, "filters");
packaging one directory
yuki-kimoto authored on 2009-11-16
49

            
50
test 'Sub sub class constructor default';
51
{
52
    package DBIx::Custom::T1_2;
53
    use base 'DBIx::Custom::T1';
54
}
55
$dbi = DBIx::Custom::T1_2->new;
56
isa_ok($dbi, 'DBIx::Custom::T1_2');
57

            
58

            
59
test 'Customized sub class constructor default';
60
{
61
    package DBIx::Custom::T1_3;
62
    use base 'DBIx::Custom::T1';
63
    
64
}
65
$dbi = DBIx::Custom::T1_3->new;
66
isa_ok($dbi, 'DBIx::Custom::T1_3');
67

            
68

            
69
test 'Customized sub class constructor';
70
$dbi = DBIx::Custom::T1_3->new(
71
    filters => {
72
        f => 3,
73
    },
74
);
cleanup
Yuki Kimoto authored on 2011-01-23
75
is_deeply($dbi->filters, {f => 3}, "filters");
packaging one directory
yuki-kimoto authored on 2009-11-16
76
isa_ok($dbi, 'DBIx::Custom');
77

            
78

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

            
added dbi_options attribute
kimoto authored on 2010-12-20
86
test 'invalid attribute name';
87
eval {$dbi = DBIx::Custom->new(a => 1) };
cleanup
Yuki Kimoto authored on 2011-01-23
88
like ($@, qr/"a" is invalid attribute name/);