9 my $schema = DBICTest->init_schema();
12 my $cds_rs_2000 = $schema->resultset('CD')->search( { year => 2000 });
13 my $year2kcds_rs = $schema->resultset('Year2000CDs');
15 is($cds_rs_2000->count, $year2kcds_rs->count, 'View Year2000CDs sees all CDs in year 2000');
19 my $cds_rs_1999 = $schema->resultset('CD')->search( { year => 1999 });
20 my $year1999cds_rs = $schema->resultset('Year1999CDs');
22 is($cds_rs_1999->count, $year1999cds_rs->count, 'View Year1999CDs sees all CDs in year 1999');
25 # Test if relationships work correctly
28 $schema->resultset('Year1999CDs')->search (
31 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
32 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
37 $schema->resultset('CD')->search (
38 { 'me.year' => '1999'},
40 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
41 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
42 columns => [qw/cdid single_track title/], # to match the columns retrieved by the virtview
46 'Prefetch over virtual view gives expected result',
51 $schema->resultset('Year2000CDs')->search (
54 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
55 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
60 $schema->resultset('CD')->search (
61 { 'me.year' => '2000'},
63 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
64 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
68 'Prefetch over regular view gives expected result',