Add proper thaw hooks so schema gets re-attached
[dbsrgits/DBIx-Class.git] / t / 84serialize.t
index a8cedf0..c1b67dc 100644 (file)
@@ -8,9 +8,25 @@ use Storable;
 
 my $schema = DBICTest->init_schema();
 
-plan tests => 1;
+plan tests => 6;
 
 my $artist = $schema->resultset('Artist')->find(1);
-my $copy = eval { Storable::dclone($artist) };
-is_deeply($copy, $artist, 'serialize row object works');
+
+{
+  my $copy = $schema->dclone($artist);
+  is_deeply($copy, $artist, "dclone row object works");
+  eval { $copy->discard_changes };
+  ok( !$@, "discard_changes okay" );
+  is($copy->id, $artist->id, "IDs still match ");
+}
+
+{
+  my $ice = $schema->freeze($artist);
+  my $copy = $schema->thaw($ice);
+  is_deeply($copy, $artist, 'dclone row object works');
+
+  eval { $copy->discard_changes };
+  ok( !$@, "discard_changes okay" );
+  is($copy->id, $artist->id, "IDs still okay");
+}