Test the flash feature of C::P::Session
Yuval Kogman [Mon, 5 Dec 2005 09:10:50 +0000 (09:10 +0000)]
t/03_flash.t [new file with mode: 0644]

diff --git a/t/03_flash.t b/t/03_flash.t
new file mode 100644 (file)
index 0000000..66b4531
--- /dev/null
@@ -0,0 +1,43 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 6;
+use Test::MockObject::Extends;
+use Test::Exception;
+
+my $m;
+BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) }
+
+my $c = Test::MockObject::Extends->new( $m );
+
+$c->set_always( get_session_data => { __expires => time+10000, __updated => time } );
+$c->set_always( config => { session => { expires => 1000000 } } );
+
+$c->sessionid("deadbeef");
+
+$c->_load_session;
+
+is_deeply( $c->flash, {}, "nothing in flash");
+
+$c->flash->{foo} = "moose";
+
+$c->finalize;
+$c->_load_session;
+
+is_deeply( $c->flash, { foo => "moose" }, "one key in flash" );
+
+$c->flash->{bar} = "gorch";
+
+is_deeply( $c->flash, { foo => "moose", bar => "gorch" }, "two keys in flash");
+
+$c->finalize;
+$c->_load_session;
+
+is_deeply( $c->flash, { bar => "gorch" }, "one key in flash" );
+
+$c->finalize;
+$c->_load_session;
+
+is_deeply( $c->flash, {}, "nothing in flash");