BEGIN {
eval "use DBIx::Class::CDBICompat;";
plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
- : (tests=> 8);
+ : (tests=> 10);
}
use lib 't/testlib';
Rating => 'R'
});
+local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 1;
+
warnings_like {
my $rating = $waves->{rating};
$waves->Rating("PG");
$waves->update;
my @films = Film->search( Rating => "PG", Title => "Breaking the Waves" );
is @films, 1, "column updated as hash was saved";
+
+
+warning_is {
+ local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 0;
+ $waves->{rating}
+} '', 'DBIC_CDBICOMPAT_HASH_WARN controls warnings';
+
+
+{
+ local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 0;
+
+ $waves->rating("R");
+ $waves->update;
+
+ no warnings 'redefine';
+ local *Film::rating = sub {
+ return "wibble";
+ };
+
+ is $waves->{rating}, "R";
+}