Revert r482[45], by implementing a better version of r4760
[dbsrgits/DBIx-Class.git] / t / 68inflate_resultclass_hashrefinflator.t
index a0402a1..e8fe25b 100644 (file)
@@ -120,6 +120,12 @@ for my $index (0 .. $#hashrefinf) {
 
 # Test the data inflator
 
+is_deeply (
+    DBIx::Class::ResultClass::HashRefInflator->new (inflate_columns => 1),
+    DBIx::Class::ResultClass::HashRefInflator->new ({inflate_columns => 1}),
+    'Make sure arguments as list and as hashref work identically'
+);
+
 $schema->class('CD')->inflate_column( 'year',
     { inflate => sub { DateTime->new( year => shift ) },
       deflate => sub { shift->year } }
@@ -131,3 +137,16 @@ $cd_rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
 my $cd = $cd_rs->first;
 ok ( (not blessed $cd->{year}), "Plain string returned for year");
 is ( $cd->{year}, '1997', "We are looking at the right year");
+
+# try again with a HRI instance
+$cd_rs->reset;
+$cd_rs->result_class(DBIx::Class::ResultClass::HashRefInflator->new);
+my $cd2 = $cd_rs->first;
+is_deeply ($cd, $cd2, "HRI used as instance returns the same hashref as the old result_class ('class')");
+
+# try it again with inflation requested
+$cd_rs->reset;
+$cd_rs->result_class(DBIx::Class::ResultClass::HashRefInflator->new (inflate_columns => 1));
+my $cd3 = $cd_rs->first;
+isa_ok ($cd3->{year}, 'DateTime', "Inflated object");
+is ($cd3->{year}, DateTime->new ( year => 1997 ), "Correct year was inflated");