File: 82cascade_copy.t

package info (click to toggle)
libdbix-class-perl 0.082844-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,320 kB
  • sloc: perl: 27,215; sql: 322; sh: 29; makefile: 16
file content (40 lines) | stat: -rw-r--r-- 1,052 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use strict;
use warnings;

use Test::More;
use lib qw(t/lib);
use DBICTest;

my $schema = DBICTest->init_schema();

my $artist = $schema->resultset('Artist')->find(1);
my $artist_cds = $artist->search_related('cds');

my $cover_band = $artist->copy ({name => $artist->name . '_cover' });

my $cover_cds = $cover_band->search_related('cds');
cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...');
is($cover_cds->count, $artist_cds->count, 'duplicated rows count ok');

#check multi-keyed
is(
  $cover_band->search_related('twokeys')->count,
  $artist->search_related('twokeys')->count,
  'duplicated multiPK ok'
);

#and check copying a few relations away
cmp_ok($cover_cds->search_related('tags')->count, '==',
   $artist_cds->search_related('tags')->count , 'duplicated count ok');


# check from the other side
my $cd = $schema->resultset('CD')->find(1);
my $dup_cd = $cd->copy ({ title => 'ha!' });
is(
  $dup_cd->search_related('twokeys')->count,
  $cd->search_related('twokeys')->count,
  'duplicated multiPK ok'
);

done_testing;