7 use Storable qw(dclone freeze thaw);
9 my $schema = DBICTest->init_schema();
12 dclone_method => sub { return $schema->dclone($_[0]) },
13 dclone_func => sub { return dclone($_[0]) },
14 "freeze/thaw_method" => sub {
15 my $ice = $schema->freeze($_[0]);
16 return $schema->thaw($ice);
18 "freeze/thaw_func" => sub {
23 plan tests => (7 * keys %stores);
25 for my $name (keys %stores) {
26 my $store = $stores{$name};
28 my $artist = $schema->resultset('Artist')->find(1);
30 # Test that the procedural versions will work if there's a registered
31 # schema as with CDBICompat objects and that the methods work
33 if( $name =~ /func/ ) {
34 $artist->result_source_instance->schema($schema);
35 DBICTest::CD->result_source_instance->schema($schema);
38 $artist->result_source_instance->schema(undef);
39 DBICTest::CD->result_source_instance->schema(undef);
42 my $copy = eval { $store->($artist) };
43 is_deeply($copy, $artist, "serialize row object works: $name");
45 # Test that an object with a related_resultset can be serialized.
46 my @cds = $artist->related_resultset("cds");
48 ok $artist->{related_resultsets}, 'has key: related_resultsets';
50 $copy = eval { $store->($artist) };
51 for my $key (keys %$artist) {
52 next if $key eq 'related_resultsets';
53 next if $key eq '_inflated_column';
54 is_deeply($copy->{$key}, $artist->{$key},
55 qq[serialize with related_resultset "$key"]);
58 ok eval { $copy->discard_changes; 1 } or diag $@;
59 is($copy->id, $artist->id, "IDs still match ");