Added $schema->populate
[dbsrgits/DBIx-Class-Historic.git] / t / lib / DBICTest / Setup.pm
CommitLineData
4d9d84d5 1use strict;
2use warnings;
3use DBICTest::Schema;
4
5my $db_file = "t/var/DBIxClass.db";
6
7unlink($db_file) if -e $db_file;
8unlink($db_file . "-journal") if -e $db_file . "-journal";
9mkdir("t/var") unless -d "t/var";
10
11my $dsn = "dbi:SQLite:${db_file}";
12
13my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn);
14
a37a4697 15$schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]);
4d9d84d5 16
a37a4697 17my $dbh = $schema->storage->dbh;
4d9d84d5 18
0009fa49 19open IN, "t/lib/sqlite.sql";
20
a37a4697 21my $sql;
22
23{ local $/ = undef; $sql = <IN>; }
0009fa49 24
25close IN;
26
4d9d84d5 27$dbh->do($_) for split(/\n\n/, $sql);
28
29$schema->storage->dbh->do("PRAGMA synchronous = OFF");
30
a37a4697 31$schema->populate('Artist', [
32 [ qw/artistid name/ ],
33 [ 1, 'Caterwauler McCrae' ],
34 [ 2, 'Random Boy Band' ],
35 [ 3, 'We Are Goth' ],
36]);
37
38$schema->populate('CD', [
39 [ qw/cdid artist title year/ ],
40 [ 1, 1, "Spoonful of bees", 1999 ],
41 [ 2, 1, "Forkful of bees", 2001 ],
42 [ 3, 1, "Caterwaulin' Blues", 1997 ],
43 [ 4, 2, "Generic Manufactured Singles", 2001 ],
44 [ 5, 3, "Come Be Depressed With Us", 1998 ],
45]);
46
47$schema->populate('LinerNotes', [
48 [ qw/liner_id notes/ ],
49 [ 2, "Buy Whiskey!" ],
50 [ 4, "Buy Merch!" ],
51 [ 5, "Kill Yourself!" ],
52]);
53
54$schema->populate('Tag', [
55 [ qw/tagid cd tag/ ],
56 [ 1, 1, "Blue" ],
57 [ 2, 2, "Blue" ],
58 [ 3, 3, "Blue" ],
59 [ 4, 5, "Blue" ],
60 [ 5, 2, "Cheesy" ],
61 [ 6, 4, "Cheesy" ],
62 [ 7, 5, "Cheesy" ],
63 [ 8, 2, "Shiny" ],
64 [ 9, 4, "Shiny" ],
65]);
66
67$schema->populate('TwoKeys', [
68 [ qw/artist cd/ ],
69 [ 1, 1 ],
70 [ 1, 2 ],
71 [ 2, 2 ],
72]);
73
74$schema->populate('FourKeys', [
75 [ qw/foo bar hello goodbye/ ],
76 [ 1, 2, 3, 4 ],
77 [ 5, 4, 3, 6 ],
78]);
79
80$schema->populate('OneKey', [
81 [ qw/id artist cd/ ],
82 [ 1, 1, 1 ],
83 [ 2, 1, 2 ],
84 [ 3, 2, 2 ],
85]);
86
87$schema->populate('SelfRef', [
88 [ qw/id name/ ],
89 [ 1, 'First' ],
90 [ 2, 'Second' ],
91]);
92
93$schema->populate('SelfRefAlias', [
94 [ qw/self_ref alias/ ],
95 [ 1, 2 ]
96]);
97
98$schema->populate('ArtistUndirectedMap', [
99 [ qw/id1 id2/ ],
100 [ 1, 2 ]
101]);
102
103$schema->populate('Producer', [
104 [ qw/producerid name/ ],
105 [ 1, 'Matt S Trout' ],
106]);
107
108$schema->populate('CD_to_Producer', [
109 [ qw/cd producer/ ],
110 [ 1, 1 ],
111]);
0009fa49 112
a37a4697 1131;