9 my $schema = DBICTest->init_schema();
14 my $cd_rc = $schema->resultset("CD")->result_class;
17 $schema->resultset("Artist")
18 ->search_rs({}, {result_class => "IWillExplode"})
19 } qr/Can't locate IWillExplode/, 'nonexistant result_class exception';
21 # to make ensure_class_loaded happy, dies on inflate
22 eval 'package IWillExplode; sub dummy {}';
24 my $artist_rs = $schema->resultset("Artist")
25 ->search_rs({}, {result_class => "IWillExplode"});
26 is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class');
29 $artist_rs->result_class('mtfnpy')
30 } qr/Can't locate mtfnpy/,
31 'nonexistant result_access exception (from accessor)';
35 } qr/Can't locate object method "inflate_result" via package "IWillExplode"/,
36 'IWillExplode explodes on inflate';
38 my $cd_rs = $artist_rs->related_resultset('cds');
39 is($cd_rs->result_class, $cd_rc, 'Correct cd result_class');
41 my $cd_rs2 = $schema->resultset("Artist")->search_rs({})->related_resultset('cds');
42 is($cd_rs->result_class, $cd_rc, 'Correct cd2 result_class');
44 my $cd_rs3 = $schema->resultset("Artist")->search_rs({},{})->related_resultset('cds');
45 is($cd_rs->result_class, $cd_rc, 'Correct cd3 result_class');
47 isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class');
52 my $cd_rc = $schema->resultset("CD")->result_class;
54 my $artist_rs = $schema->resultset("Artist")
55 ->search_rs({}, {result_class => "IWillExplode"})->search({artistid => 1});
56 is($artist_rs->result_class, 'IWillExplode', 'Correct artist result_class');
58 my $cd_rs = $artist_rs->related_resultset('cds');
59 is($cd_rs->result_class, $cd_rc, 'Correct cd result_class');
61 isa_ok(eval{ $cd_rs->find(1) }, $cd_rc, 'Inflated into correct cd result_class');
62 isa_ok(eval{ $cd_rs->search({ cdid => 1 })->first }, $cd_rc, 'Inflated into correct cd result_class');