File: 012_st_handle.t

package info (click to toggle)
libdbd-mock-perl 1.43-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 416 kB
  • sloc: perl: 1,135; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use strict;

use Test::More tests => 15;

BEGIN {
    use_ok('DBD::Mock');  
    use_ok('DBI');  
}

# test misc. attributes

{
    my $dbh = DBI->connect('DBI:Mock:', 'user', 'pass');
    isa_ok($dbh, 'DBI::db'); 
    
    $dbh->{mock_add_resultset} = [[ 'Foo', 'Bar', 'Baz' ],[ 1, 1, 1 ]];

    my $sth = eval { $dbh->prepare('SELECT Foo, Bar, Baz FROM FooBarBaz') };
    ok(!$@, '... $sth handle prepared ok');
    isa_ok($sth, 'DBI::st');

    is($sth->{Statement}, 'SELECT Foo, Bar, Baz FROM FooBarBaz', '... got the right statement');
    is($sth->{Database}, $dbh, '... got the right Database handle');

    is($sth->{NUM_OF_FIELDS}, 3, '... got the right number of fields');
    is($sth->{NUM_OF_PARAMS}, 0, '... got the right number of params');    

    is_deeply(
        $sth->{NAME},
        [ 'Foo', 'Bar', 'Baz' ],
        '... got the right NAME attributes');

    is_deeply(
        $sth->{NAME_lc},
        [ 'foo', 'bar', 'baz' ],
        '... got the right NAME_lc attributes');

    is_deeply(
        $sth->{NAME_uc},
        [ 'FOO', 'BAR', 'BAZ' ],
        '... got the right NAME_uc attributes');    
            
    is_deeply(
        $sth->{NAME_hash},
        { Foo => 0, Bar => 1, Baz => 2 },
        '... got the right NAME_hash attributes');
        
    is_deeply(
        $sth->{NAME_hash_lc},
        { foo => 0, bar => 1, baz => 2 },
        '... got the right NAME_hash_lc attributes');
        
    is_deeply(
        $sth->{NAME_hash_uc},
        { FOO => 0, BAR => 1, BAZ => 2 },
        '... got the right NAME_hash_uc attributes');                    
}