Do not destroy callback interface (clkao)
[catagits/Web-Session.git] / t / 006_basic_w_null_store.t
CommitLineData
9bb20750 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Exception;
8
9use Plack::Request;
10use Plack::Session;
11use Plack::Session::State;
12use Plack::Session::Store::Null;
13
14my $storage = Plack::Session::Store::Null->new;
15my $state = Plack::Session::State->new;
16my $request_creator = sub {
17 open my $in, '<', \do { my $d };
18 my $env = {
19 'psgi.version' => [ 1, 0 ],
20 'psgi.input' => $in,
21 'psgi.errors' => *STDERR,
22 'psgi.url_scheme' => 'http',
23 SERVER_PORT => 80,
24 REQUEST_METHOD => 'GET',
25 };
26 my $r = Plack::Request->new( $env );
27 $r->parameters( @_ );
28 $r;
29};
30
31{
32 my $r = $request_creator->();
33
34 my $s = Plack::Session->new(
35 state => $state,
36 store => $storage,
37 request => $r,
38 );
39
40 ok($s->id, '... got a session id');
41
42 ok(!$s->get('foo'), '... no value stored in foo for session');
43
44 lives_ok {
45 $s->set( foo => 'bar' );
46 } '... set the value successfully in session';
47
48 ok(!$s->get('foo'), '... still no value stored in foo for session (null store)');
49
50 lives_ok {
51 $s->remove('foo');
52 } '... removed the value successfully in session';
53
54 lives_ok {
55 $s->expire;
56 } '... expire session successfully';
57
58 my $resp = $r->new_response;
59
60 lives_ok {
61 $s->finalize( $resp );
62 } '... finalized session successfully';
63}
64
65
66done_testing;