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