From: Yuval Kogman Date: Mon, 5 Dec 2005 09:10:50 +0000 (+0000) Subject: Test the flash feature of C::P::Session X-Git-Tag: v0.03~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da9aa7d5e1e12555689e8af70dcaa54ca16be16b;p=catagits%2FCatalyst-Plugin-Session.git Test the flash feature of C::P::Session --- diff --git a/t/03_flash.t b/t/03_flash.t new file mode 100644 index 0000000..66b4531 --- /dev/null +++ b/t/03_flash.t @@ -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");