nasty hack
[catagits/Catalyst-Plugin-Session.git] / t / 06_finalize.t
CommitLineData
60534014 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
325f6ef4 6use Test::More;
7
8BEGIN {
9 if ( eval { require Catalyst::Plugin::Session::State::Cookie } ) {
10 plan tests => 3;
11 } else {
12 plan skip_all => "Catalyst::Plugin::Session::State::Cookie required";
13 }
14}
455d7130 15
16my $finalized = 0;
60534014 17
18{
4ad471ea 19 package TestPlugin;
d505302f 20 BEGIN { $INC{"TestPlugin.pm"} = 1 } # nasty hack for 5.8.6
60534014 21
60534014 22 sub finalize_session { $finalized = 1 }
23
24 sub finalize { die "already finalized_session()" if $finalized }
25
4ad471ea 26 # Structure inheritance so TestPlugin->finalize() is called *after*
60534014 27 # Catalyst::Plugin::Session->finalize()
28 package TestApp;
29
4ad471ea 30 use Catalyst qw/
31 Session Session::Store::Dummy Session::State::Cookie +TestPlugin
32 /;
60534014 33 __PACKAGE__->setup;
34}
35
4ad471ea 36BEGIN { use_ok('Catalyst::Plugin::Session') }
60534014 37
38my $c = TestApp->new;
39eval { $c->finalize };
40ok(!$@, "finalize_session() called after all other finalize() methods");
455d7130 41ok($finalized, "finalize_session() called");