Update to hide modules from the PAUSE Indexer.
[dbsrgits/DBIx-Class.git] / t / testlib / MyBase.pm
1 package # hide from PAUSE
2     MyBase;
3
4 use strict;
5 use base qw(DBIx::Class);
6
7 use vars qw/$dbh/;
8
9 my @connect = ("dbi:mysql:test", "", "");
10
11 $dbh = DBI->connect(@connect) or die DBI->errstr;
12 my @table;
13
14 END { $dbh->do("DROP TABLE $_") foreach @table }
15
16 __PACKAGE__->connection(@connect);
17
18 sub set_table {
19         my $class = shift;
20         $class->table($class->create_test_table);
21 }
22
23 sub create_test_table {
24         my $self   = shift;
25         my $table  = $self->next_available_table;
26         my $create = sprintf "CREATE TABLE $table ( %s )", $self->create_sql;
27         push @table, $table;
28         $dbh->do($create);
29         return $table;
30 }
31
32 sub next_available_table {
33         my $self   = shift;
34         my @tables = sort @{
35                 $dbh->selectcol_arrayref(
36                         qq{
37     SHOW TABLES
38   }
39                 )
40                 };
41         my $table = $tables[-1] || "aaa";
42         return "z$table";
43 }
44
45 1;