Flash data is now in a separately prefixed session storage thingy
[catagits/Catalyst-Plugin-Session.git] / t / 03_flash.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 6;
7 use Test::MockObject::Extends;
8 use Test::Exception;
9
10 my $m;
11 BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) }
12
13 my $c = Test::MockObject::Extends->new( $m );
14
15 $c->set_always( get_session_data => { } );
16 $c->set_true( "store_session_data" );
17 $c->set_always( _sessionid => "deadbeef");
18
19 $c->_load_flash;
20
21 is_deeply( $c->flash, {}, "nothing in flash");
22
23 $c->flash->{foo} = "moose";
24
25 $c->finalize;
26 $c->_load_flash;
27
28 is_deeply( $c->flash, { foo => "moose" }, "one key in flash" );
29
30 $c->flash->{bar} = "gorch";
31
32 is_deeply( $c->flash, { foo => "moose", bar => "gorch" }, "two keys in flash");
33
34 $c->finalize;
35 $c->_load_flash;
36
37 is_deeply( $c->flash, { bar => "gorch" }, "one key in flash" );
38
39 $c->finalize;
40 $c->_load_flash;
41
42 is_deeply( $c->flash, {}, "nothing in flash");