12 use Plack::Session::State;
13 use Plack::Session::Store;
16 open my $in, '<', \do { my $d };
18 'psgi.version' => [ 1, 0 ],
20 'psgi.errors' => *STDERR,
21 'psgi.url_scheme' => 'http',
23 REQUEST_METHOD => 'GET',
25 my $r = Plack::Request->new( $env );
30 my $storage = Plack::Session::Store->new;
31 my $state = Plack::Session::State->new;
34 my $s = Plack::Session->new(
40 is($s->id, 1, '... got a basic session id (1)');
42 ok(!$s->get('foo'), '... no value stored in foo for session (1)');
45 $s->set( foo => 'bar' );
46 } '... set the value successfully in session (1)';
48 is($s->get('foo'), 'bar', '... got the foo value back successfully from session (1)');
52 } '... finalized session (1) successfully';
56 my $s = Plack::Session->new(
62 is($s->id, 2, '... got a basic session id (2)');
64 ok(!$s->get('foo'), '... no value stored for foo in session (2)');
67 $s->set( foo => 'baz' );
68 } '... set the value successfully';
70 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
74 } '... finalized session (2) successfully';
78 my $s = Plack::Session->new(
81 request => request({ plack_session => 1 }),
84 is($s->id, 1, '... got a basic session id (1)');
86 is($s->get('foo'), 'bar', '... got the value for foo back successfully from session (1)');
90 } '... removed the foo value successfully from session (1)';
92 ok(!$s->get('foo'), '... no value stored for foo in session (1)');
96 } '... finalized session (1) successfully';
101 my $s = Plack::Session->new(
104 request => request({ plack_session => 2 }),
107 is($s->id, 2, '... got a basic session id (2)');
109 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
113 } '... finalized session (2) successfully';
117 my $s = Plack::Session->new(
120 request => request({ plack_session => 1 }),
123 is($s->id, 1, '... got a basic session id (1)');
125 ok(!$s->get('foo'), '... no value stored for foo in session (1)');
128 $s->set( bar => 'baz' );
129 } '... set the bar value successfully in session (1)';
133 } '... finalized session (1) successfully';
137 my $s = Plack::Session->new(
140 request => request({ plack_session => 1 }),
143 is($s->id, 1, '... got a basic session id (1)');
145 is($s->get('bar'), 'baz', '... got the bar value back successfully from session (1)');
149 } '... expired session (1) successfully';
153 my $s = Plack::Session->new(
156 request => request({ plack_session => 1 }),
159 is($s->id, 3, '... got a new session id (3)');
161 ok(!$s->get('bar'), '... no bar value stored (from session (1)) in session (3)');
165 my $s = Plack::Session->new(
168 request => request({ plack_session => 2 }),
171 is($s->id, 2, '... got a basic session id (2)');
173 is($s->get('foo'), 'baz', '... got the foo value back successfully from session (2)');
177 } '... finalized session (2) successfully';