The infinite loop with sub DESTROY { $_[0]->discard_changes } is a DBIC
[dbsrgits/DBIx-Class.git] / t / discard_changes_in_DESTROY.t
CommitLineData
e60dc79f 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More;
5
6BEGIN {
7 eval "use DBIx::Class::CDBICompat;";
8 plan $@ ? (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@")
9 : (tests=> 1);
10}
11
12INIT {
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}