Merge 'reorganize_tests' into 'DBIx-Class-current'
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema.pm
CommitLineData
bab77431 1package # hide from PAUSE
c6d74d3e 2 DBICTest::Schema;
a02675cd 3
4use base qw/DBIx::Class::Schema/;
5
5ce32fc1 6no warnings qw/qw/;
7
a02675cd 8__PACKAGE__->load_classes(qw/
5ce32fc1 9 Artist
4e298a80 10 Employee
5ce32fc1 11 CD
9c2c91ea 12 Link
13 Bookmark
18bd469b 14 #Casecheck
5ce32fc1 15 #dummy
16 Track
17 Tag
18 /,
19 { 'DBICTest::Schema' => [qw/
20 LinerNotes
21 OneKey
22 #dummy
23 TwoKeys
9fcda149 24 Serialized
5ce32fc1 25 /]},
26 (
27 'FourKeys',
28 '#dummy',
29 'SelfRef',
5efe4c79 30 'ArtistUndirectedMap',
bab77431 31 'ArtistSourceName',
7411204b 32 'Producer',
33 'CD_to_Producer',
5ce32fc1 34 ),
f86fcf0d 35 qw/SelfRefAlias TreeLike TwoKeyTreeLike Event/
5ce32fc1 36);
a02675cd 37
4b8dcc58 38sub deploy {
39 my $self = shift;
40
41 if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
42 return $schema->next::method(@_);
43 } else {
44 open IN, "t/lib/sqlite.sql";
45 my $sql;
46 { local $/ = undef; $sql = <IN>; }
47 close IN;
48 $self->storage->dbh->do($_) for split(/;\n/, $sql);
49 }
50}
51
52sub auto_populate {
53 my $self = shift;
54
55 $self->storage->dbh->do("PRAGMA synchronous = OFF");
56
57 $self->populate('Artist', [
58 [ qw/artistid name/ ],
59 [ 1, 'Caterwauler McCrae' ],
60 [ 2, 'Random Boy Band' ],
61 [ 3, 'We Are Goth' ],
62 ]);
63
64 $self->populate('CD', [
65 [ qw/cdid artist title year/ ],
66 [ 1, 1, "Spoonful of bees", 1999 ],
67 [ 2, 1, "Forkful of bees", 2001 ],
68 [ 3, 1, "Caterwaulin' Blues", 1997 ],
69 [ 4, 2, "Generic Manufactured Singles", 2001 ],
70 [ 5, 3, "Come Be Depressed With Us", 1998 ],
71 ]);
72
73 $self->populate('LinerNotes', [
74 [ qw/liner_id notes/ ],
75 [ 2, "Buy Whiskey!" ],
76 [ 4, "Buy Merch!" ],
77 [ 5, "Kill Yourself!" ],
78 ]);
79
80 $self->populate('Tag', [
81 [ qw/tagid cd tag/ ],
82 [ 1, 1, "Blue" ],
83 [ 2, 2, "Blue" ],
84 [ 3, 3, "Blue" ],
85 [ 4, 5, "Blue" ],
86 [ 5, 2, "Cheesy" ],
87 [ 6, 4, "Cheesy" ],
88 [ 7, 5, "Cheesy" ],
89 [ 8, 2, "Shiny" ],
90 [ 9, 4, "Shiny" ],
91 ]);
92
93 $self->populate('TwoKeys', [
94 [ qw/artist cd/ ],
95 [ 1, 1 ],
96 [ 1, 2 ],
97 [ 2, 2 ],
98 ]);
99
100 $self->populate('FourKeys', [
101 [ qw/foo bar hello goodbye/ ],
102 [ 1, 2, 3, 4 ],
103 [ 5, 4, 3, 6 ],
104 ]);
105
106 $self->populate('OneKey', [
107 [ qw/id artist cd/ ],
108 [ 1, 1, 1 ],
109 [ 2, 1, 2 ],
110 [ 3, 2, 2 ],
111 ]);
112
113 $self->populate('SelfRef', [
114 [ qw/id name/ ],
115 [ 1, 'First' ],
116 [ 2, 'Second' ],
117 ]);
118
119 $self->populate('SelfRefAlias', [
120 [ qw/self_ref alias/ ],
121 [ 1, 2 ]
122 ]);
123
124 $self->populate('ArtistUndirectedMap', [
125 [ qw/id1 id2/ ],
126 [ 1, 2 ]
127 ]);
128
129 $self->populate('Producer', [
130 [ qw/producerid name/ ],
131 [ 1, 'Matt S Trout' ],
132 [ 2, 'Bob The Builder' ],
133 [ 3, 'Fred The Phenotype' ],
134 ]);
135
136 $self->populate('CD_to_Producer', [
137 [ qw/cd producer/ ],
138 [ 1, 1 ],
139 [ 1, 2 ],
140 [ 1, 3 ],
141 ]);
142
143 $self->populate('TreeLike', [
144 [ qw/id parent name/ ],
145 [ 1, 0, 'foo' ],
146 [ 2, 1, 'bar' ],
147 [ 3, 2, 'baz' ],
148 [ 4, 3, 'quux' ],
149 ]);
150
151 $self->populate('Track', [
152 [ qw/trackid cd position title/ ],
153 [ 4, 2, 1, "Stung with Success"],
154 [ 5, 2, 2, "Stripy"],
155 [ 6, 2, 3, "Sticky Honey"],
156 [ 7, 3, 1, "Yowlin"],
157 [ 8, 3, 2, "Howlin"],
158 [ 9, 3, 3, "Fowlin"],
159 [ 10, 4, 1, "Boring Name"],
160 [ 11, 4, 2, "Boring Song"],
161 [ 12, 4, 3, "No More Ideas"],
162 [ 13, 5, 1, "Sad"],
163 [ 14, 5, 2, "Under The Weather"],
164 [ 15, 5, 3, "Suicidal"],
165 [ 16, 1, 1, "The Bees Knees"],
166 [ 17, 1, 2, "Apiary"],
167 [ 18, 1, 3, "Beehind You"],
168 ]);
169
170 $self->populate('Link', [
171 [ qw/id title/ ],
172 [ 1, 'aaa' ]
173 ]);
174
175 $self->populate('Bookmark', [
176 [ qw/id link/ ],
177 [ 1, 1 ]
178 ]);
179}
180
a02675cd 1811;