Failing test for populate on RS
[dbsrgits/DBIx-Class.git] / t / 101populate_rs.t
CommitLineData
81ab7888 1use strict;
2use warnings;
3
4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
8plan tests => 18;
9
10my $schema = DBICTest->init_schema();
11my $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
30my $artist = $rs->find(4);
31
32ok($artist, 'Found artist');
33is($artist->name, 'Manufactured Crap');
34is($artist->cds->count, 2, 'Has CDs');
35
36my @cds = $artist->cds;
37
38is($cds[0]->title, 'My First CD', 'A CD');
39is($cds[0]->year, 2006, 'Published in 2006');
40
41is($cds[1]->title, 'Yet More Tweeny-Pop crap', 'Another crap CD');
42is($cds[1]->year, 2007, 'Published in 2007');
43
44$artist = $rs->find(5);
45ok($artist, 'Found artist');
46is($artist->name, 'Angsty-Whiny Girl');
47is($artist->cds->count, 3, 'Has CDs');
48
49@cds = $artist->cds;
50
51
52is($cds[0]->title, 'My parents sold me to a record company', 'A CD');
53is($cds[0]->year, 2005, 'Published in 2005');
54
55is($cds[1]->title, 'Why Am I So Ugly?', 'A Coaster');
56is($cds[1]->year, 2006, 'Published in 2006');
57
58is($cds[2]->title, 'I Got Surgery and am now Popular', 'Selling un-attainable dreams');
59is($cds[2]->year, 2007, 'Published in 2007');
60
61$artist = $rs->search({name => 'Like I Give A Damn'})->single;
62ok($artist);
63
64is($artist->cds->count, 0, 'No CDs');
65