delete_session is not an internal method
[catagits/Catalyst-Plugin-Session.git] / t / 04_sessionid_stomp.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 4;
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 my $flash = {};
16 $c->mock(
17     get_session_data => sub {
18         my ( $c, $key ) = @_;
19         return $key =~ /expire/ ? time() + 1000 : $flash;
20     }
21 );
22 $c->set_true("store_session_data");
23 #$c->set_always( _sessionid => "deadbeef" );
24 $c->set_always( config     => { session => { expires => 1000 } } );
25 $c->set_always( stash      => {} );
26 $c->set_always( log => my $log = Test::MockObject->new );
27 $log->set_true( "warn" );
28
29 $c->sessionid('deadbeef');
30 is_deeply($c->sessionid(), 'deadbeef', "Session not set properly.");
31
32 $log->clear;
33
34 $c->sessionid('deadbeef2');
35 is_deeply($c->sessionid(), 'deadbeef', "Session was not stomped!.");
36
37 $log->called_ok("warn");