Cleanup shebang lines of all maint/example scripts, remove from tests entirely
[dbsrgits/DBIx-Class.git] / t / discard_changes_in_DESTROY.t
CommitLineData
e60dc79f 1use strict;
f54428ab 2use warnings;
7e36a763 3
e60dc79f 4use Test::More;
7e36a763 5use lib qw(t/lib);
6use DBICTest;
e60dc79f 7
7e36a763 8my $schema = DBICTest->init_schema();
e60dc79f 9
e60dc79f 10{
11 my @warnings;
12 local $SIG{__WARN__} = sub { push @warnings, @_; };
13 {
14 # Test that this doesn't cause infinite recursion.
7e36a763 15 local *DBICTest::Artist::DESTROY;
16 local *DBICTest::Artist::DESTROY = sub { $_[0]->discard_changes };
f54428ab 17
7e36a763 18 my $artist = $schema->resultset("Artist")->create( {
19 artistid => 10,
20 name => "artist number 10",
21 });
f54428ab 22
7e36a763 23 $artist->name("Wibble");
f54428ab 24
7e36a763 25 print "# About to call DESTROY\n";
e60dc79f 26 }
27 is_deeply \@warnings, [];
f54428ab 28}
29
30done_testing;