Add all database connections via DBICTest::Schema to the leaktrace pool
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema.pm
CommitLineData
bab77431 1package # hide from PAUSE
c6d74d3e 2 DBICTest::Schema;
a02675cd 3
65d35121 4use strict;
5use warnings;
6no warnings 'qw';
a02675cd 7
65d35121 8use base 'DBIx::Class::Schema';
9
10use DBICTest::Util qw/populate_weakregistry assert_empty_weakregistry/;
11use namespace::clean;
5ce32fc1 12
71829446 13__PACKAGE__->mk_group_accessors(simple => 'custom_attr');
14
a02675cd 15__PACKAGE__->load_classes(qw/
5ce32fc1 16 Artist
b829910c 17 SequenceTest
6ec7d1bb 18 BindType
4e298a80 19 Employee
5ce32fc1 20 CD
370f2ba2 21 Genre
9c2c91ea 22 Bookmark
97c96475 23 Link
5ce32fc1 24 #dummy
25 Track
26 Tag
a648ec78 27 Year2000CDs
1ee9aa72 28 Year1999CDs
b8b55c8e 29 CustomSql
818ec409 30 Money
4d4dc518 31 TimestampPrimaryKey
5ce32fc1 32 /,
33 { 'DBICTest::Schema' => [qw/
34 LinerNotes
4f6386b0 35 Artwork
d5633096 36 Artwork_to_Artist
4f6386b0 37 Image
38 Lyrics
39 LyricVersion
5ce32fc1 40 OneKey
41 #dummy
42 TwoKeys
9fcda149 43 Serialized
5ce32fc1 44 /]},
45 (
46 'FourKeys',
3bd6e3e0 47 'FourKeys_to_TwoKeys',
5ce32fc1 48 '#dummy',
49 'SelfRef',
5efe4c79 50 'ArtistUndirectedMap',
bab77431 51 'ArtistSourceName',
b1fb2c94 52 'ArtistSubclass',
7411204b 53 'Producer',
54 'CD_to_Producer',
181c0934 55 'Dummy', # this is a real result class we remove in the hook below
5ce32fc1 56 ),
dda9af55 57 qw/SelfRefAlias TreeLike TwoKeyTreeLike Event EventTZ NoPrimaryKey/,
a7e65bb5 58 qw/Collection CollectionObject TypedObject Owners BooksInLibrary/,
6e6b37a7 59 qw/ForceForeign Encoded/,
5ce32fc1 60);
a02675cd 61
d6c79cb3 62sub sqlt_deploy_hook {
63 my ($self, $sqlt_schema) = @_;
64
458e0292 65 $sqlt_schema->drop_table('dummy');
d6c79cb3 66}
67
65d35121 68my $weak_registry = {};
69
70sub clone {
71 my $self = shift->next::method(@_);
72 populate_weakregistry ( $weak_registry, $self )
73 if $INC{'Test/Builder.pm'};
74 $self;
75}
76
6892eb09 77sub connection {
78 my $self = shift->next::method(@_);
6918c70e 79
80 if ($INC{'Test/Builder.pm'}) {
81 populate_weakregistry ( $weak_registry, $self->storage );
82
83 my $cur_connect_call = $self->storage->on_connect_call;
84
85 $self->storage->on_connect_call([
86 (ref $cur_connect_call eq 'ARRAY'
87 ? @$cur_connect_call
88 : ($cur_connect_call || ())
89 ),
90 [sub {
91 populate_weakregistry( $weak_registry, shift->_dbh )
92 }],
93 ]);
94 }
95
6892eb09 96 $self;
97}
98
65d35121 99END {
100 assert_empty_weakregistry($weak_registry, 'quiet');
101}
102
a02675cd 1031;