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