Mark forgotten ::Row::id() method as indirect_sugar
[dbsrgits/DBIx-Class.git] / t / 33exception_wrap.t
index fdee230..0acc690 100644 (file)
@@ -1,10 +1,11 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
 use warnings;
 
 use Test::More;
 use Test::Exception;
-
-use lib qw(t/lib);
+use Test::Warn;
 
 use DBICTest;
 my $schema = DBICTest->init_schema;
@@ -23,4 +24,29 @@ is_deeply (
   'Exception-arrayref contents preserved',
 );
 
+for my $ap (qw(
+  DBICTest::AntiPattern::TrueZeroLen
+  DBICTest::AntiPattern::NullObject
+)) {
+  eval "require $ap";
+
+  warnings_like {
+    eval {
+      $schema->txn_do (sub { die $ap->new });
+    };
+
+    isa_ok $@, $ap;
+  } qr/\QObjects of external exception class '$ap' stringify to '' (the empty string)/,
+    'Proper warning on encountered antipattern';
+
+  warnings_are {
+    $@ = $ap->new;
+    $schema->txn_do (sub { 1 });
+
+    $@ = $ap->new;
+    $schema->txn_scope_guard->commit;
+  } [], 'No spurious PSA warnings on pre-existing antipatterns in $@';
+
+}
+
 done_testing;