From: zby Date: Sat, 20 Mar 2010 13:56:43 +0000 (+0100) Subject: A test case from Amiri X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=311dd083d47f66fb455316ddd0e9a85963a0733d;p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate A test case from Amiri --- diff --git a/t/lib/DBSchema.pm b/t/lib/DBSchema.pm index 9b1dca6..3d01f23 100644 --- a/t/lib/DBSchema.pm +++ b/t/lib/DBSchema.pm @@ -25,6 +25,13 @@ sub get_test_schema { my $deploy_attrs; $deploy_attrs->{add_drop_table} = 1 if tables_exist( $dsn, $user, $pass ); $schema->deploy( $deploy_attrs ); + $schema->populate('Personality', [ + [ qw/user_id / ], + [ '1'], + [ '2' ], + [ '3'], + ] + ); $schema->populate('User', [ [ qw/username name password / ], [ 'jgda', 'Jonas Alves', ''], diff --git a/t/lib/DBSchema/Result/Personality.pm b/t/lib/DBSchema/Result/Personality.pm new file mode 100644 index 0000000..3284fa1 --- /dev/null +++ b/t/lib/DBSchema/Result/Personality.pm @@ -0,0 +1,15 @@ +package DBSchema::Result::Personality; + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components( "PK::Auto", "Core" ); +__PACKAGE__->table("personality"); +__PACKAGE__->add_columns( "user_id" => { data_type => 'integer' }, ); +__PACKAGE__->set_primary_key("user_id"); +__PACKAGE__->has_one( 'user', 'DBSchema::Result::User', {'user_id' => 'foreign.id'}, ); + +1; + diff --git a/t/lib/RunTests.pm b/t/lib/RunTests.pm index 53d3c6b..88ec1c9 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 => 40; + plan tests => 41; my $dvd_rs = $schema->resultset( 'Dvd' ); my $user_rs = $schema->resultset( 'User' ); @@ -213,7 +213,15 @@ sub run_tests{ is( scalar @rel_tags, 2, 'tags related' ); ok( $rel_tags[0]->file eq 'file0' || $rel_tags[0]->file eq 'file1', 'tags related' ); + my $new_person = { + name => 'Amiri Barksdale', + username => 'amiri', + password => 'amiri', + }; + ok(my $new_user = $user_rs->recursive_update( $new_person )); + #print STDERR Dumper $new_user; + # $updates = { # name => 'Test name 1', # }; diff --git a/t/var/dvdzbr.db b/t/var/dvdzbr.db index 279e7f7..cf2b20f 100644 Binary files a/t/var/dvdzbr.db and b/t/var/dvdzbr.db differ