8 eval "use DBD::SQLite";
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
17 my $schema = DBICTest->init_schema();
21 $schema->storage->debugcb(sub { $cbworks = 1; });
22 $schema->storage->debug(0);
23 my $rs = $schema->resultset('CD')->search({});
25 ok(!$cbworks, 'Callback not called with debug disabled');
27 $schema->storage->debug(1);
30 ok($cbworks, 'Debug callback worked.');
32 my $prof = new DBIx::Test::Profiler();
33 $schema->storage->debugobj($prof);
35 # Test non-transaction calls.
37 ok($prof->{'query_start'}, 'query_start called');
38 ok($prof->{'query_end'}, 'query_end called');
39 ok(!$prof->{'txn_begin'}, 'txn_begin not called');
40 ok(!$prof->{'txn_commit'}, 'txn_commit not called');
44 # Test transaction calls
46 ok($prof->{'txn_begin'}, 'txn_begin called');
48 $rs = $schema->resultset('CD')->search({});
50 ok($prof->{'query_start'}, 'query_start called');
51 ok($prof->{'query_end'}, 'query_end called');
53 $schema->txn_commit();
54 ok($prof->{'txn_commit'}, 'txn_commit called');
60 $rs = $schema->resultset('CD')->search({});
62 $schema->txn_rollback();
63 ok($prof->{'txn_rollback'}, 'txn_rollback called');
65 $schema->storage->debug(0);
67 package DBIx::Test::Profiler;
76 $self->{'query_start'} = 1;
81 $self->{'query_end'} = 1;
86 $self->{'txn_begin'} = 1;
91 $self->{'txn_rollback'} = 1;
96 $self->{'txn_commit'} = 1;
102 $self->{'query_start'} = 0;
103 $self->{'query_end'} = 0;
104 $self->{'txn_begin'} = 0;
105 $self->{'txn_rollback'} = 0;
106 $self->{'txn_end'} = 0;