12 my $schema = DBICTest->init_schema();
16 $schema->storage->debugcb(sub { $cbworks = 1; });
17 $schema->storage->debug(0);
18 my $rs = $schema->resultset('CD')->search({});
20 ok(!$cbworks, 'Callback not called with debug disabled');
22 $schema->storage->debug(1);
25 ok($cbworks, 'Debug callback worked.');
27 my $prof = new DBIx::Test::Profiler();
28 $schema->storage->debugobj($prof);
30 # Test non-transaction calls.
32 ok($prof->{'query_start'}, 'query_start called');
33 ok($prof->{'query_end'}, 'query_end called');
34 ok(!$prof->{'txn_begin'}, 'txn_begin not called');
35 ok(!$prof->{'txn_commit'}, 'txn_commit not called');
39 # Test transaction calls
41 ok($prof->{'txn_begin'}, 'txn_begin called');
43 $rs = $schema->resultset('CD')->search({});
45 ok($prof->{'query_start'}, 'query_start called');
46 ok($prof->{'query_end'}, 'query_end called');
48 $schema->txn_commit();
49 ok($prof->{'txn_commit'}, 'txn_commit called');
55 $rs = $schema->resultset('CD')->search({});
57 $schema->txn_rollback();
58 ok($prof->{'txn_rollback'}, 'txn_rollback called');
60 $schema->storage->debug(0);
62 package DBIx::Test::Profiler;
71 $self->{'query_start'} = 1;
76 $self->{'query_end'} = 1;
81 $self->{'txn_begin'} = 1;
86 $self->{'txn_rollback'} = 1;
91 $self->{'txn_commit'} = 1;
97 $self->{'query_start'} = 0;
98 $self->{'query_end'} = 0;
99 $self->{'txn_begin'} = 0;
100 $self->{'txn_rollback'} = 0;
101 $self->{'txn_end'} = 0;