Introduce GOVERNANCE document and empty RESOLUTIONS file.
[dbsrgits/DBIx-Class.git] / t / inflate / serialize.t
index 1564798..2da0347 100644 (file)
@@ -1,14 +1,14 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
-use warnings;  
+use warnings;
 
 use Test::More;
-use lib qw(t/lib);
+
 use DBICTest;
 
 my $schema = DBICTest->init_schema();
 
-use Data::Dumper;
-
 my @serializers = (
     { module => 'YAML.pm',
       inflater => sub { YAML::Load (shift) },
@@ -30,14 +30,12 @@ foreach my $serializer (@serializers) {
     }
 }
 
-plan (skip_all => "No suitable serializer found") unless $selected;
-
 DBICTest::Schema::Serialized->inflate_column( 'serialized',
     { inflate => $selected->{inflater},
       deflate => $selected->{deflater},
     },
 );
-Class::C3->reinitialize;
+Class::C3->reinitialize if DBIx::Class::_ENV_::OLD_MRO;
 
 my $struct_hash = {
     a => 1,
@@ -61,20 +59,27 @@ my $inflated;
 
 #======= testing hashref serialization
 
-my $object = $rs->create( { 
+my $object = $rs->create( {
     serialized => '',
 } );
 ok($object->update( { serialized => $struct_hash } ), 'hashref deflation');
 ok($inflated = $object->serialized, 'hashref inflation');
 is_deeply($inflated, $struct_hash, 'inflated hash matches original');
 
-$object = $rs->create( { 
+$object = $rs->create( {
     serialized => '',
 } );
-eval { $object->set_inflated_column('serialized', $struct_hash) };
-ok(!$@, 'set_inflated_column to a hashref');
+$object->set_inflated_column('serialized', $struct_hash);
 is_deeply($object->serialized, $struct_hash, 'inflated hash matches original');
 
+$object = $rs->new({});
+$object->serialized ($struct_hash);
+$object->insert;
+is_deeply (
+  $rs->find ({id => $object->id})->serialized,
+  $struct_hash,
+  'new/insert works',
+);
 
 #====== testing arrayref serialization
 
@@ -82,9 +87,17 @@ ok($object->update( { serialized => $struct_array } ), 'arrayref deflation');
 ok($inflated = $object->serialized, 'arrayref inflation');
 is_deeply($inflated, $struct_array, 'inflated array matches original');
 
+$object = $rs->new({});
+$object->serialized ($struct_array);
+$object->insert;
+is_deeply (
+  $rs->find ({id => $object->id})->serialized,
+  $struct_array,
+  'new/insert works',
+);
 
-#===== make sure make_column_dirty ineracts reasonably with inflation
-$object = $rs->first;
+#===== make sure make_column_dirty interacts reasonably with inflation
+$object = $rs->search({}, { rows => 1 })->next;
 $object->update ({serialized => { x => 'y'}});
 
 $object->serialized->{x} = 'z'; # change state without notifying $object