Fix documentation of search_related
[dbsrgits/DBIx-Class.git] / t / 74mssql.t
CommitLineData
70350518 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
eef2ff6c 7
8my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/};
9
10#warn "$dsn $user $pass";
11
70350518 12plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test'
eef2ff6c 13 unless ($dsn);
14
15plan tests => 4;
16
3885cff6 17DBICTest::Schema->storage_type('::DBI::MSSQL');
58d387fe 18DBICTest::Schema->compose_connection( 'MSSQLTest' => $dsn, $user, $pass );
eef2ff6c 19
20my $dbh = MSSQLTest->schema->storage->dbh;
21
22$dbh->do("IF OBJECT_ID('artist', 'U') IS NOT NULL
23 DROP TABLE artist");
24
25$dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(255));");
26
27MSSQLTest::Artist->load_components('PK::Auto::MSSQL');
28
29# Test PK
30my $new = MSSQLTest::Artist->create( { name => 'foo' } );
31ok($new->artistid, "Auto-PK worked");
32
33# Test LIMIT
34for (1..6) {
35 MSSQLTest::Artist->create( { name => 'Artist ' . $_ } );
36}
37
38my $it = MSSQLTest::Artist->search( { },
39 { rows => 3,
40 offset => 2,
41 order_by => 'artistid'
42 }
43);
44
45is( $it->count, 3, "LIMIT count ok" );
f48dd03f 46ok( $it->next->name, "iterator->next ok" );
eef2ff6c 47$it->next;
48$it->next;
49is( $it->next, undef, "next past end of resultset ok" );
50