Cleanup shebang lines of all maint/example scripts, remove from tests entirely
[dbsrgits/DBIx-Class.git] / t / storage / ping_count.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7 use DBIC::SqlMakerTest;
8
9 my $ping_count = 0;
10
11 {
12   local $SIG{__WARN__} = sub {};
13   require DBIx::Class::Storage::DBI;
14
15   my $ping = \&DBIx::Class::Storage::DBI::_ping;
16
17   *DBIx::Class::Storage::DBI::_ping = sub {
18     $ping_count++;
19     goto &$ping;
20   };
21 }
22
23
24 # measure pings around deploy() separately
25 my $schema = DBICTest->init_schema( sqlite_use_file => 1, no_populate => 1 );
26
27 is ($ping_count, 0, 'no _ping() calls during deploy');
28 $ping_count = 0;
29
30
31
32 DBICTest->populate_schema ($schema);
33
34 # perform some operations and make sure they don't ping
35
36 $schema->resultset('CD')->create({
37   cdid => 6, artist => 3, title => 'mtfnpy', year => 2009
38 });
39
40 $schema->resultset('CD')->create({
41   cdid => 7, artist => 3, title => 'mtfnpy2', year => 2009
42 });
43
44 $schema->storage->_dbh->disconnect;
45
46 $schema->resultset('CD')->create({
47   cdid => 8, artist => 3, title => 'mtfnpy3', year => 2009
48 });
49
50 $schema->storage->_dbh->disconnect;
51
52 $schema->txn_do(sub {
53  $schema->resultset('CD')->create({
54    cdid => 9, artist => 3, title => 'mtfnpy4', year => 2009
55  });
56 });
57
58 is $ping_count, 0, 'no _ping() calls';
59
60 done_testing;