Commit | Line | Data |
70350518 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
e60dc79f |
7 | use Storable qw(dclone freeze thaw); |
69ac22ee |
8 | |
a47e1233 |
9 | my $schema = DBICTest->init_schema(); |
69ac22ee |
10 | |
e60dc79f |
11 | my %stores = ( |
12 | dclone => sub { return dclone($_[0]) }, |
13 | "freeze/thaw" => sub { return thaw(freeze($_[0])) }, |
14 | ); |
69ac22ee |
15 | |
e60dc79f |
16 | plan tests => (5 * keys %stores); |
69ac22ee |
17 | |
e60dc79f |
18 | for my $name (keys %stores) { |
19 | my $store = $stores{$name}; |
20 | |
21 | my $artist = $schema->resultset('Artist')->find(1); |
22 | my $copy = eval { $store->($artist) }; |
23 | is_deeply($copy, $artist, "serialize row object works: $name"); |
24 | |
25 | # Test that an object with a related_resultset can be serialized. |
26 | my @cds = $artist->related_resultset("cds"); |
27 | ok $artist->{related_resultsets}, 'has key: related_resultsets'; |
28 | |
29 | $copy = eval { $store->($artist) }; |
30 | for my $key (keys %$artist) { |
31 | next if $key eq 'related_resultsets'; |
32 | next if $key eq '_inflated_column'; |
33 | is_deeply($copy->{$key}, $artist->{$key}, |
34 | qq[serialize with related_resultset "$key"]); |
35 | } |
36 | } |