DBIx-Custom / t / dbix-custom-core.t /
Newer Older
89 lines | 1.962kb
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;
updated version
Yuki Kimoto authored on 2011-06-07
4
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
packaging one directory
yuki-kimoto authored on 2009-11-16
5

            
6
use DBIx::Custom;
fixed tests
yuki-kimoto authored on 2010-08-06
7
use DBIx::Custom::QueryBuilder;
packaging one directory
yuki-kimoto authored on 2009-11-16
8

            
9
# Function for test name
10
my $test;
table object call dbi object...
Yuki Kimoto authored on 2011-01-25
11
sub test { print "# $_[0]\n" }
packaging one directory
yuki-kimoto authored on 2009-11-16
12

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

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

            
37

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

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

            
59

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

            
69

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

            
79

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

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