]> Dogcows Code - chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate/blobdiff - t/lib/DBSchemaBase.pm
fixed usage with moosified resultsets (RT#64773)
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / t / lib / DBSchemaBase.pm
diff --git a/t/lib/DBSchemaBase.pm b/t/lib/DBSchemaBase.pm
new file mode 100644 (file)
index 0000000..5b19a6e
--- /dev/null
@@ -0,0 +1,61 @@
+package DBSchemaBase;
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Schema';
+
+sub tables_exist {
+    my $dbh = shift;
+    # assume that all tables exist if table dvd is found
+    return $dbh->tables( '%', '%', 'dvd' );
+}
+
+sub get_test_schema {
+    my ( $class, $dsn, $user, $pass ) = @_;
+    $dsn ||= 'dbi:SQLite:dbname=t/var/dvdzbr.db';
+    warn "testing $dsn\n";
+    my $schema = $class->connect( $dsn, $user, $pass, {} );
+    my $deploy_attrs;
+    $deploy_attrs->{add_drop_table} = 1 if tables_exist( $schema->storage->dbh );
+    $schema->deploy( $deploy_attrs );
+    $schema->populate('Personality', [
+        [ qw/user_id / ],
+        [ '1'],
+        [ '2' ],
+        [ '3'],
+        ]
+    );
+    $schema->populate('User', [
+        [ qw/username name password / ],
+        [ 'jgda', 'Jonas Alves', ''],
+        [ 'isa' , 'Isa', '', ],
+        [ 'zby' , 'Zbyszek Lukasiak', ''],
+        ]
+    );
+    $schema->populate('Tag', [
+        [ qw/name file / ],
+        [ 'comedy', '' ],
+        [ 'dramat', '' ],
+        [ 'australian', '' ],
+        ]
+    );
+    $schema->populate('Dvd', [
+        [ qw/name imdb_id owner current_borrower creation_date alter_date / ],
+        [ 'Picnick under the Hanging Rock', 123, 1, 3, '2003-01-16 23:12:01', undef ],
+        [ 'The Deerhunter', 1234, 1, 1, undef, undef ],
+        [ 'Rejs', 1235, 3, 1, undef, undef ],
+        [ 'Seksmisja', 1236, 3, 1, undef, undef ],
+        ]
+    );
+    $schema->populate( 'Dvdtag', [
+        [ qw/ dvd tag / ],
+        [ 1, 2 ],
+        [ 1, 3 ],
+        [ 3, 1 ],
+        [ 4, 1 ],
+        ]
+    );
+    return $schema;
+}
+
+1;
This page took 0.021179 seconds and 4 git commands to generate.