Merge 'trunk' into 'cdbicompat_integration'
[dbsrgits/DBIx-Class.git] / t / cdbi-t / discard_changes_in_DESTROY.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More;
5
6 BEGIN {
7   eval "use DBIx::Class::CDBICompat;";
8   plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
9           : (tests=> 1);
10 }
11
12 INIT {
13     use lib 't/testlib';
14     use Film;
15 }
16
17 {
18     my @warnings;
19     local $SIG{__WARN__} = sub { push @warnings, @_; };
20     {
21         # Test that this doesn't cause infinite recursion.
22         local *Film::DESTROY;
23         local *Film::DESTROY = sub { $_[0]->discard_changes };
24         
25         my $film = Film->insert({ Title => "Eegah!" });
26         $film->director("Arch Hall Sr.");
27     }
28     is_deeply \@warnings, [];
29 }