new config option to DBICTest to let you set an alternative storage type, start on...
[dbsrgits/DBIx-Class.git] / t / 82cascade_copy.t
1 use strict;
2 use warnings;  
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9
10 plan tests => 4;
11 my $artist = $schema->resultset('Artist')->find(1);
12 my $artist_cds = $artist->search_related('cds');
13
14 my $cover_band;
15
16 {
17   no warnings qw(redefine once);
18   local *DBICTest::Artist::result_source_instance = \&DBICTest::Schema::Artist::result_source_instance;
19
20   $cover_band = $artist->copy;
21 }
22
23 my $cover_cds = $cover_band->search_related('cds');
24 cmp_ok($cover_band->id, '!=', $artist->id, 'ok got new column id...');
25 is($cover_cds->count, $artist_cds->count, 'duplicated rows count ok');
26
27 #check multi-keyed
28 cmp_ok($cover_band->search_related('twokeys')->count, '>', 0, 'duplicated multiPK ok');
29
30 #and check copying a few relations away
31 cmp_ok($cover_cds->search_related('tags')->count, '==',
32    $artist_cds->search_related('tags')->count , 'duplicated count ok');
33