fixed usage with moosified resultsets (RT#64773)
[chaz/p5-DBIx-Class-ResultSet-RecursiveUpdate] / t / lib / DBSchemaBase.pm
1 package DBSchemaBase;
2 use strict;
3 use warnings;
4
5 use base 'DBIx::Class::Schema';
6
7 sub tables_exist {
8 my $dbh = shift;
9 # assume that all tables exist if table dvd is found
10 return $dbh->tables( '%', '%', 'dvd' );
11 }
12
13 sub get_test_schema {
14 my ( $class, $dsn, $user, $pass ) = @_;
15 $dsn ||= 'dbi:SQLite:dbname=t/var/dvdzbr.db';
16 warn "testing $dsn\n";
17 my $schema = $class->connect( $dsn, $user, $pass, {} );
18 my $deploy_attrs;
19 $deploy_attrs->{add_drop_table} = 1 if tables_exist( $schema->storage->dbh );
20 $schema->deploy( $deploy_attrs );
21 $schema->populate('Personality', [
22 [ qw/user_id / ],
23 [ '1'],
24 [ '2' ],
25 [ '3'],
26 ]
27 );
28 $schema->populate('User', [
29 [ qw/username name password / ],
30 [ 'jgda', 'Jonas Alves', ''],
31 [ 'isa' , 'Isa', '', ],
32 [ 'zby' , 'Zbyszek Lukasiak', ''],
33 ]
34 );
35 $schema->populate('Tag', [
36 [ qw/name file / ],
37 [ 'comedy', '' ],
38 [ 'dramat', '' ],
39 [ 'australian', '' ],
40 ]
41 );
42 $schema->populate('Dvd', [
43 [ qw/name imdb_id owner current_borrower creation_date alter_date / ],
44 [ 'Picnick under the Hanging Rock', 123, 1, 3, '2003-01-16 23:12:01', undef ],
45 [ 'The Deerhunter', 1234, 1, 1, undef, undef ],
46 [ 'Rejs', 1235, 3, 1, undef, undef ],
47 [ 'Seksmisja', 1236, 3, 1, undef, undef ],
48 ]
49 );
50 $schema->populate( 'Dvdtag', [
51 [ qw/ dvd tag / ],
52 [ 1, 2 ],
53 [ 1, 3 ],
54 [ 3, 1 ],
55 [ 4, 1 ],
56 ]
57 );
58 return $schema;
59 }
60
61 1;
This page took 0.034719 seconds and 4 git commands to generate.