From: Henry Van Styn Date: Wed, 29 Oct 2014 13:25:33 +0000 (-0400) Subject: Add _merge_joinpref_attr test w/ {}/undef (empty) vals X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=455b7a9bb9dbb5d7324fef0db001b29b3bbecb38;p=dbsrgits%2FDBIx-Class-Historic.git Add _merge_joinpref_attr test w/ {}/undef (empty) vals Added a test for the case of join attrs specified with empty ({} or undef) vals (i.e. join => { rel => { rel2 => {} } }). These tests pass, however, the empty {} vals currently produce uninitialized warnings. For further reference, these warnings were bypassed for RapidApp in this commit: https://github.com/vanstyn/RapidApp/commit/6f41f6e48 This test was added per the request of @ribasushi --- diff --git a/t/91merge_joinpref_attr.t b/t/91merge_joinpref_attr.t index 0e9f601..a7f9b97 100644 --- a/t/91merge_joinpref_attr.t +++ b/t/91merge_joinpref_attr.t @@ -6,7 +6,7 @@ use lib qw(t/lib); use DBICTest; use Test::More; -plan tests => 15; +plan tests => 17; my $schema = DBICTest->init_schema(); my $rs = $schema->resultset( 'CD' ); @@ -131,5 +131,20 @@ my $rs = $schema->resultset( 'CD' ); is_deeply( $result, $expected ); } +{ + my $a = [ { 'artist' => { 'manager' => {} } }, 'cd' ]; + my $b = [ 'artist', { 'artist' => { 'manager' => {} } } ]; + my $expected = [ { 'artist' => { 'manager' => {} } }, 'cd', { 'artist' => { 'manager' => {} } } ]; + my $result = $rs->_merge_joinpref_attr($a, $b); + is_deeply( $result, $expected ); +} + +{ + my $a = [ { 'artist' => { 'manager' => undef } }, 'cd' ]; + my $b = [ 'artist', { 'artist' => { 'manager' => undef } } ]; + my $expected = [ { 'artist' => { 'manager' => undef } }, 'cd', { 'artist' => { 'manager' => undef } } ]; + my $result = $rs->_merge_joinpref_attr($a, $b); + is_deeply( $result, $expected ); +} 1;