Nuked _select_columns, the last vestige of class-based evil
[dbsrgits/DBIx-Class.git] / t / run / 11mysql.tl
CommitLineData
0567538f 1sub run_tests {
1edaf6fe 2my $schema = shift;
0567538f 3
4my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/};
5
6#warn "$dsn $user $pass";
7
8plan skip_all, 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'
9 unless ($dsn && $user);
10
11plan tests => 4;
12
70fe6d6e 13DBICTest::Schema->compose_connection('MySQLTest' => $dsn, $user, $pass);
0567538f 14
15my $dbh = MySQLTest::Artist->storage->dbh;
16
17$dbh->do("DROP TABLE IF EXISTS artist;");
18
19$dbh->do("CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255));");
20
21#'dbi:mysql:host=localhost;database=dbic_test', 'dbic_test', '');
22
23MySQLTest::Artist->load_components('PK::Auto::MySQL');
24
25# test primary key handling
26my $new = MySQLTest::Artist->create({ name => 'foo' });
27ok($new->artistid, "Auto-PK worked");
28
29# test LIMIT support
30for (1..6) {
31 MySQLTest::Artist->create({ name => 'Artist ' . $_ });
32}
33my $it = MySQLTest::Artist->search( {},
34 { rows => 3,
35 offset => 2,
36 order_by => 'artistid' }
37);
38is( $it->count, 3, "LIMIT count ok" );
39is( $it->next->name, "Artist 2", "iterator->next ok" );
40$it->next;
41$it->next;
42is( $it->next, undef, "next past end of resultset ok" );
43
44# clean up our mess
45$dbh->do("DROP TABLE artist");
46
47}
48
491;