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