fix up txn_begin and the ping_count test
[dbsrgits/DBIx-Class.git] / t / 92storage_ping_count.t
CommitLineData
25546937 1use strict;
2use warnings;
3
4# Stolen from 76joins.t (a good test for this purpose)
5
6use Test::More;
7use lib qw(t/lib);
8use DBICTest;
9use Data::Dumper;
10use DBIC::SqlMakerTest;
11
28be49a6 12plan tests => 1;
13
25546937 14my $ping_count = 0;
15
e4697499 16my $schema = DBICTest->init_schema();
17
25546937 18{
19 local $SIG{__WARN__} = sub {};
20 require DBIx::Class::Storage::DBI;
21
22 my $ping = \&DBIx::Class::Storage::DBI::_ping;
23
24 *DBIx::Class::Storage::DBI::_ping = sub {
25 $ping_count++;
26 goto &$ping;
27 };
28}
29
28be49a6 30# perform some operations and make sure they don't ping
25546937 31
28be49a6 32$schema->resultset('CD')->create({
33 cdid => 6, artist => 3, title => 'mtfnpy', year => 2009
34});
25546937 35
28be49a6 36$schema->resultset('CD')->create({
37 cdid => 7, artist => 3, title => 'mtfnpy2', year => 2009
38});
25546937 39
28be49a6 40$schema->storage->_dbh->disconnect;
25546937 41
28be49a6 42$schema->resultset('CD')->create({
43 cdid => 8, artist => 3, title => 'mtfnpy3', year => 2009
44});
25546937 45
28be49a6 46$schema->storage->_dbh->disconnect;
25546937 47
28be49a6 48$schema->txn_do(sub {
49 $schema->resultset('CD')->create({
50 cdid => 9, artist => 3, title => 'mtfnpy4', year => 2009
51 });
52});
25546937 53
54is $ping_count, 0, 'no _ping() calls';