X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate;a=blobdiff_plain;f=t%2Flib%2FRunTests.pm;h=53d3c6b174809bbebdf4bfc4fc0dbb844694cefc;hp=8e5afa8e3bc0e83b01aa125ea8497345140cceff;hb=861d0d247104ba5d9a05184728e19f1516521396;hpb=df9cba8acd38f0929da6d62ec6980cbc3415421a diff --git a/t/lib/RunTests.pm b/t/lib/RunTests.pm index 8e5afa8..53d3c6b 100644 --- a/t/lib/RunTests.pm +++ b/t/lib/RunTests.pm @@ -9,7 +9,7 @@ use DBIx::Class::ResultSet::RecursiveUpdate; sub run_tests{ my $schema = shift; - plan tests => 36; + plan tests => 40; my $dvd_rs = $schema->resultset( 'Dvd' ); my $user_rs = $schema->resultset( 'User' ); @@ -113,11 +113,11 @@ sub run_tests{ { dvd_name => $dvd->name, key2 => 1 } ], }; - my $dvd_updated = $dvd_rs->recursive_update( $updates ); + $dvd_updated = $dvd_rs->recursive_update( $updates ); ok ( $schema->resultset( 'Twokeys' )->find( { dvd_name => 'New Test Name', key2 => 1 } ), 'Twokeys updated' ); ok ( !$schema->resultset( 'Twokeys' )->find( { dvd_name => $dvd->name, key2 => 1 } ), 'Twokeys updated' ); - # repeatable +# repeatable $updates = { name => 'temp name', @@ -198,6 +198,21 @@ sub run_tests{ ); is( $user->borrowed_dvds->count, 1, 'if_not_submitted delete' ); + @tags = $schema->resultset( 'Tag' )->search(); + $dvd_updated = DBIx::Class::ResultSet::RecursiveUpdate::Functions::recursive_update( + resultset => $schema->resultset( 'Dvd' ), + updates => { + id => $dvd->dvd_id, # id instead of dvd_id + tags => [ { id => $tags[0]->id, file => 'file0'}, { id => $tags[1]->id, file => 'file1' } ], + } + ); + $tags[$_]->discard_changes for 0 .. 1; + is( $tags[0]->file, 'file0', 'file set in tag' ); + is( $tags[1]->file, 'file1', 'file set in tag' ); + my @rel_tags = $dvd_updated->tags; + is( scalar @rel_tags, 2, 'tags related' ); + ok( $rel_tags[0]->file eq 'file0' || $rel_tags[0]->file eq 'file1', 'tags related' ); + # $updates = { # name => 'Test name 1',