fixup for stringify that can be false in find_or_create_related
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Setup.pm
index 9b64890..ddcad9c 100755 (executable)
@@ -1,30 +1,26 @@
 use strict;
 use warnings;
-use DBICTest::Schema;
+use DBICTest;
 
-my $db_file = "t/var/DBIxClass.db";
-
-unlink($db_file) if -e $db_file;
-unlink($db_file . "-journal") if -e $db_file . "-journal";
-mkdir("t/var") unless -d "t/var";
-
-my $dsn = "dbi:SQLite:${db_file}";
-
-my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn);
+my $schema = DBICTest->initialise;
 
 $schema->storage->on_connect_do([ "PRAGMA synchronous = OFF" ]);
 
 my $dbh = $schema->storage->dbh;
 
-open IN, "t/lib/sqlite.sql";
+if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
+  $schema->deploy;
+} else {
+  open IN, "t/lib/sqlite.sql";
 
-my $sql;
+  my $sql;
 
-{ local $/ = undef; $sql = <IN>; }
+  { local $/ = undef; $sql = <IN>; }
 
-close IN;
+  close IN;
 
-$dbh->do($_) for split(/\n\n/, $sql);
+  $dbh->do($_) for split(/\n\n/, $sql);
+}
 
 $schema->storage->dbh->do("PRAGMA synchronous = OFF");
 
@@ -103,11 +99,52 @@ $schema->populate('ArtistUndirectedMap', [
 $schema->populate('Producer', [
   [ qw/producerid name/ ],
   [ 1, 'Matt S Trout' ],
+  [ 2, 'Bob The Builder' ],
+  [ 3, 'Fred The Phenotype' ],
 ]);
 
 $schema->populate('CD_to_Producer', [
   [ qw/cd producer/ ],
   [ 1, 1 ],
+  [ 1, 2 ],
+  [ 1, 3 ],
+]);
+
+$schema->populate('TreeLike', [
+  [ qw/id parent name/ ],
+  [ 1, 0, 'foo'  ],
+  [ 2, 1, 'bar'  ],
+  [ 3, 2, 'baz'  ],
+  [ 4, 3, 'quux' ],
+]);
+
+$schema->populate('Track', [
+  [ qw/trackid cd  position title/ ],
+  [ 4, 2, 1, "Stung with Success"],
+  [ 5, 2, 2, "Stripy"],
+  [ 6, 2, 3, "Sticky Honey"],
+  [ 7, 3, 1, "Yowlin"],
+  [ 8, 3, 2, "Howlin"],
+  [ 9, 3, 3, "Fowlin"],
+  [ 10, 4, 1, "Boring Name"],
+  [ 11, 4, 2, "Boring Song"],
+  [ 12, 4, 3, "No More Ideas"],
+  [ 13, 5, 1, "Sad"],
+  [ 14, 5, 2, "Under The Weather"],
+  [ 15, 5, 3, "Suicidal"],
+  [ 16, 1, 1, "The Bees Knees"],
+  [ 17, 1, 2, "Apiary"],
+  [ 18, 1, 3, "Beehind You"],
+]);
+
+$schema->populate('Link', [
+  [ qw/id title/ ],
+  [ 1, 'aaa' ]
+]);
+
+$schema->populate('Bookmark', [
+  [ qw/id link/ ],
+  [ 1, 1 ]
 ]);
 
 1;