1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
10 my $schema = DBICTest->init_schema();
13 my $cds_rs_2000 = $schema->resultset('CD')->search( { year => 2000 });
14 my $year2kcds_rs = $schema->resultset('Year2000CDs');
16 is($cds_rs_2000->count, $year2kcds_rs->count, 'View Year2000CDs sees all CDs in year 2000');
20 my $cds_rs_1999 = $schema->resultset('CD')->search( { year => 1999 });
21 my $year1999cds_rs = $schema->resultset('Year1999CDs');
23 is($cds_rs_1999->count, $year1999cds_rs->count, 'View Year1999CDs sees all CDs in year 1999');
26 # Test if relationships work correctly
29 $schema->resultset('Year1999CDs')->search (
32 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
33 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
34 order_by => 'tracks.trackid',
39 $schema->resultset('CD')->search (
40 { 'me.year' => '1999'},
42 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
43 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
44 columns => [qw/cdid single_track title/], # to match the columns retrieved by the virtview
45 order_by => 'tracks.trackid',
49 'Prefetch over virtual view gives expected result',
54 $schema->resultset('Year2000CDs')->search (
57 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
58 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
63 $schema->resultset('CD')->search (
64 { 'me.year' => '2000'},
66 result_class => 'DBIx::Class::ResultClass::HashRefInflator',
67 prefetch => ['artist', { tracks => [qw/cd year1999cd year2000cd/] } ],
71 'Prefetch over regular view gives expected result',