DBIx-Custom / t / dbix-custom-core.t /
Newer Older
90 lines | 1.983kb
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
);
fixed DEPRECATED messages
Yuki Kimoto authored on 2011-06-08
31
delete $dbi->{tags};
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
32
is_deeply($dbi,{user => 'a', password => 'b', dsn => 'c', 
update document
yuki-kimoto authored on 2010-05-27
33
                filters => {f => 3}, default_bind_filter => 'f',
cleanup
yuki-kimoto authored on 2010-04-28
34
                default_fetch_filter => 'g', result_class => 'g',
cleanup
Yuki Kimoto authored on 2011-01-23
35
                query_builder => $query_builder});
packaging one directory
yuki-kimoto authored on 2009-11-16
36
isa_ok($dbi, 'DBIx::Custom');
37

            
38

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

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

            
60

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

            
70

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

            
80

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

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