X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=blobdiff_plain;f=t%2F93single_accessor_object.t;h=287785f8bbf30a9141d9633bcf53837d2d0a2512;hp=8c2db94f57c943670056b44c3ef06d1145d8f95e;hb=370f2ba2727791641c350a20e4fd09469503dbae;hpb=555b3385868f4954e1faf0a01d4d691a07905250 diff --git a/t/93single_accessor_object.t b/t/93single_accessor_object.t index 8c2db94..287785f 100644 --- a/t/93single_accessor_object.t +++ b/t/93single_accessor_object.t @@ -2,12 +2,13 @@ use strict; use warnings; use Test::More; +use Test::Exception; use lib qw(t/lib); use DBICTest; my $schema = DBICTest->init_schema(); -plan tests => 7; +plan tests => 10; # Test various uses of passing an object to find, create, and update on a single # rel accessor @@ -40,3 +41,24 @@ plan tests => 7; $track->update({ disc => $another_cd }); is($track->get_column('cd'), $another_cd->cdid, 'track matches another CD after update'); } + +$schema = DBICTest->init_schema(); + +{ + my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); + my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982, genreid => undef }); + + ok(!defined($cd->genreid), 'genreid is NULL'); + ok(!defined($cd->genre), 'genre accessor returns undef'); +} + +$schema = DBICTest->init_schema(); + +{ + my $artist = $schema->resultset('Artist')->create({ artistid => 666, name => 'bad religion' }); + my $genre = $schema->resultset('Genre')->create({ name => 'disco' }); + my $cd = $schema->resultset('CD')->create({ cdid => 187, artist => 1, title => 'how could hell be any worse?', year => 1982 }); + + dies_ok { $cd->genre } 'genre accessor throws without column'; +} +