Retire DBIC/SqlMakerTest.pm now that SQLA::Test provides the same function
[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
8 my $ping_count = 0;
9
10 {
11   local $SIG{__WARN__} = sub {};
12   require DBIx::Class::Storage::DBI;
13
14   my $ping = \&DBIx::Class::Storage::DBI::_ping;
15
16   *DBIx::Class::Storage::DBI::_ping = sub {
17     $ping_count++;
18     goto &$ping;
19   };
20 }
21
22
23 # measure pings around deploy() separately
24 my $schema = DBICTest->init_schema( sqlite_use_file => 1, no_populate => 1 );
25
26 is ($ping_count, 0, 'no _ping() calls during deploy');
27 $ping_count = 0;
28
29
30
31 DBICTest->populate_schema ($schema);
32
33 # perform some operations and make sure they don't ping
34
35 $schema->resultset('CD')->create({
36   cdid => 6, artist => 3, title => 'mtfnpy', year => 2009
37 });
38
39 $schema->resultset('CD')->create({
40   cdid => 7, artist => 3, title => 'mtfnpy2', year => 2009
41 });
42
43 $schema->storage->_dbh->disconnect;
44
45 $schema->resultset('CD')->create({
46   cdid => 8, artist => 3, title => 'mtfnpy3', year => 2009
47 });
48
49 $schema->storage->_dbh->disconnect;
50
51 $schema->txn_do(sub {
52  $schema->resultset('CD')->create({
53    cdid => 9, artist => 3, title => 'mtfnpy4', year => 2009
54  });
55 });
56
57 is $ping_count, 0, 'no _ping() calls';
58
59 done_testing;