10 my $schema = DBICTest->init_schema();
14 $schema->storage->debugcb(sub { $cbworks = 1; });
15 $schema->storage->debug(0);
16 my $rs = $schema->resultset('CD')->search({});
18 ok(!$cbworks, 'Callback not called with debug disabled');
20 $schema->storage->debug(1);
23 ok($cbworks, 'Debug callback worked.');
25 my $prof = new DBIx::Test::Profiler();
26 $schema->storage->debugobj($prof);
28 # Test non-transaction calls.
30 ok($prof->{'query_start'}, 'query_start called');
31 ok($prof->{'query_end'}, 'query_end called');
32 ok(!$prof->{'txn_begin'}, 'txn_begin not called');
33 ok(!$prof->{'txn_commit'}, 'txn_commit not called');
37 # Test transaction calls
39 ok($prof->{'txn_begin'}, 'txn_begin called');
41 $rs = $schema->resultset('CD')->search({});
43 ok($prof->{'query_start'}, 'query_start called');
44 ok($prof->{'query_end'}, 'query_end called');
46 $schema->txn_commit();
47 ok($prof->{'txn_commit'}, 'txn_commit called');
53 $rs = $schema->resultset('CD')->search({});
55 $schema->txn_rollback();
56 ok($prof->{'txn_rollback'}, 'txn_rollback called');
58 $schema->storage->debug(0);
60 package DBIx::Test::Profiler;
69 $self->{'query_start'} = 1;
74 $self->{'query_end'} = 1;
79 $self->{'txn_begin'} = 1;
84 $self->{'txn_rollback'} = 1;
89 $self->{'txn_commit'} = 1;
95 $self->{'query_start'} = 0;
96 $self->{'query_end'} = 0;
97 $self->{'txn_begin'} = 0;
98 $self->{'txn_rollback'} = 0;
99 $self->{'txn_end'} = 0;