10 my $schema = DBICTest->init_schema();
11 my $rs = $schema->resultset('Artist');
15 my ($crap, $girl) = $rs->populate( [
16 { artistid => 4, name => 'Manufactured Crap', cds => [
17 { title => 'My First CD', year => 2006 },
18 { title => 'Yet More Tweeny-Pop crap', year => 2007 },
21 { artistid => 5, name => 'Angsty-Whiny Girl', cds => [
22 { title => 'My parents sold me to a record company' ,year => 2005 },
23 { title => 'Why Am I So Ugly?', year => 2006 },
24 { title => 'I Got Surgery and am now Popular', year => 2007 }
28 { name => 'Like I Give a Damn' }
32 isa_ok( $crap, 'DBICTest::Artist', "Got 'Artist'");
33 isa_ok( $girl, 'DBICTest::Artist', "Got 'Artist'");
35 ok( $crap->name eq 'Manufactured Crap', "Got Correct name for result object");
36 ok( $girl->name eq 'Angsty-Whiny Girl', "Got Correct name for result object");
38 use Data::Dump qw/dump/;
40 ok( $crap->cds->count == 2, "got Expected Number of Cds");
41 ok( $girl->cds->count == 3, "got Expected Number of Cds");
47 { artistid => 4, name => 'Manufactured Crap', cds => [
48 { title => 'My First CD', year => 2006 },
49 { title => 'Yet More Tweeny-Pop crap', year => 2007 },
52 { artistid => 5, name => 'Angsty-Whiny Girl', cds => [
53 { title => 'My parents sold me to a record company' ,year => 2005 },
54 { title => 'Why Am I So Ugly?', year => 2006 },
55 { title => 'I Got Surgery and am now Popular', year => 2007 }
59 { name => 'Like I Give a Damn' }
63 my $artist = $rs->find(4);
65 ok($artist, 'Found artist');
66 is($artist->name, 'Manufactured Crap');
67 is($artist->cds->count, 2, 'Has CDs');
69 my @cds = $artist->cds;
71 is($cds[0]->title, 'My First CD', 'A CD');
72 is($cds[0]->year, 2006, 'Published in 2006');
74 is($cds[1]->title, 'Yet More Tweeny-Pop crap', 'Another crap CD');
75 is($cds[1]->year, 2007, 'Published in 2007');
77 $artist = $rs->find(5);
78 ok($artist, 'Found artist');
79 is($artist->name, 'Angsty-Whiny Girl');
80 is($artist->cds->count, 3, 'Has CDs');
85 is($cds[0]->title, 'My parents sold me to a record company', 'A CD');
86 is($cds[0]->year, 2005, 'Published in 2005');
88 is($cds[1]->title, 'Why Am I So Ugly?', 'A Coaster');
89 is($cds[1]->year, 2006, 'Published in 2006');
91 is($cds[2]->title, 'I Got Surgery and am now Popular', 'Selling un-attainable dreams');
92 is($cds[2]->year, 2007, 'Published in 2007');
94 $artist = $rs->search({name => 'Like I Give A Damn'})->single;
97 is($artist->cds->count, 0, 'No CDs');