Not sure what I was thinking, but 18637ebb never worked :/
[dbsrgits/DBIx-Class.git] / t / 82cascade_copy.t
CommitLineData
333cce60 1use strict;
84f7e8a1 2use warnings;
333cce60 3
70350518 4use Test::More;
5use lib qw(t/lib);
6use DBICTest;
7
a47e1233 8my $schema = DBICTest->init_schema();
333cce60 9
333cce60 10my $artist = $schema->resultset('Artist')->find(1);
11my $artist_cds = $artist->search_related('cds');
83419ec6 12
84f7e8a1 13my $cover_band = $artist->copy ({name => $artist->name . '_cover' });
83419ec6 14
333cce60 15my $cover_cds = $cover_band->search_related('cds');
16cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...');
17is($cover_cds->count, $artist_cds->count, 'duplicated rows count ok');
18
19#check multi-keyed
2053211a 20is(
21 $cover_band->search_related('twokeys')->count,
22 $artist->search_related('twokeys')->count,
23 'duplicated multiPK ok'
24);
333cce60 25
26#and check copying a few relations away
27cmp_ok($cover_cds->search_related('tags')->count, '==',
28 $artist_cds->search_related('tags')->count , 'duplicated count ok');
29
2053211a 30
31# check from the other side
32my $cd = $schema->resultset('CD')->find(1);
33my $dup_cd = $cd->copy ({ title => 'ha!' });
34is(
35 $dup_cd->search_related('twokeys')->count,
36 $cd->search_related('twokeys')->count,
37 'duplicated multiPK ok'
38);
39
84f7e8a1 40done_testing;