X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F03_flash.t;h=4000422e9a90289a854c9a7d8f8bdd37ebb68a46;hb=eb250519802344a677c86103e5bba640dc40d59f;hp=0ed22422731ea5eee5a98c56a932ec70c2d614c5;hpb=52feb18b99d74903d104da47b1ae9501f94d71b3;p=catagits%2FCatalyst-Plugin-Session.git diff --git a/t/03_flash.t b/t/03_flash.t index 0ed2242..4000422 100644 --- a/t/03_flash.t +++ b/t/03_flash.t @@ -3,9 +3,10 @@ use strict; use warnings; -use Test::More tests => 8; +use Test::More tests => 12; use Test::MockObject::Extends; use Test::Exception; +use Test::Deep; my $m; BEGIN { use_ok( $m = "Catalyst::Plugin::Session" ) } @@ -19,12 +20,15 @@ $c->mock( return $key =~ /expire/ ? time() + 1000 : $flash; }, ); +$c->mock("debug" => sub { 0 }); $c->mock("store_session_data" => sub { $flash = $_[2] }); $c->mock("delete_session_data" => sub { $flash = {} }); $c->set_always( _sessionid => "deadbeef" ); $c->set_always( config => { session => { expires => 1000 } } ); $c->set_always( stash => {} ); +is_deeply( $c->session, {}, "nothing in session" ); + is_deeply( $c->flash, {}, "nothing in flash" ); $c->flash->{foo} = "moose"; @@ -33,10 +37,14 @@ $c->finalize; is_deeply( $c->flash, { foo => "moose" }, "one key in flash" ); +cmp_deeply( $c->session, { __updated => re('^\d+$'), __flash => $c->flash }, "session has __flash with flash data" ); + $c->flash(bar => "gorch"); is_deeply( $c->flash, { foo => "moose", bar => "gorch" }, "two keys in flash" ); +cmp_deeply( $c->session, { __updated => re('^\d+$'), __flash => $c->flash }, "session still has __flash with flash data" ); + $c->finalize; is_deeply( $c->flash, { bar => "gorch" }, "one key in flash" ); @@ -55,6 +63,8 @@ $c->finalize; is_deeply( $c->flash, {}, "nothing in flash after finalize after clear_flash" ); +cmp_deeply( $c->session, { __updated => re('^\d+$'), }, "session has empty __flash after clear_flash + finalize" ); + $c->flash->{bar} = "gorch"; $c->config->{session}{flash_to_stash} = 1;