From: Jess Robinson Date: Sat, 19 May 2007 15:33:46 +0000 (+0000) Subject: Test populate_rs with belongs_to rels X-Git-Tag: v0.08010~150^2~50^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=79fa498280663b837d48932d57c7c4aa63e38196;p=dbsrgits%2FDBIx-Class.git Test populate_rs with belongs_to rels --- diff --git a/t/101populate_rs.t b/t/101populate_rs.t index 7d25d78..3a2bc4f 100644 --- a/t/101populate_rs.t +++ b/t/101populate_rs.t @@ -5,7 +5,7 @@ use Test::More; use lib qw(t/lib); use DBICTest; -plan tests => 40; +plan tests => 43; my $schema = DBICTest->init_schema(); my $rs = $schema->resultset('Artist'); @@ -148,3 +148,15 @@ RETURN_RESULTSETS_AUTOPK: { ok( $girl->cds->count == 3, "got Expected Number of Cds"); } +## Test from a belongs_to perspective, should create artist first, then CD with artistid in: +my $cd_rs = $schema->resultset('CD'); +$cd_rs->populate([ + { title => 'Some CD', + year => 1997, + artist => { name => 'Fred Bloggs'}, + }] ); +my $cd = $schema->resultset('CD')->find({title => 'Some CD'}); + +isa_ok($cd, 'DBICTest::CD', 'Created CD'); +isa_ok($cd->artist, 'DBICTest::Artist', 'Set Artist'); +is($cd->artist->name, 'Fred Bloggs', 'Set Artist to Fred');