Institute a central "load this first in testing" package
[dbsrgits/DBIx-Class.git] / xt / extra / internals / discard_changes_in_DESTROY.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
e60dc79f 3use strict;
f54428ab 4use warnings;
7e36a763 5
e60dc79f 6use Test::More;
c0329273 7
7e36a763 8use DBICTest;
e60dc79f 9
7e36a763 10my $schema = DBICTest->init_schema();
e60dc79f 11
e60dc79f 12{
13 my @warnings;
14 local $SIG{__WARN__} = sub { push @warnings, @_; };
15 {
16 # Test that this doesn't cause infinite recursion.
7e36a763 17 local *DBICTest::Artist::DESTROY;
18 local *DBICTest::Artist::DESTROY = sub { $_[0]->discard_changes };
f54428ab 19
8273e845 20 my $artist = $schema->resultset("Artist")->create( {
7e36a763 21 artistid => 10,
22 name => "artist number 10",
23 });
f54428ab 24
7e36a763 25 $artist->name("Wibble");
f54428ab 26
7e36a763 27 print "# About to call DESTROY\n";
e60dc79f 28 }
29 is_deeply \@warnings, [];
f54428ab 30}
31
32done_testing;