8 eval "use DBD::SQLite";
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
17 DBICTest->init_schema();
21 DBICTest->schema->storage->debugcb(sub { $cbworks = 1; });
22 DBICTest->schema->storage->debug(0);
23 my $rs = DBICTest::CD->search({});
25 ok(!$cbworks, 'Callback not called with debug disabled');
27 DBICTest->schema->storage->debug(1);
30 ok($cbworks, 'Debug callback worked.');
32 my $prof = new DBIx::Test::Profiler();
33 DBICTest->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
45 DBICTest->schema->txn_begin();
46 ok($prof->{'txn_begin'}, 'txn_begin called');
48 $rs = DBICTest::CD->search({});
50 ok($prof->{'query_start'}, 'query_start called');
51 ok($prof->{'query_end'}, 'query_end called');
53 DBICTest->schema->txn_commit();
54 ok($prof->{'txn_commit'}, 'txn_commit called');
59 DBICTest->schema->txn_begin();
60 $rs = DBICTest::CD->search({});
62 DBICTest->schema->txn_rollback();
63 ok($prof->{'txn_rollback'}, 'txn_rollback called');
65 DBICTest->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;