Some cleanup of the code.
[catagits/Web-Session.git] / t / 002_basic_w_cookie.t
CommitLineData
05b5f99d 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
05b5f99d 7
8use Plack::Request;
05b5f99d 9use Plack::Session;
10use Plack::Session::State::Cookie;
11use Plack::Session::Store;
12
f331b3e0 13use t::lib::TestSession;
14
15t::lib::TestSession::run_all_tests(
16 store => Plack::Session::Store->new,
17 state => Plack::Session::State::Cookie->new,
18 request_creator => sub {
19 my $cookies = shift;
20 open my $in, '<', \do { my $d };
21 my $env = {
22 'psgi.version' => [ 1, 0 ],
23 'psgi.input' => $in,
24 'psgi.errors' => *STDERR,
25 'psgi.url_scheme' => 'http',
26 SERVER_PORT => 80,
27 REQUEST_METHOD => 'GET',
28 HTTP_COOKIE => join "; " => map { $_ . "=" . $cookies->{ $_ } } keys %$cookies,
29 };
30 return Plack::Request->new( $env );
31 },
32 response_test => sub {
33 my ($response, $session_id, $check_expired) = @_;
34 is_deeply(
35 $response->cookies,
36 {
37 plack_session => {
38 value => $session_id,
39 path => '/',
40 ($check_expired
41 ? ( expires => '0' )
42 : ())
43 }
44 },
45 '... got the right cookies in the response'
46 );
47 }
48);
05b5f99d 49
50done_testing;