Commit | Line | Data |
81ab7888 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | |
8 | plan tests => 18; |
9 | |
10 | my $schema = DBICTest->init_schema(); |
11 | my $rs = $schema->resultset('Artist'); |
12 | |
13 | $rs->populate( [ |
14 | { artistid => 4, name => 'Manufactured Crap', cds => [ |
15 | { title => 'My First CD', year => 2006 }, |
16 | { title => 'Yet More Tweeny-Pop crap', year => 2007 }, |
17 | ] |
18 | }, |
19 | { artistid => 5, name => 'Angsty-Whiny Girl', cds => [ |
20 | { title => 'My parents sold me to a record company' ,year => 2005 }, |
21 | { title => 'Why Am I So Ugly?', year => 2006 }, |
22 | { title => 'I Got Surgery and am now Popular', year => 2007 } |
23 | |
24 | ] |
25 | }, |
26 | { name => 'Like I Give a Damn' } |
27 | |
28 | ] ); |
29 | |
30 | my $artist = $rs->find(4); |
31 | |
32 | ok($artist, 'Found artist'); |
33 | is($artist->name, 'Manufactured Crap'); |
34 | is($artist->cds->count, 2, 'Has CDs'); |
35 | |
36 | my @cds = $artist->cds; |
37 | |
38 | is($cds[0]->title, 'My First CD', 'A CD'); |
39 | is($cds[0]->year, 2006, 'Published in 2006'); |
40 | |
41 | is($cds[1]->title, 'Yet More Tweeny-Pop crap', 'Another crap CD'); |
42 | is($cds[1]->year, 2007, 'Published in 2007'); |
43 | |
44 | $artist = $rs->find(5); |
45 | ok($artist, 'Found artist'); |
46 | is($artist->name, 'Angsty-Whiny Girl'); |
47 | is($artist->cds->count, 3, 'Has CDs'); |
48 | |
49 | @cds = $artist->cds; |
50 | |
51 | |
52 | is($cds[0]->title, 'My parents sold me to a record company', 'A CD'); |
53 | is($cds[0]->year, 2005, 'Published in 2005'); |
54 | |
55 | is($cds[1]->title, 'Why Am I So Ugly?', 'A Coaster'); |
56 | is($cds[1]->year, 2006, 'Published in 2006'); |
57 | |
58 | is($cds[2]->title, 'I Got Surgery and am now Popular', 'Selling un-attainable dreams'); |
59 | is($cds[2]->year, 2007, 'Published in 2007'); |
60 | |
61 | $artist = $rs->search({name => 'Like I Give A Damn'})->single; |
62 | ok($artist); |
63 | |
64 | is($artist->cds->count, 0, 'No CDs'); |
65 | |