Commit | Line | Data |
731e8b3e |
1 | # DBIx::Class::Schema::ResultSetAccessors - check module loading and create testing directory |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use lib qw(t/lib); |
7 | |
8 | use Test::More; |
9 | use Test::Exception; |
10 | |
11 | BEGIN { |
12 | use_ok('MyApp1::Schema'); |
13 | } |
14 | |
15 | ok my $schema1 = MyApp1::Schema->connect('dbi:SQLite:dbname=:memory:', '', ''), |
16 | 'Got schema 1'; |
17 | |
18 | isa_ok $schema1->resultset('Artist'), 'DBIx::Class::ResultSet'; |
867277b3 |
19 | can_ok $schema1, qw/cds artists liner_notes/; |
731e8b3e |
20 | isa_ok $schema1->artists, 'DBIx::Class::ResultSet'; # generic resultset |
21 | isa_ok $schema1->cds, 'MyApp1::Schema::ResultSet::CD'; # custom ResultSet |
22 | |
23 | # overwrite the accessor name with resultset_accessor_name() |
24 | can_ok $schema1, qw/source_resultset/; |
25 | isa_ok $schema1->source_resultset, 'DBIx::Class::ResultSet'; |
26 | |
27 | throws_ok { |
28 | # must use required, because for some reason throws_ok cannot catch |
29 | # erros with "use" |
30 | require MyApp2::Schema; |
31 | MyApp2::Schema->connect('dbi:SQLite:dbname=:memory:', '', ''); |
32 | } qr/Schema method with the same name already exists/, |
33 | 'Schema method with the same name already exists'; |
34 | |
35 | done_testing; |