From: Ash Berlin Date: Sat, 12 May 2007 20:22:09 +0000 (+0000) Subject: Failing test for populate on RS X-Git-Tag: v0.08010~150^2~51^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=81ab78881ac2c926be35ffba2b89d2845fb9fcf1;p=dbsrgits%2FDBIx-Class.git Failing test for populate on RS --- diff --git a/t/101populate_rs.t b/t/101populate_rs.t new file mode 100644 index 0000000..9e1d2e1 --- /dev/null +++ b/t/101populate_rs.t @@ -0,0 +1,65 @@ +use strict; +use warnings; + +use Test::More; +use lib qw(t/lib); +use DBICTest; + +plan tests => 18; + +my $schema = DBICTest->init_schema(); +my $rs = $schema->resultset('Artist'); + +$rs->populate( [ + { artistid => 4, name => 'Manufactured Crap', cds => [ + { title => 'My First CD', year => 2006 }, + { title => 'Yet More Tweeny-Pop crap', year => 2007 }, + ] + }, + { artistid => 5, name => 'Angsty-Whiny Girl', cds => [ + { title => 'My parents sold me to a record company' ,year => 2005 }, + { title => 'Why Am I So Ugly?', year => 2006 }, + { title => 'I Got Surgery and am now Popular', year => 2007 } + + ] + }, + { name => 'Like I Give a Damn' } + +] ); + +my $artist = $rs->find(4); + +ok($artist, 'Found artist'); +is($artist->name, 'Manufactured Crap'); +is($artist->cds->count, 2, 'Has CDs'); + +my @cds = $artist->cds; + +is($cds[0]->title, 'My First CD', 'A CD'); +is($cds[0]->year, 2006, 'Published in 2006'); + +is($cds[1]->title, 'Yet More Tweeny-Pop crap', 'Another crap CD'); +is($cds[1]->year, 2007, 'Published in 2007'); + +$artist = $rs->find(5); +ok($artist, 'Found artist'); +is($artist->name, 'Angsty-Whiny Girl'); +is($artist->cds->count, 3, 'Has CDs'); + +@cds = $artist->cds; + + +is($cds[0]->title, 'My parents sold me to a record company', 'A CD'); +is($cds[0]->year, 2005, 'Published in 2005'); + +is($cds[1]->title, 'Why Am I So Ugly?', 'A Coaster'); +is($cds[1]->year, 2006, 'Published in 2006'); + +is($cds[2]->title, 'I Got Surgery and am now Popular', 'Selling un-attainable dreams'); +is($cds[2]->year, 2007, 'Published in 2007'); + +$artist = $rs->search({name => 'Like I Give A Damn'})->single; +ok($artist); + +is($artist->cds->count, 0, 'No CDs'); +