X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi-t%2Fcolumns_as_hashes.t;fp=t%2Fcdbi-t%2Fcolumns_as_hashes.t;h=a355291d8250536365f46f590200017e832c7b9f;hb=8ed9eec640fc8718bbebc88dcf0fe9373f1ffd8e;hp=1280f6ff7d2d6bcabdb3b2e42cd77b4f8f67e193;hpb=92a23d906134d27d929dc103e37e28cb4541a006;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi-t/columns_as_hashes.t b/t/cdbi-t/columns_as_hashes.t index 1280f6f..a355291 100644 --- a/t/cdbi-t/columns_as_hashes.t +++ b/t/cdbi-t/columns_as_hashes.t @@ -19,43 +19,43 @@ my $waves = Film->insert({ Rating => 'R' }); -local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 1; +local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 0; -warnings_like { - my $rating = $waves->{rating}; - $waves->Rating("PG"); - is $rating, "R", 'evaluation of column value is not deferred'; -} qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at \Q$0}; +{ + local $ENV{DBIC_CDBICOMPAT_HASH_WARN} = 1; -warnings_like { - is $waves->{title}, $waves->Title, "columns can be accessed as hashes"; -} qr{^Column 'title' of 'Film/$waves' was fetched as a hash at\b}; + warnings_like { + my $rating = $waves->{rating}; + $waves->Rating("PG"); + is $rating, "R", 'evaluation of column value is not deferred'; + } qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at \Q$0}; -$waves->Rating("G"); + warnings_like { + is $waves->{title}, $waves->Title, "columns can be accessed as hashes"; + } qr{^Column 'title' of 'Film/$waves' was fetched as a hash at\b}; -warnings_like { - is $waves->{rating}, "G", "updating via the accessor updates the hash"; -} qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at\b}; + $waves->Rating("G"); + warnings_like { + is $waves->{rating}, "G", "updating via the accessor updates the hash"; + } qr{^Column 'rating' of 'Film/$waves' was fetched as a hash at\b}; -warnings_like { - $waves->{rating} = "PG"; -} qr{^Column 'rating' of 'Film/$waves' was stored as a hash at\b}; -$waves->update; -my @films = Film->search( Rating => "PG", Title => "Breaking the Waves" ); -is @films, 1, "column updated as hash was saved"; + warnings_like { + $waves->{rating} = "PG"; + } qr{^Column 'rating' of 'Film/$waves' was stored as a hash at\b}; + $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; @@ -66,3 +66,4 @@ warning_is { is $waves->{rating}, "R"; } + \ No newline at end of file