Commit | Line | Data |
6c0ddbf7 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | my $schema = DBICTest->init_schema(); |
9 | |
b72d5dd3 |
10 | plan tests => 9; |
6c0ddbf7 |
11 | |
12 | { |
13 | my $cd_rc = $schema->resultset("CD")->result_class; |
14 | |
15 | my $artist_rs = $schema->resultset("Artist") |
16 | ->search_rs({}, {result_class => "IWillExplode"}); |
17 | is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class'); |
18 | |
19 | my $cd_rs = $artist_rs->related_resultset('cds'); |
20 | is($cd_rs->result_class, $cd_rc, 'Correct cd result_class'); |
b72d5dd3 |
21 | |
22 | my $cd_rs2 = $schema->resultset("Artist")->search_rs({})->related_resultset('cds'); |
23 | is($cd_rs->result_class, $cd_rc, 'Correct cd2 result_class'); |
24 | |
25 | my $cd_rs3 = $schema->resultset("Artist")->search_rs({},{})->related_resultset('cds'); |
26 | is($cd_rs->result_class, $cd_rc, 'Correct cd3 result_class'); |
6c0ddbf7 |
27 | |
b72d5dd3 |
28 | isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class'); |
6c0ddbf7 |
29 | } |
30 | |
31 | |
32 | { |
33 | my $cd_rc = $schema->resultset("CD")->result_class; |
34 | |
35 | my $artist_rs = $schema->resultset("Artist") |
b72d5dd3 |
36 | ->search_rs({}, {result_class => "IWillExplode"})->search({artistid => 1}); |
6c0ddbf7 |
37 | is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class'); |
38 | |
39 | my $cd_rs = $artist_rs->related_resultset('cds'); |
40 | is($cd_rs->result_class, $cd_rc, 'Correct cd result_class'); |
41 | |
42 | isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class'); |
b72d5dd3 |
43 | isa_ok(eval{ $cd_rs->search({ cdid => 1 })->first }, $cd_rc, 'Inflated into correct cd result_class'); |
6c0ddbf7 |
44 | } |