nasty hack
[catagits/Catalyst-Plugin-Session.git] / t / 06_finalize.t
index e4bdd40..65fe057 100644 (file)
@@ -3,29 +3,39 @@
 use strict;
 use warnings;
 
-use Test::More tests => 2;
+use Test::More;
+
+BEGIN {
+    if ( eval { require Catalyst::Plugin::Session::State::Cookie } ) {
+        plan tests => 3;
+    } else {
+        plan skip_all => "Catalyst::Plugin::Session::State::Cookie required";
+    }
+}
+
+my $finalized = 0;
 
 {
-  package MyTestPlugin;
-  use strict;
+  package TestPlugin;
+  BEGIN { $INC{"TestPlugin.pm"} = 1 }
 
-  my $finalized = 0;
   sub finalize_session { $finalized = 1 }
 
   sub finalize { die "already finalized_session()" if $finalized }
 
-  # Structure inheritance so MyTestPlugin->finalize() is called *after* 
+  # Structure inheritance so TestPlugin->finalize() is called *after* 
   # Catalyst::Plugin::Session->finalize()
   package TestApp;
 
-  use Catalyst qw/ Session Session::Store::Dummy Session::State::Cookie +MyTestPlugin /;
-  __PACKAGE__->config(session => { expires => 1000 });
+  use Catalyst qw/
+    Session Session::Store::Dummy Session::State::Cookie +TestPlugin 
+  /;
   __PACKAGE__->setup;
 }
 
-my $m;
-BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) }
+BEGIN { use_ok('Catalyst::Plugin::Session') }
 
 my $c = TestApp->new;
 eval { $c->finalize };
 ok(!$@, "finalize_session() called after all other finalize() methods");
+ok($finalized, "finalize_session() called");