7 use Storable qw(dclone freeze thaw);
9 my $schema = DBICTest->init_schema();
12 dclone_method => sub { return $schema->dclone($_[0]) },
13 "freeze/thaw_method" => sub {
14 my $ice = $schema->freeze($_[0]);
15 return $schema->thaw($ice);
19 plan tests => (7 * keys %stores);
21 for my $name (keys %stores) {
22 my $store = $stores{$name};
24 my $artist = $schema->resultset('Artist')->find(1);
25 my $copy = eval { $store->($artist) };
26 is_deeply($copy, $artist, "serialize row object works: $name");
28 # Test that an object with a related_resultset can be serialized.
29 my @cds = $artist->related_resultset("cds");
30 ok $artist->{related_resultsets}, 'has key: related_resultsets';
32 $copy = eval { $store->($artist) };
33 for my $key (keys %$artist) {
34 next if $key eq 'related_resultsets';
35 next if $key eq '_inflated_column';
36 is_deeply($copy->{$key}, $artist->{$key},
37 qq[serialize with related_resultset "$key"]);
40 ok eval { $copy->discard_changes; 1 } or diag $@;
41 is($copy->id, $artist->id, "IDs still match ");