3 no warnings qw/once redefine/;
8 use Test::More tests => 9;
10 my $schema = DBICTest->init_schema(
15 local *DBIx::Class::Storage::DBI::connect_call_foo = sub {
16 isa_ok $_[0], 'DBIx::Class::Storage::DBI',
17 'got storage in connect_call method';
18 is $_[1], 'bar', 'got param in connect_call method';
21 local *DBIx::Class::Storage::DBI::disconnect_call_foo = sub {
22 isa_ok $_[0], 'DBIx::Class::Storage::DBI',
23 'got storage in disconnect_call method';
26 ok $schema->connection(
30 [ do_sql => 'create table test1 (id integer)' ],
31 [ do_sql => [ 'insert into test1 values (?)', {}, 1 ] ],
32 [ do_sql => sub { ['insert into test1 values (2)'] } ],
33 [ sub { $_[0]->dbh->do($_[1]) }, 'insert into test1 values (3)' ],
36 on_connect_do => 'insert into test1 values (4)',
37 on_disconnect_call => 'foo',
42 $schema->storage->dbh->selectall_arrayref('select * from test1'),
43 [ [ 1 ], [ 2 ], [ 3 ], [ 4 ] ],
44 'on_connect_call/do actions worked'
47 local *DBIx::Class::Storage::DBI::connect_call_foo = sub {
48 isa_ok $_[0], 'DBIx::Class::Storage::DBI',
49 'got storage in connect_call method';
52 local *DBIx::Class::Storage::DBI::connect_call_bar = sub {
53 isa_ok $_[0], 'DBIx::Class::Storage::DBI',
54 'got storage in connect_call method';
57 $schema->storage->disconnect;
59 ok $schema->connection(
63 on_connect_call => [ 'foo', sub { ok 1, "coderef in list form" }, 'bar' ],
67 $schema->storage->ensure_connected;